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 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 192.168.1.10. 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 //192.168.1.10/documents /mnt
Or we can also provide the password as a command option.
mount -t cifs -o username=sambauser,password=pass //192.168.1.10/documents /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.
//192.168.1.10/documents /mnt cifs username=sambauser,password=pass 0 0
Then run the mount -a command to mount the filesystem.
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,
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 //192.168.1.10/documents /mnt
The /etc/fstab entry should be as follows,
//192.168.1.10/documents /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.
- First, we installed the cifs-utils package on CentOS 7 using yum command, Then we used mount command and /etc/fstab to mount the samba cifs share.
- We also learn how to authenticate the cifs/smb share using a credentials file.