How to mount smb/cifs shares under linux

This document provides help on mounting SMB/CIFS shares under Linux.
All files accessible in a Linux and UNIX systems are arranged in one big tree, the file hierarchy, rooted at /. These files can be spread out over several devices. The mount command serves to attach the file system found on some device to the big file tree.

Use the mount command to mount remote SMB/CIFS shares under Linux as follows:

1 [www@service-labs.com~]#mount -t cifs //192.168.1.1/mySharedFolder -o username=myUser,password=myPassword /mnt/mySharedFolder

Where,
-t cifs : File system type to be mount
-o : are options passed to mount command, in this example I had passed two options. First argument is the user name (myUser) and second argument is the password (myPassword) to connect to the remote computer.
//192.168.1.1/mySharedFolder : remote computer and share name
/mnt/mySharedFolder : local mount point directory

Make sure to create /mnt/mySharedFolder first.

Once this happens you can change to the directory and view the contents using cd and ls command:

1 [www@service-labs.com~]#cd /mnt/mySharedFolder
2 [www@service-labs.com~]#ls -la

To mount a SMB/CIFS share to be mounted when a Linux system comes up after reboot edit the /etc/fstab file and an entry as follows:

//192.168.1.1/mySharedFolder /mnt/mySharedFolder cifs username=myUser,password=myPassword 0 0

Replace //192.168.1.1/mySharedFolder, myUser and myPassword with your actual parameters.

上一篇: