Top Way to Setup Samba on Ubuntu
22.04
Have you ever heard about Samba? Here, we will briefly introduce this software and present the top way to Setup Samba on Ubuntu 22.04. Samba is actually a software by which users can access all files, resources, or printers that exist jointly in the network or Internet of companies and other cases. The best feature that can be mentioned about this tool is that Samba is available in the repositories of almost all Linux distributions and is easy to install.
What Is Samba?
Samba software is a free and open-source implementation of the SMB protocol used to integrate servers and desktops that are equipped with Linux or Unix systems and are located in environments with Microsoft’s active directory service. Another function of this software is to be used as a controller for the domain or as a normal member.
Samba software uses common SMB/CIFS protocols. CIFS is an open-type protocol of SMB. That is, if your programs are compatible with SMB or CIFS, they can communicate with a Samba server. Some Linux desktops have a Samba client by default. The Samba client is called smbclient.
Prerequisites
There are some requirements before you start your installation process:
– A Linux VPS with the Ubuntu OS
– Root access or Sudo privileges
Steps to Setup Samba on Ubuntu 22.04
Here, we are going to show how to install and setup Samba on Ubuntu. So, follow the instructions below:
Installing Samba on Ubuntu 22.04
If you want to install Samba on Ubuntu, first of all, you should update your system to the last version. Use this command to run the system update:
sudo apt update
In your next step, use the APT package manager in your command line to start the installation process. The installation package already exists on your system repository so you don’t need to add anything more:
sudo apt install samba
Now, check the status using the following command:
systemctl status smbd --no-pager -l
The following command will help you to make the service enabled to start the program automatically:
sudo systemctl enable --now smbd
Configuring Samba and Samba User
To do the configuration of Samba on the Ubuntu operating system, use the command below:
nano /etc/samba/smb.conf
Then find the Workgroup line and replace it with your own group:
Configuring the Firewall to Allow Samba in Ubuntu 22.04
To be able to access files shared via the SMB protocol, you must whitelist and allow the service in the firewall, outside of the computer. To do this, apply the following command:
sudo ufw allow samba
Adding User to the Samba Group
To add the current user to the Sambashare group, apply the command below and access all files and folders shared:
sudo usermod -aG sambashare $USER
Now, you should set a password for share. Note that, this one should be different from the system password:
sudo smbpasswd -a $USER
$USER is your current user, but if you want to replace another user, you can change this one with your own user. The shared files or folders should be accessible to that particular user.
As an alternative, you can use the commands below to add users to Sambagroup:
sudo usermod -aG sambashare your-user
Then to set a password use:
sudo smbpasswd -a your-user
Setup Samba on Ubuntu to Share Files
As you configured the user to use Samba, you can test it using the instructions below. e.g. sharing a picture folder. Find your desired folder and right-click on it. Choose the Properties and then Local Network Share:
If you want to delete or create files from the shared directory, you should mark the box for Allow others to create and delete files in this folder. To log in or access the shared folder you can select the Guest Access option. In the end, to create the sharing point, click on Create Share:
As soon as you see the following message on your screen, click on the “Add the permissions automatically“:
To access the remotely shared folder on Ubuntu 22.04, we will use Debian. Also, you can use Windows or MacOS:
– Go to File Manager and select Other Locations.
– Then type your Ubuntu 22.04 Samba IP address in the format below:
smb://ip-address/shared-folder-name
– You should replace ip-address with the samba server IP and Shared-folder-name with the folder you shared before:
Now you will enter the credentials. Here, you should select the Registered User and give the Username and Password which is set to use in Samba:
Now, you will have all the content of the remote Ubuntu through the Samba protocol:
Conclusion
This article was prepared to show how to install and setup Samba on Ubuntu 22.04. We also thought about how you can set the firewall to use the software. This implementation is a useful utility that can help in sharing different files and folders. Study this content carefully and enjoy using it. If you have any questions, please live a comment.
FAQ
The main directory is /etc/samba/smb. conf for the configuration file.
NFS is used for Unix-based systems and is good for faster file sharing. Samba is a Windows-based software that gives file and print services.
You might like it
MikroTik Tutorials
How to Configure VPN on Mikrotik Router
Linux Tutorials
How to Turn off Hardware Acceleration Chrome
cPanel Tutorials
1+0 Ways to Change max_execution_time in CPanel