File Sharing
We will be installing Samba, a protocol that allows us to share your files over the local network. This is open-source implementation of Microsoft's SMB protocol.
Installation
We can install it by entering the following command:
sudo apt-get install -y samba samba-common-bin smbclient
Now that Samba is installed, we can ensure it's running by using the following command:
sudo systemctl status samba
Now that we know it's installed and running, we can set up our storage drives for sharing.
Setting Up Shares
Before we make any changes to the Samba configuration, we should back up the default. We can do this by copying the file to a backup:
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.backup
Now, we will use a terminal-based text editor known as nano. We will edit the Samba configuration file that was just backed up:
sudo nano /etc/samba/smb.conf
Samba comes with default sharing options, but we are going to modifying the configuration file to include the hard drives we mounted earlier. Using the arrows keys, navigate to the very bottom of the file.
For our Storage drive, we will be sharing it across our local network so anyone with the password can access the files on it.
[Storage]
path = /mnt/storage
writable = yes
guest ok = no
valid users = @sambashare
Once we've made our edits, we can hit Ctrl-O to save, then enter to confirm the file name, and finally Ctrl-X to class the nano editor.
Create a Samba User
Next, we will provide our user account with access to the Samba share we just made.
Change 'username' to your account's username.
sudo adduser username sambashare
Next, we will need to set the password we'll use to access our files.
Change 'username' to your account's username.
sudo smbpasswd -a username
You will be prompted to enter and confirm your password. If you wish, this can be the same as your account password.
Once that is completed, we can restart the Samba service using the following command:
sudo systemctl restart smbd
Now, we can verify that our Samba share are working by verifying the output of the following command:
smbclient -L localhost -U %
This program lists all available Samba shares on the local computer.