Mount Samba Share in Linux
List available shares on server:
Install the samba client library:
sudo apt install smbclient
Then list the shares:
smbclient -L //<your-ip-address>
You will then be prompted to enter a password (assuming your share requires one) and then will output something like this:
Sharename Type Comment
--------- ---- -------
folder-mount-1 Disk Description 1
folder-mount-2 Disk Description 2
folder-mount-3 Disk Description 3
IPC$ IPC IPC Service (Server Name)
Note the share name that you want to mount for later.
Temp mount the share to a folder:
Install the cifs-utils
package:
sudo apt install cifs-utils
Create the mount-point (folder) and then mount the share:
sudo mkdir /mnt/myFolder
sudo mount -t cifs -o username=serverUserName //myServerIpAdress/sharename /mnt/myFolder/
(Note: this will unmount upon reboot.)
Permanently mount the share to a folder:
Install the cifs-utils
package:
sudo apt install cifs-utils
Create the mount-point (folder):
sudo mkdir /mnt/myFolder
Modify your fstab
file:
sudo vi /etc/fstab
Place the following line at or near the bottom of the file:
//<your-ip-address>/<mount-name> /mnt/myFolder/ cifs username=YOURUSERNAME,password=YOURPASSWORD,iocharset=utf8,file_mode=0777,dir_mode=0777
(be sure to swap in your info into the line above)
Reboot your server and you should be off to the races. To confirm that it is still mounted, type df -h
and look found your mount in the list.