How to use samba on the command line

samba.gif

Just a short how to access samba shares via the command line.

smbtree – finds windows machines and samba shares. See example below:

~$ smbtree
Password:
WORKGROUP
MSHOME
\\MYTH-DESKTOP          myth-desktop server (Samba, Mythbuntu)
\\MYTH-DESKTOP\videos             Videos

Workgroup and MSHOME are two workgroups found by smbtree.  MYTH-DESKTOP is a machine on the MSHOME workgroup that has a samba share of “videos”.

nmblookup gets a list of NetBIOS names from the remote host:

$ nmblookup -A 192.168.2.231
Looking up status of 192.168.0.100
MYTH-DESKTOP   <00> -         B <ACTIVE>
MYTH-DESKTOP   <03> -         B <ACTIVE>
MYTH-DESKTOP   <20> -         B <ACTIVE>
..__MSBROWSE__. <01> – <GROUP> B <ACTIVE>
MSHOME          <1d> -         B <ACTIVE>
MSHOME          <1e> – <GROUP> B <ACTIVE>
MSHOME          <00> – <GROUP> B <ACTIVE>

MAC Address = 00-00-00-00-00-00

Get list of resources available on the remote host:

$ smbclient -L\\MYTH-DESKTOP -I 192.168.2.231
Password:
Domain=[MSHOME] OS=[Unix] Server=[Samba 3.0.26a]

Sharename       Type      Comment
———       —-      ——-
videos          Disk      Videos

Server               Comment
———            ——-
MYTH-DESKTOP        myth-desktop server (Samba, Mythbuntu)

Workgroup            Master
———            ——-
MSHOME               MYTH-DESKTOP
WORKGROUP        DESKTOP2

Access a resource on the remote host:

$ smbclient //MYTH-DESKTOP/videos -I 192.168.2.231 -N

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.

Example:

Copy a file:

smb> get (filename)

Permanently mount a samba share:

Add something to this effect is  your /etc/fstab (make sure you have the cifs package installed:

//server/share /localMountPoint cifs guest 0 0
then a simple "mount -a" should mount it for you.

Related Posts

Comments are closed.