Linux Administrator

How to:- Mount SMB or SAMBA in CentOS/Redhat/Fedora or Ubuntu/Debian

In Linux system we 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.

Follow these below steps to Mount SMB or SAMBA in CentOS/Redhat/Fedora or Ubuntu/Debian.

Mount SMB or SAMBA in CentOS/Redhat/Fedora

Follow these below steps to Mount SMB or SAMBA in CentOS/Redhat/Fedora:

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

Mount SMB or SAMBA in Ubuntu/Debian

If you want to mount smb or samba in Debian/Ubuntu system follow these simple below steps:

Install CIFS Utils Package

First of all install CIFS utils package on your Debain based system.

$ sudo apt-get install cifs-utils

Create Mount Point

Second, create a mount point where you want to mount hour smb. In my example I have created a mount point in /mnt director with named smb_share.

$ sudo mkdir /mnt/smb_share

Mount Volume

Third, now let’s mount the volume.

$ sudo mount -t cifs //<IP_Address>/<export_share> /mnt/<smb_share>

Mount at Boot Time

Fourth, above steps was for mounting smb temporarily. Now let’s mount smb at system boot time to mount permanently on system. Run this below command to edit the /etc/fstab file and put this line in the fstab file.

//<IP_Address>/<smb_share> cifs user=<User Name Here>,pass=<Password Here> 0 0

I hope this article helped you to mount SMB or SAMBA share on Linux/Debian 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 LookLinux 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.

10 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”

  • You’ve made some decent points there. I looked on the net for additional information about the issue and
    found most individuals will go along with your views on this web site.

  • 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