8 Ways To Mount SMBfs (SAMBA FILE SYSTEM) In Linux.

How to Mount smbfs (SAMBA file system) permanently in Linux.In this post I am going to give some examples how to do SMB (Server Message Block) mounts..


Type1 : Listing SMB shared folder through command prompt
#smbclient –L ipadd –U username
Here –L will specify listing of SMB share for the server with ipadd
#smbclient // –U username


Example :
#smbclient –L –U root


Type2 : Mounting SMB share on local folder by using smbmount command
#smbmount //ipadd/sharename /mountpoint –o username=userid,workgroup=workgroupname
Example :
#smbmount // /mnt –o username=steev,workgroup=test


Type3 : Mounting SMB share by using mount command
#mount –t smbfs ipadd:/sharename /mountpoint –o username=userid,workgroup=workgroupname
#mount –t smbfs //ipadd/sharename /mountpoint –o username=userid,workgroup=workgroupname


Example :
#mount –t smbfs /mnt –o username=surendra,workgroup=test


Type4 : Mounting CIFS (Common Internet File System) is nothing but a advanced SMB file system implementation which support RAP (Remote Access Protocol)
#mount –t cifs ipadd:/sharename /mountpoint –o username=userid,workgroup=workgroupname


Example :
#mount –t cifs /test –o username=Surendra,workgroup=test


Type5 : All the above commands will ask password to display/mount the share name, however we can specify the password in command itself as below
#mount -t smbfs -o username=userid,workgroup=workgroupname,password=XXXXX //ipadd/sharepoint /mountpoint/


Example :
#mount –t smbfs –o username=Surendra,workgroup=test,password=xylBJRS8 // /test


Type6 : Mounting permanently by editing /etc/fstab file, below is the fstab file entry example
#vi /etc/fstab// /test smbfs rw,user,username=surendra,password=xylBJRS8 0 0
Save and exit the file and conform that you edited fstab file properly. By below commands
#mount –a
This command should not throw any error,
#df –H
This command should n style="font-size: small;"> show mount from server


Type7 : Mounting a share where user belongs to a domain permanently by editing /etc/fstab file
The above command will not work properly for domain users so we have to specify domain as well when specifying username
So now username will be changed to domainusername
#vi /etc/fstab
// /mnt smbfs rw,user,username=testsurendra,password=xylBJRS8 0 0
Save the file and exit then execute mount –a and df –H for just conformation if the mount is done successfully.


Type8:As you people know /etc/fstab file is visible to all the users who logged in, so specifying user password in /etc/fstab file is not that much good procedure.. So there is a work around to resolve this issue, just create a credential file in users home directory and point that file in /etc/fstab file entry as mention below.
#cd ~
#echo username=surendra > .smbfile
#echo password=xylBJRS8 >> .smbfile
#chmod 600 .smbfile
Then edit the /etc/fstab file and specify the entries as below
#vi /etc/fstab
// /mnt smbfs credentials=/home/myhomedirectoryofuser/. smbfile,rw,user 0 0
Save and exit the file and execute mount –a, df –H to check if you did any mistakes..


Please comment your experience on SMB.




  • http://giedrius.co.uk Giedrius Tuminauskas

    Citate: This command should not “through” any error,
    MUST BE: “throw”, but not “through”

    • http://www.linuxnix.com Surendra Anne

      Thanks Giedrius. Updated the post.

  • mallika

    very informative…

  • Norliza

    If you got error "smbclient: command not found", install as root "yum install samba-client"


  • Norliza

    The only mount command that works for me is

    # mount.cifs //windows_ip/windows_folder  /linux_created_folder -o user=windows_username

    Password: <my windows password>

  • Jack Senechal

    Thanks, very useful article. One issue you should fix is that your blog software is converting dashes (-) to some unicode character (–), so copying and pasting these commands fails.