How to mount samba drive in Linux using command line
Solution 1:
First, unless already installed, install cifs-utils
as follows:
sudo apt-get install cifs-utils
Then, choose a path where to place a file containing the credentials to access your shared folder. Let's say /home/.smbcredentials
, as an instance.
So, open that file and write your credentials as follows:
usename=yourUsername
password=yourPassword
Also, decide where to mount your shared folder. Let's say /myfolder
, as an instance.
Now, assuming you want your network folder to be accessible as soon as your Linux system is started, edit the /etc/fstab
file. You can use nano
as follows:
sudo nano /etc/fstab
Then, you should be able to see something already written to that file. Therefore, just append one line to the bottom:
//yourHostNameOrIpAddress/path/to/your/shared/folder /your/mount/point cifs guest,iocharset=utf8,file_mode=0777,dir_mode=0777,credentials=/path/to/the/credentials/file
That's all, reboot your Linux system by typing reboot -f
and your network drive will be mounted.
As an alternative to rebooting, running /etc/fstab
as superuser should work:
sudo /etc/fstab