How to set up a Samba file server and share files across a local network
Samba is an implementation of the Server Message Block (SMB)/Common Internet File System (CIFS) protocol for Unix systems, providing support for cross-platform file and printer sharing with Microsoft Windows, OS X, and other Unix systems.
Prerequisite
- Ubuntu Desktop version Operating system.
- Local Area Network[LAN] to share files.
IF you are using Ubuntu server and you would like to install Desktop GUI, please follow the instruction here
To install Samba
Check for system updates and install them.
apt update
apt upgrade
Command to install Samba
apt install samba
To check if Samba installed correctly
whereis samba
Output:
samba: /usr/sbin/samba /usr/lib/x86_64-linux-gnu/samba /etc/samba /usr/share/samba /usr/share/man/man8/samba.8.gz /usr/share/man/man7/samba.7.gz
You can also install Samba from tasksel tool.
Lunch the tasksel
tasksel
A GUI interface will launch, Use the arrow key to scroll down the list and find Samba file server.
Note: Use the Space key to select it, press Tab to select OK at the bottom, then press Enter.
OutPut:
To configure Samba
Create a directory to share
Note: Replace your Username in the following command.
mkdir /home/<username>/sambashare/
And the following lines the in the Samba configuration file /etc/samba/smb.conf
Command to open file
nano /etc/samba/smb.conf
Content to add the bottom of the file
Note: change the path according to yours.
[sambashare]
comment = Samba on Ubuntu
path = /home/username/sambashare
read only = no
browsable = yes
Next, restart the Samba server.
service smbd restart
Update the firewall rules to allow Samba.
ufw allow samba
To set up a Samba password for our user account.
smbpasswd -a username
To connect and share.
Enter the following URL in the File manager to connect and share.
Note: *ip-address is the Samba server IP address.
smb://ip-address/sambashare
- Ubuntu: Open up the default file manager and click Connect to Server then enter
- Mac: In the Finder menu, click Go > Connect to Server then enter
- Windows: open up File Manager and edit the file path.
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS