As a client, Samba enables you to view and work with files on a Windows system from a Linux system. This section discusses several ways of accessing Windows files from Linux. smbtree: Displays Windows SharesThe smbtree utility displays a hierarchical diagram of available shares. When you run smbtree, it prompts you for a password; do not enter a password if you want to browse shares that are visible to the guest user. The password allows you to view restricted shares, such as a user's home directory in the [homes] share. Following is sample output from smbtree: $ smbtree Password: MGS \\PB pb Samba \\PB\mark Home Directories \\PB\MainPrinter MainPrinter \\PB\ADMIN$ IPC Service (pb Samba) \\PB\IPC$ IPC Service (pb Samba) \\PB\tmp mgs temp In the preceding output, MGS is the name of the workgroup, PB is the name of the Windows machine, mark and tmp are directory shares, and MainPrinter is a shared printer. Workgroup and machine names are always shown in capitals. Refer to the smbtree man page for more information. smbclient: Connects to Windows SharesThe smbclient utility functions similarly to ftp (page 601) and connects to a Windows share; however, smbclient uses Linux-style forward slashes (/) as path separators rather than Windows-style backslashes (\). The next example connects to one of the shares displayed in the preceding example: $ smbclient //PB/mark Password: Domain=[PB] OS=[Unix] Server=[Samba 3.0.10-1.fc2] smb: \> ls . D 0 Wed Feb 22 15:10:03 2006 .. D 0 Mon Feb 6 12:40:17 2006 .kde DH 0 Tue Feb 7 22:24:17 2006 .xemacs DH 0 Mon Feb 6 10:12:45 2006 .bash_logout H 24 Tue Oct 25 06:15:04 2005 .bash_profile H 191 Tue Oct 25 06:15:04 2005 .bashrc H 124 Tue Oct 25 06:15:04 2005 ... You can use most ftp commands from smbclient. Refer to "Tutorial Session" on page 604 for some examples or give the command help to display a list of commands. Browsing Windows NetworksBrowsing Windows shares using smbtree and smbclient is quite awkward compared with the ease of browsing a network from Windows; Gnome and KDE provide more user-friendly alternatives. From either Konqueror or Nautilus (the KDE and Gnome file managers), enter smb:/ in the location bar to browse the Windows shares on the network. Both Konqueror and Nautilus use virtual filesystem add-ons, which are part of the respective desktop environments and not part of the native Linux system. As a consequence, only native Gnome or KDE applications can open files on remote shares; normal Linux programs cannot. For example, gedit and kedit will be able to open files on remote shares, while OpenOffice, mplayer, and xedit cannot. Mounting Windows SharesThe mount utility (page 466) with a t cifs option mounts a Windows share as if it were a Linux directory hierarchy. See page 1024 for more information on the CIFS protocol. When you mount a Windows share, you can write to the files on the share; you cannot write to files on a share using smbclient. A mount command that mounts a Windows share has the following syntax:
where host is the name of the system that the share is on, share is the name of the Windows share that you want to mount, and dir is the absolute pathname of the Linux directory that you are mounting the share on (the mount point). The following command, when run as root, mounts on the /share directory the share used in the preceding example. If you omit the password argument (which you may want to do for security reasons), mount prompts for it. # mount -t cifs //PB/mark /share -o username=mark,password=pizza # ls /share Desktop mansmbconf smb.conf smbout httpd.conf NVIDIA-Linux-x86-1.0-5336-pkg1.run smbhold x You can use the uid, file_mode, and dir_mode mount options with type cifs filesystems to establish ownership and permissions of mounted files. # mount -t cifs //PB/mark /share -o username=mark,uid=mark,file_mode=0644,dir_mode=0755 Permissions must be expressed as octal numbers preceded by a zero. For more information refer to the mount.cifs man page. |