Published: July 22, 2026
Read: 9 min
In: Technology & Development

Written by

Reviewed by

Last updated: July 31, 2023

Expert verified

SVG Image

TL;DR

To add Samba user in Linux, you can follow these steps:

  1. Install Samba: Use the package manager to install Samba on your system.
  2. Create Samba User: Create a new Samba user with the desired username.
  3. Set Password: Assign a strong and secure password to the new Samba user.
  4. Verify User: Confirm the successful addition of the Samba user by checking the list of Samba users.
  5. Configure Samba Shares: Define shared directories in the Samba configuration file and restart the Samba service.

Common errors include “Failed to add user: NT_STATUS_LOGON_FAILURE,” caused by incorrect credentials, and “smbpasswd: command not found,” indicating a missing Samba installation. “Failed to find entry for user” arises when setting passwords for non-existent Samba users. The “NT_STATUS_BAD_NETWORK_NAME” error suggests network issues, while “pdbedit: uid range full!” happens when the UID limit is reached.

Continue reading the guide below to learn the step-by-step method to add Samba user in Linux and the common errors that can occur with the troubleshooting tips.

Samba is a powerful tool that enables seamless file sharing between Linux and Windows systems. In the context of Samba, users are distinct entities used for authentication when accessing shared resources. These users can be either local Linux users or specially created Samba users. By

Samba is a powerful tool that enables seamless file sharing between Linux and Windows systems. In the context of Samba, users are distinct entities used for authentication when accessing shared resources. These users can be either local Linux users or specially created Samba users. By

Samba is a powerful tool that enables seamless file sharing between Linux and Windows systems. In the context of Samba, users are distinct entities used for authentication when accessing shared resources. These users can be either local Linux users or specially created Samba users. By adding Samba users to your Linux environment, you can grant access to shared resources and create a collaborative workspace. This comprehensive guide will take you through the step-by-step process to add Samba users in Linux and troubleshooting techniques to ensure a smooth experience.

to your Linux environment, you can grant access to shared resources and create a collaborative workspace. This comprehensive guide will take you through the step-by-step process to add Samba users in Linux and troubleshooting techniques to ensure a smooth experience.

to your Linux environment, you can grant access to shared resources and create a collaborative workspace. This comprehensive guide will take you through the step-by-step process to add Samba users in Linux and troubleshooting techniques to ensure a smooth experience.

How to Add Samba User in Linux

To add Samba user in Linux, you need a Linux distribution installed, Samba software, administrative privileges, network connectivity, and basic command-line knowledge. These prerequisites ensure a seamless process of granting access to shared resources and enhancing collaboration in your Linux environment. Follow these steps to add Samba user in Linux:

  1. Launch the Terminal on your Linux system.
opening terminal 46
  1. If Samba is not installed, use your Linux distribution’s package manager to install it. Run the following command:

<strong>sudo apt-get install samba</strong>
  1. The command will install Samba on your system.
installing samba on debian
  1. Use the following command followed by the desired username to create a new Samba user. For example:

<strong>sudo smbpasswd -a username</strong>
  1. A new samba user will be created.
creating samba user
  1. You’ll be prompted to enter a password for the new Samba user. Make sure to choose a strong and secure password.
setting password for samba user
  1. To confirm that the Samba user has been added successfully, use the pdbedit command:

<strong>sudo pdbedit -L</strong>
  1. This will display a list of all Samba users on your system, including the newly added user.
verifying samba user is created successfully
  1. If you want the Samba user to access specific directories, you’ll need to configure Samba shares. Open the Samba configuration file using a text editor by running the following command:

<strong>sudo nano /etc/samba/smb.conf</strong>
  1. The command will open the configuration file in nano editor.
opening samba configuration file
  1. Under the [global] section, add a new block for each shared directory. Use the following format:

<strong>[SharedDirectoryName]</strong> <strong>  path = /path/to/shared/directory</strong> <strong>  valid users = samba_user1, samba_user2</strong> <strong>   read only = no</strong>

Replace SharedDirectoryName with a descriptive name for the share, and samba_user1, samba_user2 with the actual Samba usernames that should have access.

defining shared directories
  1. After making any changes to the Samba configuration, it’s essential to restart the Samba service for the changes to take effect. Use the following command:

<strong>sudo service smbd restart</strong>
  1. The command will restart the samba service after execution.
restarting samba service
  1. You can use Samba utilities like smbclient or smbget on the Debian server itself to test the Samba share access locally. Run the command: