Linux Administrator

How to mount SAMBA share (SMBFS) in Linux

Linux system can also browse and mount SMB shares. In this article I am going to explain how you can mount SAMBA file system (SMBFS) permanently in Linux. Please note that this can be done whether the server is a Windows machine or a Samba server.

Listing SMB Share Folder

# smbclient –L IP_Address –U username

Where:

-L : Listing of SMB share

OR

# smbclient //192.168.0.5/share_file –U username

For Example:

# smbclient –L 192.168.0.5 –U santosh

Mounting SMB Share on Local Directory

# smbmount //IP_Address/sharename /mountpoint –o username=userid,workgroup=workgroupname

For Example:

# smbmount //192.168.0.5/share_file /mnt –o username=santosh,workgroup=web

Mounting SMB Share with Mount Command

# mount –t smbfs IP_Address:/sharename /mountpoint –o username=userid,workgroup=workgroupname

OR

# mount –t smbfs //IP_Address/sharename /mountpoint –o username=userid,workgroup=workgroupname

For Example:

# mount –t smbfs 192.168.0.5:/share_file /mnt –o username=santosh,workgroup=web

Mounting CIFS (Common Internet File System)

Advanced SMB file system implementation which support RAP (Remote Access Protocol).

# mount –t cifs IP_Address:/sharename /mountpoint –o username=userid,workgroup=workgroupname

For Example:

# mount –t cifs 192.168.0.5:/share_file /mountpoint –o username=santosh,workgroup=web

Mount with Password

# mount -t smbfs -o username=userid,workgroup=workgroupname,password=XXXXX //IP_Address/sharepoint /mountpoint/

For Example:

# mount –t smbfs –o username=santosh,workgroup=web,[email protected] //192.168.0.5/share_file /data

Permanent Mount

For permanent mount you will need to edit /etc/fstab file like below.

# vim /etc/fstab

//192.168.0.6/share_file   /data    smbfs  rw,user,username=santosh,[email protected] 0 0

Save and close the file.

Now run the below command to verify.

# mount -a
OR 
# df -H

For Domain User

# vim /etc/fstab

//192.168.0.5/share_file /data smbfs rw,user,username=prasad,[email protected] 0 0

Save and close.

Above prasad is a domain user.

# mount -a
OR
# df -H

Secure Way To Mount Share Permanently

As you know that /etc/fstab file is visible for all logged in user, So mentioning user and password in /etc/fstab is not a good idea. To overcome this issue just create a credential file in user’s home directory and point that file in /etc/fstab like below.

# cd ~ 
# vim .smbfile
username=santosh
[email protected]

Save and close file.

# chmod 600 .smbfile

Now edit the /etc/fstab file like below.

# vim /etc/fstab

//192.168.0.5/share_file /data smbfs credentials=/home/santosh/.smbfile rw,user 0 0

Save and close file.

Now verify by executing below command.

# mount -a
OR
# df -H

I hope this article will help to mount SMB share on Linux system. If you have any queries and problem please comment in comment section.

Thank you! for visiting LookLinux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at Look Linux Submit Article. Stay connected to Facebook.

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

9 Comments

  • I’m very happy to discover this web site. I want to to thank you for ones time due to
    this fantastic read!! I definitely enjoyed every part of it and
    I have you bookmarked to check out new stuff on your web site.

  • I savour, cause I found exactly what I wass having
    a look for. You have ended myy 4 dday lengthy hunt! God Bles you man. Have a
    great day

  • You missed the comma between the credentials and the next option ‘rw’ — cheers

    credentials=/home/santosh/.smbfile rw,user

    should

    credentials=/home/santosh/.smbfile,rw,user

  • each time i used to read smaller posts which as well clear their motive, and that is also happening with this piece of writing which I am reading at this
    time.

  • Hello there

    thanks for the information. it seems that from all the postings i have seen, it seems to me that the simpler the better. Your suggestion above worked but not completely as you have shown. In lieu of “smbfs” i used cifs as the file system type, and it worked like a charm.

    thanks

  • Thanks for the article. There is an error in your mount -t cifs command. The IP address has to have // in front and no colon. “//127.0.0.1/folder”

  • I have a possible correction for Debian users.

    To mount shared folder with mount command you on’t use:

    mount -t cifs //ip.of.samba.server:/……

    That ‘:’ should not be there. You’ll get an error.

    It should be
    mount -t cifs //ip.of.samba.server/…..

Leave a Comment