Samba is powerful and open-source tool file server that allows file sharing across different operating systems over a network. You can access files your desktop to Windows and MacOS computers.
This article covers how to set up a Samba file server and share files across a local network.
Installing Samba
To install Samba, first run the below command in Terminal:
sudo apt-get update
sudo apt-get install samba
You can check if the installation was successful by running the following command:
samba --version
Setting up Samba
Now we are going to setup Samba to share a folder. Here I will use ~/samba
directory for sharing.
The configuration file for Samba is located at /etc/samba/smb.conf
. To add a new directory for sharing, edit the configuration file by running following command:
sudo nano /etc/samba/smb.conf
This will open the file in Nano editor. Now add the below lines at the end of file.
comment = Samba on Ubuntu
path = /home/username/samba
read only = no
browsable = yes
Then save and exit the nano editor by pressing shortcut key CTRL+O
and CTRL+X
.
Now restart the Samba service by the following command.
sudo service smbd restart
Update the firewall rule to allow Samba traffic.
sudo ufw allow samba
And setup the Samba password to user account.
sudo smbpasswd -a username
Connecting to Samba
Now from the other, where you want to access the samba folder, open the file manager and Click on Connect to Server. In the server address enter the following lines with computers IP address.
On Windows system, open File Manager and edit the file path.
For MacOS system, in the Finder menu, click Go > Connect
to Server then enter the below address:
This way you can access the folder of the computer. If you want to see all files and folders shared by the computer, just input the IP address:
This way you can access the files and folders shared by Samba.