How to Install and Configure Samba on Linux
This step‑by‑step guide explains how to install Samba, enable and start the service, create a shared directory, edit the smb.conf configuration, load the settings, add a user password, test the share, and disable the firewall on a Linux system.
This guide demonstrates the complete process of installing and configuring Samba on a Linux server.
1. Install Samba and its client package: # yum install samba samba-client -y 2. Enable the Samba service to start at boot:
# systemctl enable smb.service ln -s '/usr/lib/systemd/system/smb.service' '/etc/systemd/system/multi-user.target.wants/smb.service'3. Verify that the service is enabled: # systemctl status smb.service The output should show the service loaded and enabled, though it may be inactive until started.
4. Start the Samba service:
# systemctl start smb.service # service smb start5. Create a directory to be shared and a test file:
mkdir -p /share/image touch /share/image/2.txt6. Edit the Samba configuration file ( smb.conf) located in /etc/samba/. You can refer to smb.conf.example for a template, then add sections such as:
[global] workgroup = MYGROUP server string = Samba Server Version %v log file = /var/log/samba/log.%m max log size = 50 security = user passdb backend = tdbsam load printers = yes cups options = rawDefine share definitions, for example:
[homes] comment = Home Directories browseable = no writable = yes [printers] comment = All Printers path = /var/spool/samba browseable = no guest ok = no writable = no printable = yes [image] path = /share/image public = no writable = yes [root] path = /var/samba writeable = yes browseable = yes guest ok = yes7. Test the configuration for syntax errors: # testparm The command will load the configuration and list each processed section.
8. Add a Samba password for a user (e.g., root): # smbpasswd -a root 9. Verify the share by creating a file in the shared directory:
# echo "你好" > /share/image/2.txt10. Disable the firewall to allow Samba traffic (or configure it appropriately):
# systemctl stop firewalld.service # firewall-cmd --stateThe command should return not running.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Practical DevOps Architecture
Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
