Running Linux, 5th Edition - Matthias Kalle Dalheimer [297]
drwxr-xr-x 23 root root 560 May 18 15:21 ..
drwxr-xr-x 1 lct users 4096 Sep 30 2003 AOL Downloads
drwxr-xr-x 1 lct users 4096 May 19 12:06 CanoScanCSUv571a
dr-xr-xr-x 1 lct users 4096 Apr 16 22:42 My Music
dr-xr-xr-x 1 lct users 4096 Sep 30 2003 My Pictures
dr-xr-xr-x 1 lct users 4096 Aug 5 2004 My Videos
-rwxr-xr-x 1 lct users 129 Jul 4 2004 desktop.ini
linux:~ # cd CanoScanCSUv571a
linux:~ # ls -al
total 3451
drwxr-xr-x 1 lct users 4096 May 19 12:06 ./
drwxr-xr-x 1 lct users 4096 May 20 02:50 ../
-rwxr-xr-x 1 lct users 3398144 Mar 13 2003 CanoScanCSUv571a.exe*
-rwxr-xr-x 1 lct users 77824 Apr 26 2002 Deldrv1205.exe*
-rwxr-xr-x 1 lct users 13644 May 21 2002 N122U.cat*
-rwxr-xr-x 1 lct users 15311 May 21 2002 N122UNT.cat*
drwxr-xr-x 1 lct users 4096 May 19 12:10 N122USG/
-rwxr-xr-x 1 lct users 6151 Apr 16 2002 N122u.inf*
-rwxr-xr-x 1 lct users 8944 Jun 12 1998 USBSCAN.SYS*
linux:~ # cp USBSCAN.SYS /tmp
linux:~ # cp /var/log/messages .
linux:~ # ls -al messages
-rwxr-xr-x 1 lct users 240117 May 20 02:58 messages
This has been a satisfying outcome, because everything works. We were able to copy a file from the SMB/CIFS share. A file was also copied to the share from the Linux filesystem. It is possible to create, change, and delete files on an SMB/CIFS mounted filesystem. Permissions that determine the limits of these operations reflect the operations permitted by the SMB/CIFS server for the effective user at its end. Linux filesystem permissions control user access to the mounted resource.
Now let's dismount the filesystem in preparation for the use of the command-line version of the smbfs toolset:
linux:~ # cd /
linux:~ # df /mnt
Filesystem 1K-blocks Used Available Use% Mounted on
//emacho/shareddocs 39061504 6782976 32278528 18% /mnt
linux:~ #umount /mnt
The Samba source tarball includes a set of tools that are meant to be run from the command line. The smbmount program is run by the mount command when used with the -t smbfs option, the way we used it previously. The smbmount program calls smbmnt, which performs the actual mounting operation. While the shared directory is mounted, the smbmount process continues to run, and if you issue a ps ax listing, you will see one smbmount process for each mounted share.
The smbmount program reads the Samba smb.conf configuration file, although it doesn't need to gather much information from it. In fact, it is possible to get by without a configuration file, or with one that is empty! The important thing is to make sure the configuration file exists in the correct location, or you will get error messages.
You will learn more about creating and validation of the configuration file later in this chapter. Here is a minimal smb.conf file:
[global]
workgroup = NAME
Simply replace NAME with the name of your workgroup, as it is configured on the Windows systems on your network.
The last thing to do is to mount the shared directory. Using smbmount can be quite easy. The command syntax is
smbmount UNC_resource_name mount_point options
where mount_point specifies a directory just as in the mount command. UNC_resource_name follows the Windows Universal Naming Convention (UNC) format, except that it replaces the backslashes with slashes. For example, if you want to mount a SMB share from the computer called maya that is exported (made available) under the name mydocs onto the directory /windocs, you could use the following command:
linux:~ # smbmount //maya/mydocs/ /windocs
If a username or password is needed to access the share, smbmount will prompt you for them.
Now let's consider a more complex example of an smbmount command:
linux:~ # smbmount //maya/d /maya-d/ \
-o credentials=/etc/samba/pw,uid=jay,gid=jay,fmask=600,dmask=700
In this example, we are using the -o option to specify options for mounting the share. Reading from left to right through the option string, we first specify a credentials file, which contains the username and password needed to access the share. This avoids having to enter them at an interactive prompt each