e Learning

How to Mount Samba Share on CentOS 7

In this tutorial we are going to learn how to mount samba share on CentOS 7. The samba is typically used to share files with Windows computers, But using the SMB/CIFS protocol we can also mount samba shares on Linux.

Install and Configure Samba Server on CentOS 7

Install cifs-utils Package

To mount samba share on CentOS 7, we need to install cifs-utils package on CentOS 7. The cifs-utils contains the tools and Utilities need to mount shares using SMB/CIFS protocol.

Install the cifs-utils package using yum install command.

yum install cifs-utils

Mount Samba Share using mount command

Now we can mount smb shares on CentOS 7 using the mount command. File system type should be cifs.

mount -t cifs -o username=username //server-name/share-name /mount-point

The mount command will prompt for the samba password once execute the command.


In My Network I have samba share server. IP Address of the server is Name of the share is Documents, the username is sambauser. I will use /mnt directory as the mount point.

mount -t cifs -o username=sambauser // /mnt

Mount Samba Share on CentOS 7

Or we can also provide the password as a command option.

mount -t cifs -o username=sambauser,password=pass // /mnt

Mount Samba Share Using fstab

If you need, you can mount the smb share automatically by adding a entry to the /etc/fstab as follows.

// /mnt cifs username=sambauser,password=pass 0 0

Then run the mount -a command to mount the filesystem.

mount -a

Use Credentials File for Authentication

Instead of giving username password as options, we can provide a credentials file which contains the username and password to access the samba share on Linux CentOS 7.


First, create the credentials file,

vim /var/smbcredentials

Add the username add the password to credentials file,



Then, mount the samba share using the Linux mount command with credentials file as option,

mount -t cifs -o credentials=/var/smbcredentials // /mnt

The /etc/fstab entry should be as follows,

// /mnt cifs credentials=/var/smbcredentials 0 0

Summary – Mount CSIF/SMB Share on CentOS 7

In this tutorial we learned how to mount samba share on Linux CentOS 7, using mount  command and /etc/fstab file.