Edited 2 days ago by ExtremeHow Editorial Team
FedoraSambaFile SharingConfigurationNetworkingWindows IntegrationSecure SharesSoftwareSystem AdministrationComputers
This content is available in 7 different language
Samba is a powerful open-source software suite that enables file and print services to SMB/CIFS clients. Samba is a highly flexible software package that allows interoperation between Linux/Unix servers and Windows-based clients. Here, we will go through step-by-step instructions on how to install and configure Samba on a Fedora system.
Samba is a free software re-implementation of the SMB/CIFS networking protocol. It allows end users to access and use a server's files, printers, and other shared resources, meaning you can share files and printers between computers on a network, regardless of the underlying operating system running on each machine.
Before installing Samba, make sure your Fedora system is up-to-date. This is important to avoid compatibility issues. To update your system, open the terminal and execute:
sudo dnf update
This command upgrades all installed packages to the latest version available on the Fedora repository.
To install Samba on Fedora, you will need the Samba server package. Execute the following command in the terminal:
sudo dnf install samba samba-common samba-client
This command will install the Samba server along with other required components. Once completed, verify the installation by checking the version with the following:
smbd --version
You should see the installed version of Samba as the output.
After installing Samba, the configuration file is important for defining settings and shared resources. The main configuration file is located at /etc/samba/smb.conf
. Before making changes, it is a good practice to back up this file:
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
Now you can edit the configuration file using any text editor, for example nano:
sudo nano /etc/samba/smb.conf
In the configuration file, you will see several lines and sections. Modify the [global]
section to define the basic settings for your Samba server.
[global]
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = fedora
security = user
map to guest = bad user
After the [global]
section, you can define shares by adding new sections. Each section begins with the share name in square brackets []
. Below is an example of sharing a directory:
[shared]
path = /srv/samba/shared
browsable = yes
writable = yes
guest ok = yes
read only = no
This configuration example shares /srv/samba/shared
directory, while allowing read and write access, and makes it available for guest connections. If the shared directory does not exist yet, create it:
sudo mkdir -p /srv/samba/shared
It's important to set the correct permissions for this directory to enable sharing:
sudo chown nobody:nobody /srv/samba/shared
chmod
settings can be applied according to your needs.
For authenticated access to the share, add users to Samba. Samba user management requires adding users from your Linux system:
sudo smbpasswd -a <username>
Follow the prompt to set the password for the Samba user.
Fedora's firewall needs to allow Samba traffic. Use the following command to open the required ports:
sudo firewall-cmd --permanent --zone=FedoraWorkstation --add-service=samba
sudo firewall-cmd --reload
To ensure that Samba services start on your system, use the following commands to start and enable them:
sudo systemctl start smb
sudo systemctl start nmb
sudo systemctl enable smb
sudo systemctl enable nmb
To test your configuration, use the test tools provided by Samba:
testparm
This utility will check for any syntax errors in the smb.conf
file, and show whether the settings have been applied correctly.
To access the shared resource from a Linux machine, use the following command:
smbclient //hostname/shared -U <username>
Replace hostname
with the hostname or IP address of your Fedora server, and replace <username>
with the user you added to Samba.
To access the Samba share from a Windows machine, open the Run dialog by pressing Win + R
, then enter:
\\hostname\shared
A prompt will appear to enter the Samba username and password. After logging in, you will have access to the file share.
Make sure the firewall allows Samba connections. If connection problems occur, revisit the firewall settings to make sure services such as samba
are allowed.
Check both the SYSTEM and Samba password entries. SYSTEM users must exist locally on the server. Also make sure the passwords match between the Linux and Samba configurations.
When shares do not display as expected, double-check the /etc/samba/smb.conf
file for typing or configuration errors.
Samba is an incredibly powerful tool that helps bridge the gap between different operating systems, providing seamless file and print sharing capabilities. With this guide, you should have a solid understanding of how to install, configure, and maintain Samba on a Fedora system, allowing you to create shares that can be accessed from multiple operating systems on your network. Remember to regularly check for updates and consult the detailed Samba documentation when tailoring your setup to your specific needs.
If you find anything wrong with the article content, you can