What is Samba ?
It is file sharing
What you will learn ?
- How to install and configure samba on Ubuntu
- How to share file across LAN(Local Area Network)
- Ubuntu 18.04 or Any
- Local Area Network(LAN) to share files
If you meet all these requirements then lets get started.
To install samba on your local machine you have to download it locally (installation process is same if you are installing on remote server) to install we run:
sudo apt update sudo apt install samba
Run the below command to checking if the installation was successful.
The following command will output like this.
samba: /usr/sbin/samba /usr/lib/samba /etc/samba /usr/share/samba /usr/share/man/man7/samba.7.gz /usr/share/man/man8/samba.8.gz
Configuration of Samba
Samba is install completely now we have to create a directory which we will share.
To run this command change username to your actual username. This command will create a directory named sambashare.
After that you have to edit the configuration file which is location at /etc/samba/smb.conf
sudo nano /etc/samba/smb.conf
At the bottom add the following lines
[sambashare] comment = Samba on Ubuntu path = /home/username/sambashare read only = no browsable = yes
Ctrl-O to save and
Ctrl-X to exit from the nano text editor.
What we added in Config
- [sambashare]: The name inside the brackets is the name of our share.
- comment: A brief description of the share.
- path: The directory of our share.
- read only: Permission to modify the contents of the share folder is only granted when the value of this directive is
- browsable: When set to
yes, file managers such as Ubuntu’s default file manager will list this share under “Network” (it could also appear as browseable).
Now that we have our new share configured, save it and restart Samba for it to take effect:
sudo service smbd restart
Setting up User Accounts and Connecting to Share
Samba does not use system user accounts so we have to create samba accounts to share files with others. To create user run the following command.
sudo smbpasswd -a username
Username used must belong to a system account, else it won’t save.
Connecting to Share
Open up the default file manager and click Connect to Server then enter:
In the Finder menu, click Go > Connect to Server then enter:
On Windows, open up File Manager and edit the file path to:
You’ll be prompted for your credentials. Enter them to connect!