KMWEBSOFT
👤 Account
📅 April 2026 ✍️ KMWEBSOFT Team ← Back to Blog

How to Add and Delete a User in Samba on Linux

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.

What is Samba?

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.

Prerequisites

Step 1: Create or Verify the Linux User

Before adding a Samba user, the corresponding Linux user must exist:

sudo adduser username

If the user already exists, skip this step.

Step 2: Add the User to Samba

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.

Step 3: Configure Samba Share Access

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.

Step 4: Restart Samba Services

sudo systemctl restart smbd
sudo systemctl restart nmbd

How to Delete a Samba User

sudo smbpasswd -x username

To also remove the Linux user entirely:

sudo userdel -r username

Pro Tips for Secure File Sharing

Running 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.

KM

Written by KM Joshi

Senior Linux Administrator | Connect on LinkedIn

Ready to Get Started? 🚀

Professional hosting from $5/month. Done-for-you setup. Human support always.

Explore All Services → 🎫 Contact Support
KM Joshi

About the Author: KM Joshi

KM Joshi is the founder and lead system administrator at KMWEBSOFT, with over 10 years of experience in enterprise Linux server administration, network infrastructure, and hosting automation.

LinkedIn Profile →