How to create a SAMBA user in Linux
We should have a user account in Linux System to use SAMBA service.Note:
* You should have root privileges to create a new Linux or SAMBA user
Then, first of all, we have to create a Linux user account using the following command using Linux terminal.
Note:
*If you already have a user account created on the Linux system, you can skip the Linux user creation part below and proceed with the add samba user account.
[root@buddhika ~]# useradd newuser
User's directory automatically creates when we add a user to the system.
Create a password for the new user you just created
[root@buddhika ~]# passwd newuser
To create a SAMBA user you have to follow the following steps
[root@buddhika ~]## smbpasswd -a chathuhansa
Note;
The -a option to add a new SAMBA user to the Samba password list.If you want to modify the existing password for SAMBA users you have to pass command without option -a. Like below
If you want to reset the password you can follow this command (Without -a option)
[root@buddhika ~]#smbpasswd chathuhansa
After the user creation steps, we have to access allow to the directory (Folder) samba share in the /etc/samba/smb.conf configuration file to allow the new user to operate share directory.
[root@buddhika ~]#vi /etc/samba/smb.conf
# Chathuhansa's Share directory
[Chathuhansa's Share]
comment = Chathuhansa's Share directory
path = /home/chathushansa
public = yes
writable = yes
After the above configuration, we have to start/restart/reload service. However, following commands, we can use for the first or initial configuration. If you wish to read furthermore about services read from Redhat official site.
Note;
Not enough start/restart/reload service. We should set the service to start when turn on the computer.
[root@buddhika ~]#systemctl start smb.service
[root@buddhika ~]#systemctl enable smb.service
To delete SAMBA user
We can delete SAMBA user without affecting Linux user account.[root@buddhika ~]## smbpasswd -x chathuhansa
But, Further, if you want to delete SAMBA user with the linux user and the directory you should type following command.
[root@buddhika ~]## userdel -r chathuhansa