In this article, we will have explained the necessary steps to install and configure Samba on Ubuntu 18.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.
Samba is a free and open-source re-implementation of the SMB/CIFS network file sharing protocol that allows end users to access files, printers, and other shared resources.
Install Samba on Ubuntu
Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.
Step 2. Installing Samba.
Install the Samba package with the following command:
Run the below command to checking if the installation was successful:
The following should be its output:
Step 3. Configuring Global Samba Options.
Now that Samba is installed, we need to create a directory for it to 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:
At the bottom of the file, add the following lines:
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 no.
- 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:
Step 4. Setting 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:
Step 5. Connecting to Share.
Open up the default file manager and click Connect to Server then enter:
That’s all you need to do to install Samba on Ubuntu 18.04. I hope you find this quick tip helpful. If you have questions or suggestions, feel free to leave a comment below.