November 12, 2012, 9:20 PM — The most typical use of Samba is to make Unix home directories or shared files available on Windows. Being most comfortable on the command line, I generally do this by opening a Command Prompt and entering NET USE commands. The command NET USE O: \\boson\mapdata, for example, that I might use to make files available on a Windows laptop, is the same form of the command that I would use to map shares from other Windows systems. To see a list of what is mapped, I only need to type NET USE. When I want to map a drive, I can also add the username and password on the same line, ending up with a command such as NET USE O: \\boson\mapdata /USER:sbob look@that or I can let the system prompt me to enter this information.
C:\Users\shs>net use New connections will be remembered. Status Local Remote Network ------------------------------------------------------------------------------- OK Z: \\192.168.1.148\homes Microsoft Windows Network The command completed successfully.
In a NET USE command, the string that follows \\ is the name or address of the server that is sharing files and the name that follows the next \ is the share name. Were we to look at the /etc/samba/smb.conf file, we might notice that mapdata is actually something like /opt/apps/mapdata. If we're looking at a Windows share, the same thing might be true. We might be looking at C:\Program Files\maps\mapdata while the share name is just mapdata.
To map a Windows drive on a Unix system, we need to use a mount command and specify the file system type as "cifs". For example:
# mkdir /mnt/winhome # mount -t cifs //win7/users/sbob /mnt/winhome -o username=sbob,password=look@that
CIFS is really just another name for SMB, the protocol that Windows uses to share files and printers and that Samba was named after. It's a more recent implementation of the SMB protocol with some significant enhancements.
Once a Windows share is mounted on a Unix system, you will see it when you use the mount command, though with a lot more information than you see for a mounted Unix file system.
# mount ... //win7/users/sbob on /mnt/winhome type cifs (rw,relatime,vers=1.0,sec=ntlm,cache=loose, unc=\\win7\users,username=sbob,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.1.123, file_mode=0755,nounix,serverino,rsize=61440,wsize=65536,actimeo=1)
You unmount the share with the typical umount command:
For files that need to move between Unix and Windows, this means that the files can be shared from whichever end of the connection makes the most sense.
To install Samba on a Linux system, you need at least the samba package. If you want to administer it with a desktop tool, you can add system-config-samba.