Viewing and Connecting to an SMB Samba Share on Windows/Linux/Unix

This will give you the basic info needed to browse and connect to Samba shares from the command line.  From the GUI of Gnome or KDE etc, it is pretty standard and straight forward.  However, I've found very little guides on how to do it from the command line and if you're like me, a nerd who prefers command line for its simplicity and for remote use, this is the way to go.

First get a list of all the Samba/SMB shares on the target.

smbclient -L hostname (or IP address).

If you need to specify a specific username you would use:

smbclient -U username -L hostname 

If you are prompted for a password and you know one is not required, just hit enter (in this kind of case it doesn't matter what username you authenticate as).

The list of SMB Samba shares has been returned

Domain=[OURHOUSE] OS=[Unix] Server=[Samba 3.0.28-0.el4.9]

        Sharename       Type      Comment
        ---------       ----      -------
        DVDROMExternal  Disk
        dump            Disk
        driveshare      Disk

Connect to the chosen SMB Samba Share

smbclient \\\\hostname\\sharename

Yes, you read it right.  The first part before the hostname contains 4 backslashes \\\\

And the part before share name contains two backslashes \\

smb: \> ls
  .                                   D        0  Fri Feb 27 08:50:50 2009
  ..                                  D        0  Thu Jan  8 14:32:19 2009
  New Folder                          D        0  Sat Jan 26 16:24:54 2008
  test                                D        0  Sun Sep  7 18:29:26 2008
  fdsfd                               D        0  Sun Jan 27 11:37:55 2008

You'll be prompted with something like the above.  Note that I did type "ls" to get the list of folders.

The rest is pretty normal and straight forward for anyone who has ever used command line ftp.

An SMB share retrieval example:

If you want to download a file called "test" just type:

mget test

If you want to recursively get a bunch of directories just do this:

recurse
prompt
mget *

The recurse is obvious, it means to get a directory and recursively so that means everything inside.

The prompt takes away the annoying prompt, that means for each transfer you wont' be prompted to manually confirm.


An alternate and preferred way using SMB over CIFS

If that annoys you, you can simply mount the share on your local system and then browse, retrieve and make/write files as you like (assuming your permissions on the SMB server allow for it).

Others may have had different experiences but I can only get mounting with CIFS working by using the IP and not the hostname.

mount -t cifs //192.168.1.24/driveshare /mnt/cifs -o user=guest,pass=bla

If you try with the hostname dmesg will produce this message:

CIFS VFS: cifs_mount failed w/return code = -22

 Mounting SAMBA SMB CIFS shares at boot time by using /etc/fstab

Just add a line like this to /etc/fstab

//192.168.1.24/driveshare /mnt/cifs cifs        user=guest,pass=bla 0 0

Be sure to modify the user and pass options if you require a specific user and password to connect to the share.

 


Tags:

viewing, connecting, smb, samba, linux, unixthis, info, browse, shares, gui, gnome, kde, etc, ve, guides, nerd, prefers, simplicity, smbclient, hostname, ip, specify, username, prompted, password, doesn, authenticate, domain, ourhouse, os, unix, server, sharename, dvdromexternal, disk, driveshare, contains, backslashes, ls, fri, feb, thu, folder, sep, fdsfd, ll, quot, folders, ftp, retrieval, download, mget, recursively, directories, recurse, prompt, directory, wont, manually, alternate, preferred, cifs, annoys, mount, retrieve, permissions, experiences, mounting, mnt, user, bla, dmesg, vfs, cifs_mount, fstab, modify,

Latest Articles

  • How high can a Xeon CPU get?
  • bash fix PATH environment variable "command not found" solution
  • Ubuntu Linux Mint Debian Redhat Youtube Cannot Play HD or 4K videos, dropped frames or high CPU usage with Nvidia or AMD Driver
  • hostapd example configuration for high speed AC on 5GHz using WPA2
  • hostapd how to enable and use WPS to connect wireless devices like printers
  • Dell Server Workstation iDRAC Dead after Firmware Update Solution R720, R320, R730
  • Cloned VM/Server/Computer in Linux won't boot and goes to initramfs busybox Solution
  • How To Add Windows 7 8 10 11 to GRUB Boot List Dual Booting
  • How to configure OpenDKIM on Linux with Postfix and setup bind zonefile
  • Debian Ubuntu 10/11/12 Linux how to get tftpd-hpa server setup tutorial
  • efibootmgr: option requires an argument -- 'd' efibootmgr version 15 grub-install.real: error: efibootmgr failed to register the boot entry: Operation not permitted.
  • Apache Error Won't start SSL Cert Issue Solution Unable to configure verify locations for client authentication SSL Library Error: 151441510 error:0906D066:PEM routines:PEM_read_bio:bad end line SSL Library Error: 185090057 error:0B084009:x509 certif
  • Linux Debian Mint Ubuntu Bridge br0 gets random IP
  • redis requirements
  • How to kill a docker swarm
  • docker swarm silly issues
  • isc-dhcp-server dhcpd how to get longer lease
  • nvidia cannot resume from sleep Comm: nvidia-sleep.sh Tainted: Linux Ubuntu Mint Debian
  • zfs and LUKS how to recover in Linux
  • [error] (28)No space left on device: Cannot create SSLMutex Apache Solution Linux CentOS Ubuntu Debian Mint