Create User for specific purpose like Samba Sharing

Posted on

This is an article which is made to explain some description on creating new user for specific purpose like samba sharing in Linux variant distribution. The purpose of creating user for samba is simple which is a user registered in the operating system without having a further need to own a user home directory, the ability to log in since the need is only specified to access samba folder and file share definition.

To be able to achieve it, the command or tool used is the same with the one used for creating normal user which is the ‘adduser’ command.

But since there is another specific need in the user creation process, the command need to be combined with another parameter so that the purpose can be accomplished. Below is the optional parameter of the command used to create new user without home user directory and the ability to log in to the system :

adduser --no-create-home --disabled-password --disabled-login username

Description : 
adduser : It is the command or the tool used to create new user in most Linux or Unix variant operating system
--no-create-home : It is an additional parameter used to create new user so that the user created doesn't have any home user directory even if it doesn't exist in the first place. 
--disabled-password : It is an additional parameter used to create new user but the password entry is disabled although login is still possible if there is no password authentication for SSH RSA keys for an example. 
--disabled-login : It is an additional parameter used to create new user but the login access for every connection method available is disabled. 

The pattern of creating user above can be achieved by executing it with the following steps :

1. Switch to root user by executing the following command :

sudo su -

The execution of the above command in real execution :

user@hostname:~$ sudo su -
[sudo] password for user: 
  1. After turning into root, execute the following command to add a specific user :
adduser --no-create-home --disabled-password --disabled-login user_name

This is the execution of the command in the command line :

root@hostname:~# adduser --no-create-home --disabled-password --disabled-login guests
Adding user `guests' ...
Adding new group `guests' (1008) ...
Adding new user `guests' (1007) with group `guests' ...
Not creating home directory `/home/guests'.
Changing the user information for guests
Enter the new value, or press ENTER for the default
Full Name []: Guests
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] Y

The user which is prepared for specific purpose has already successfully created. Below is a way to prove it :

root@hostname:~# su - guests
No directory, logging in with HOME=/
guests@hostname:/$ exit

As shown in the above command’s execution output, switching to user guests shown that no home directory exist. And switch user to user guests doesn’t need a password to be provided.

4 thoughts on “Create User for specific purpose like Samba Sharing

Leave a Reply