Mar 27, 2008 - Linux    Comments Off on Mount a Windows share on Linux with Samba

Mount a Windows share on Linux with Samba

Method 1

This article describes how to set up a share from a Linux box to a Windows box. Samba has to be installed.

To test if your Linux machine sees the shares on the Windows box:

smbclient -L <windows-box> -U <username>

Make a directoy for the mountpoint:

mkdir /mnt/<name-of-mount-point>


Mount the share:

mount -t smbfs -o username=<username>,password=<password>
//<win-box>/<share> /mnt/<name-of-mountpoint>

Note: The syntax -username=<username>,password=<password> saves the password.

Create a symbolic link to the mounted drive:

ln -s /mnt/<name-of-mount-point> /<path-of-symlink> Method 2

To connect to a Samba share from a Linux system, from a shell prompt, type the following command:

smbclient //hostname/sharename -U username

You will need to replace hostname with the hostname or IP address of the Samba server you want to connect to, sharename with the name of the shared directory you want to browse, and username with the Samba username for the system. Enter the correct password or press [Enter] if no password is required for the user.

If you see the smb:\> prompt, you have successfully logged in. Once you are logged in, type help for a list of commands. If you wish to browse the contents of your home directory, replace sharename with your username. If the -U switch is not used, the username of the current user is passed to the Samba server.

To exit smbclient, type exit at the smb:\> prompt.

You can also use Nautilus to view available Samba shares on your network.

On the GNOME desktop, go to the Main Menu Button (on the Panel) => Programs => Applications => Nautilus to open a Nautilus window. Type smb: in the Location: bar.

SMB Browser in Nautilus

If the SMB share you are connecting to requires a user name and password combination, you must specify them in the Location: bar using the following syntax (replace user, password, servername, and sharename with the appropriate values:

smb://user:password@servername/sharename/