How to mount Windows share on Linux

Most of us know that we use Samba to share our Linux file system and it can also be accessed under Windows very easily with no much mathematic calculation. But to mount a Windows share on Linux becomes a bit tricky for most of us. Let me show you a simple step to do the same.
NOTE: While accessing a Windows network share you use backward slash (\) but while mounting a windows share on Linux you need to use forward slash (//)

Points to be considered
1. You can mount a particular shared folder and not the machine name or IP
For eg: You can mount //192.168.0.100/deepak but you cannot mount //192.168.0.100

2. You need to have login credential for the windows share access even if the share is accessible with full permission for everyone.

On Linux RHEL 5 or above
# mount -t cifs “//path_to_windows_share/Folder_name” -o username=deepak,password=my_password  /mnt

On Linux RHEL 4 or below
# mount -t smbfs “//path_to_windows_share/Folder_name” -o username=deepak,password=my_password  /mnt
Here /mnt is the local mount point on Linux. You can use any other mount point in your case.

Once the above command is executed make sure it ran without any error
# echo $?
0

It it returns zero, that means the above command executed successfully and in case the o/p is any other digit that means the earlier command was not executed properly.

Now let us verify if our windows share is mounted

# mount
/dev/sda3 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
//192.168.0.100/deepak on /mnt type cifs (rw)

Now you can use /mnt as any other linux directory.
# cd /mnt
# ls
Let me know your success and failures.

Related Articles
How to set environment (PATH) variable permanently in Linux
Give an alias entry in Linux

Leave a Comment

close button