Connecting to a NAS with Samba
What is Samba?
Samba is an open-source application that enables users to use the SMB/CIFS networking protocol used in Windows. In short, this allows Linux users to mount network drives on their devices, providing easy access either from the command line or file explorer.
Set up
While it is feasible to set up a Samba fileshare from the command line, it is likely going to be easier to do it through the GUI of the shared file drive itself.
Logging Into the Samba Server
On Linux there is a tool called smbclient that can be used to log into network drives.
sudo apt update
sudo apt install smbclientsudo apt update
sudo apt install smbclientAccess the Samba CLI with smbclient.
smbclient //<nas-hostname-or-ip>/<shared-folder> -U <username>smbclient //<nas-hostname-or-ip>/<shared-folder> -U <username>You will be prompted to enter your password. For convenience, you can set up hostnames to access the Samba share in /etc/samba/smb.conf, but you can also use the IP of the network file server as well. For example,
smbclient //10.0.0.21/Projects -U robertsmbclient //10.0.0.21/Projects -U robertIf you can access the Samba drive with smbclient then you can mount the drive to your filesystem for more seamless access.
Note: If you're mounting a cifs drive you may also have to install
cifs-utils.
mount -t cifs -o credentials=/etc/cifs_passwd,vers=1.0 //10.0.0.21/Project /mnt/locationsmount -t cifs -o credentials=/etc/cifs_passwd,vers=1.0 //10.0.0.21/Project /mnt/locationsWhere the file /etc/cifs_passwd is a text file, should not have read permissions except by root (so you'll have to use sudo) and is formatted like,
username=youruser
password=qwerty123username=youruser
password=qwerty123In the above command, /mnt/location can be any location on your device that you choose, but mounting it under /mnt/ or /media/ is often a good choice.
ADDITIONAL RESOURCES