Access Windows Shares in Linux
Scenario / Question:
How do I permanently mount a windows share on my linux machine
Solution / Answer:
Make sure you have the needed packages installed
Use mount command with the smbfs setting
Secure your username and password for accessing the windows share
Make sure you have the smbfs and smbclient packages installed
RedHat – Fedora – Centos
# rpm -qa samba-client
If not installed then run:
# yum install samba-client
Debian – Ubuntu
# apt-get install smbfs smbclient
Use mount command with the smbfs setting
Edit fstab to make the mount permanent and have it automatically mount at system start
# vi /etc/fstab
Append the below line to the /etc/fstab file. Make sure that its all on a single line
//windowmachine/sharename — The name of the windows machine and the name of the shared folder
/mnt/directory — The directory on your linux machine where you want the share to be mounted
smbfs — Mount option to let mount know that you are mounting a Windows share
credentials — location of file that contains the username and password for accessing the Windows Share
//windowmachine/sharename /mnt/directory smbfs credentials=/etc/.smbpasswd 0 0
Secure your username and password for accessing the windows share
Create a file to store your username and password:
# vi /etc/.smbpasswd
Add your username and password to the file:
username=windowsusername password=windowspassword
Set the permissions of /etc/.smbpasswd so that only root can access the file:
# chmod 600 /etc/.smbpasswd
Re-read your fstab and re-mount the entries:
# mount -a


