Mount samba share on Ubuntu in CLI (Terminal)

There are two moments when you can mount a Windows share: Before you log in, and after you log in. Here are both examples:

Server name: fs Share name: install User: usr1 Password: pwd1 Local mountpoint: mnt Local user: ubuntuuser1

If you are a sudoer (or root), do the followinr

sudo smbmount //fs/install /mnt -o user=usr1 -p password:pwd1

Note that you need to be a sudoer.

If you want the share to be mounted for all users before anyone logs in, do the following:

Edit the /etc/fstab and add the line:

//fs/install  /mnt  cifs  guest,uid=1000,iocharset=utf8  0  0
//fs/install  /mnt  cifs  username=usr1,password=pwd1,iocharset=utf8,sec=ntlm  0  0

It would be wise to store the credentials elsewhere, since the 'fstab' file is readable by everyone.

Create ~/.smbcredentials

//fs/install /mnt cifs credentials=/home/ubuntuuser1/.smbcredentials,iocharset=utf8,sec=ntlm 0 0

For special permissions (like chmod), you will need to provice a uid or gid parameter to the share's options

//fs/install  /mnt  cifs   uid=ubuntuuser1,credentials=/home/ubuntuuser1/.smbcredentials,iocharset=utf8,sec=ntlm   0       0
Enter your comment:
129 -10 = 
  • linux/samba_cifs/smb_mount_from_cli.txt
  • Last modified: 2019-10-31 09:05
  • (external edit)