Step-by-step guide to managing Samba users on Linux for secure file sharing across Windows and Linux networks. Perfect for VPS and dedicated server users.
Samba is a powerful tool that bridges Linux and Windows systems for seamless file sharing. Whether you are managing a secure server or building a collaborative network, adding users correctly is key to maintaining control and trust.
sudo apt install samba)Before adding a Samba user, the corresponding Linux user must exist:
sudo adduser username
If the user already exists, skip this step.
sudo smbpasswd -a username
You will be prompted to set a Samba-specific password. This password is stored securely in Samba's passwd database and can differ from the Linux login password.
Edit the Samba configuration file:
sudo nano /etc/samba/smb.conf
Add a share block like this:
[shared]
path = /srv/samba/shared
valid users = username
read only = no
browsable = yes
valid users restricts access to specific Samba users. read only = no allows write access.
sudo systemctl restart smbd
sudo systemctl restart nmbd
sudo smbpasswd -x username
To also remove the Linux user entirely:
sudo userdel -r username
/var/log/samba for suspicious activityRunning a Linux VPS or dedicated server and need reliable hosting? KMWEBSOFT provides affordable Linux VPS with full root access from $30/month — perfect for Samba file servers and other Linux workloads.
Senior Linux Administrator | Connect on LinkedIn
Professional hosting from $5/month. Done-for-you setup. Human support always.