How to Set Up a Basic Samba Server on Linux
Table of Contents
Samba is a popular open-source software suite that provides seamless file and print services to SMB/CIFS clients, such as Windows and macOS systems. By setting up a Samba server on your Linux machine, you can share files and folders across your network with various operating systems. In this guide, we will show you how to set up a basic Samba server on your Linux system.
Steps
Step 1: Open Terminal
Open the terminal by pressing Ctrl + Alt + T on your keyboard or by searching for it in the applications menu.
Step 2: Install Samba
On Debian/Ubuntu-based systems:
sudo apt update && sudo apt install samba
On Fedora/RPM-based systems:
sudo dnf update && sudo dnf install samba
Step 3: Create Shared Directory
Create a directory that you want to share on your network:
sudo mkdir /srv/samba/shared_folder
Replace shared_folder with the desired folder name.
To set the appropriate permissions, use the following commands:
sudo chown -R nobody:nogroup /srv/samba/shared_folder && sudo chmod -R 0775 /srv/samba/shared_folder
Step 4: Configure Samba
To configure Samba, edit the main configuration file:
sudo nano /etc/samba/smb.conf
This example uses nano. You can use the text editor of your choice.
Add the following lines at the end of the file, replacing shared_folder and Share Description with the appropriate folder name and description:
[shared_folder]
path = /srv/samba/shared_folder
browsable = yes
guest ok = yes
read only = no
create mask = 0775
directory mask = 0775
force user = nobody
force group = nogroup
comment = Share Description
Save the file and exit the text editor.
Step 5: Restart Samba Services
After making changes to the Samba configuration, restart the Samba services:
On Debian/Ubuntu-based systems:
sudo systemctl restart smbd && sudo systemctl restart nmbd
On Fedora/RPM-based systems:
sudo systemctl restart smb && sudo systemctl restart nmb
Step 6: Enable Samba Services at Startup
To ensure that Samba services start automatically at boot, enable them with the following commands:
On Debian/Ubuntu-based systems:
sudo systemctl enable smbd && sudo systemctl enable nmbd
On Fedora/RPM-based systems:
sudo systemctl enable smb && sudo systemctl enable nmb
Step 7: Access Shared Folder
From a Windows system, open File Explorer and enter the following address in the address bar:
\\your_server_ip\shared_folder
Replace your_server_ip with your Linux server’s IP address and shared_folder with the folder name you specified in the Samba configuration.
From a macOS system, open Finder, click on Go in the menu bar, and select Connect to Server. Enter the following address:
smb://your_server_ip/shared_folder
Conclusion
By following this guide, you have successfully set up a basic Samba server on your Linux system, allowing you to share files and folders across your network with various operating systems. This setup can help you improve file sharing and collaboration within your home or office network.