Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > by-pkgid > 965e33040dd61030a94f0eb89877aee8 > files > 5393

howto-html-en-20080722-2mdv2010.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
 <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
 <TITLE>SMB HOWTO: Accessing an SMB Share With Linux Machines</TITLE>
 <LINK HREF="SMB-HOWTO-9.html" REL=next>
 <LINK HREF="SMB-HOWTO-7.html" REL=previous>
 <LINK HREF="SMB-HOWTO.html#toc8" REL=contents>
</HEAD>
<BODY>
<A HREF="SMB-HOWTO-9.html">Next</A>
<A HREF="SMB-HOWTO-7.html">Previous</A>
<A HREF="SMB-HOWTO.html#toc8">Contents</A>
<HR>
<H2><A NAME="s8">8. Accessing an SMB Share With Linux Machines</A></H2>

<P>Linux (UNIX) machines can also browse and mount SMB shares.  Note that this can be done whether the server is a Windows machine or a Samba server!
<P>An SMB client program for UNIX machines is included with the Samba distribution.  It provides an ftp-like interface on the command line.  You can use this utility to transfer files between a Windows 'server' and a Linux client.
<P>Most Linux distributions also now include the useful smbfs package, which allows one to mount and umount SMB shares.  More on smbfs below.
<P>To see which shares are available on a given host, run:
<P>
<HR>
<PRE>
    /usr/bin/smbclient -L host
</PRE>
<HR>
<P>where 'host' is the name of the machine that you wish to view.  this will return a list of 'service' names - that is, names of drives or printers that it can share with you.  Unless the SMB server has no security configured, it will ask you for a password.  Get it the password for the 'guest' account or for your personal account on that machine.
<P>For example:
<P>
<HR>
<PRE>
    smbclient -L zimmerman
</PRE>
<HR>
<P>The output of this command should look something like this:
<P>
<BLOCKQUOTE><CODE>
<HR>
<PRE>
Server time is Sat Aug 10 15:58:27 1996
Timezone is UTC+10.0
Password: 
Domain=[WORKGROUP] OS=[Windows NT 3.51] Server=[NT LAN Manager 3.51]

Server=[ZIMMERMAN] User=[] Workgroup=[WORKGROUP] Domain=[]

        Sharename      Type      Comment
        ---------      ----      -------
        ADMIN$         Disk      Remote Admin
        public         Disk      Public 
        C$             Disk      Default share
        IPC$           IPC       Remote IPC
        OReilly        Printer   OReilly
        print$         Disk      Printer Drivers


This machine has a browse list:

        Server               Comment
        ---------            -------
        HOPPER               Samba 1.9.15p8
        KERNIGAN             Samba 1.9.15p8
        LOVELACE             Samba 1.9.15p8
        RITCHIE              Samba 1.9.15p8
        ZIMMERMAN            
</PRE>
<HR>
</CODE></BLOCKQUOTE>
<P>The browse list shows other SMB servers with resources to share on the network.
<P>To use the client, run:
<P>
<HR>
<PRE>
    /usr/bin/smbclient service &lt;password>
</PRE>
<HR>
<P>where 'service' is a machine and share name.  For example, if you are trying to reach a directory that has been shared as 'public' on a machine called zimmerman, the service would be called \\zimmerman\public.  However, due to shell restrictions, you will need to escape the backslashes, so you end up with something like this:
<P>
<HR>
<PRE>
    /usr/bin/smbclient \\\\zimmerman\\public mypasswd
</PRE>
<HR>
<P>where 'mypasswd' is the literal string of your password.
<P>You will get the smbclient prompt:
<P>
<BLOCKQUOTE><CODE>
<HR>
<PRE>
Server time is Sat Aug 10 15:58:44 1996
Timezone is UTC+10.0
Domain=[WORKGROUP] OS=[Windows NT 3.51] Server=[NT LAN Manager 3.51]
smb: \> 
</PRE>
<HR>
</CODE></BLOCKQUOTE>
<P>Type 'h' to get help using smbclient:
<P>
<BLOCKQUOTE><CODE>
<HR>
<PRE>
smb: \> h
ls             dir            lcd            cd             pwd            
get            mget           put            mput           rename         
more           mask           del            rm             mkdir          
md             rmdir          rd             prompt         recurse        
translate      lowercase      print          printmode      queue          
cancel         stat           quit           q              exit           
newer          archive        tar            blocksize      tarmode        
setmode        help           ?              !              
smb: \> 
</PRE>
<HR>
</CODE></BLOCKQUOTE>
<P>If you can use ftp, you shouldn't need the man pages for smbclient.
<P>Although you can use smbclient for testing, you will soon tire of it for real work.  For that you will probably want to use the smbfs package.  Smbfs comes with two simple utilties, smbmount and smbumount.  They work just like mount and umount for SMB shares.
<P>One important thing to note:  You must have smbfs support compiled into your kernel to use these utilities!
<P>The following shows a typical use of smbmount to mount an SMB share called &quot;customers&quot; from a machine called &quot;samba1&quot;:
<P>
<BLOCKQUOTE><CODE>
<HR>
<PRE>
[root@postel]# smbmount "\\\\samba1\\customers" -U rtg2t -c 'mount /customers -u 500 -g 100'
Added interface ip=192.168.35.84 bcast=192.168.255.255 nmask=255.255.0.0
Got a positive name query response from 192.168.168.158 ( 192.168.168.158 )
Server time is Tue Oct  5 10:27:36 1999
Timezone is UTC-4.0
Password:
Domain=[IPM] OS=[Unix] Server=[Samba 2.0.3]
security=user
</PRE>
<HR>
</CODE></BLOCKQUOTE>
<P>Issuing a mount command will now show the share mounted, just as if it were an NFS export:
<P>
<BLOCKQUOTE><CODE>
<HR>
<PRE>
[root@postel]# mount                                                                                                    
/dev/hda2 on / type ext2 (rw)
none on /proc type proc (rw)
none on /dev/pts type devpts (rw,mode=622)
//SAMBA1/CUSTOMERS on /customers type smbfs (0)
</PRE>
<HR>
</CODE></BLOCKQUOTE>
<P>Please see the manual pages for smbmount and smbumount for details on the above operation.
<P>
<P>
<HR>
<A HREF="SMB-HOWTO-9.html">Next</A>
<A HREF="SMB-HOWTO-7.html">Previous</A>
<A HREF="SMB-HOWTO.html#toc8">Contents</A>
</BODY>
</HTML>