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



Great article! It did exactly as stated and the .smbpasswd file is a nice touch.
One note: some modern distros will require the the use of ‘cifs’ instead of ‘smbfs’ in the /etc/fstab file. Otherwise, you might get this error:
mount: unknown filesystem type ‘smbfs’
Hope this helps someone else. Cheers!
the above comment helped me!
nice article.
i have been trying to create windows shares on ubuntu machines. i have a centos 5.5 server. i want to create shares on the server for students but i am having trouble setting it up.
i tried the above but to no succes.
can anyone redirect me to any simple url regarding this .. please