How to mount SAMBA share (SMBFS) in Linux

Written By:- Santosh Prasad

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


-L : Listing of SMB share


# smbclient // –U username

For Example:

# smbclient –L –U santosh

Mounting SMB Share on Local Directory

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

For Example:

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

Mounting SMB Share with Mount Command

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


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

For Example:

# mount –t smbfs /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 /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] // /data

Permanent Mount

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

# vim /etc/fstab

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

Save and close the file.

Now run the below command to verify.

# mount -a
# df -H

For Domain User

# vim /etc/fstab

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

Save and close.

Above prasad is a domain user.

# mount -a
# 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
[email protected]

Save and close file.

# chmod 600 .smbfile

Now edit the /etc/fstab file like below.

# vim /etc/fstab

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

Save and close file.

Now verify by executing below command.

# mount -a
# 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.


About Author


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.

Other Post by Santosh Prasad

Visit All Post

Related Article

You may also Like

Leave a Comment