How to create a user without useradd command on Debian 11.3

To Create A User Without Useradd Command On Debian 11.3

Introduction:

In Linux, the useradd command is one of the most popular commands for adding a new user. Contrary to popular belief, it is possible to create a user without using the useradd command. The purpose of this tutorial is to show you how to create a user without using the useradd command.

Procedure:

Step 1: Check the Oracle Linux version by using the below command

[linux@linuxhelp ~]$ lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 11 (bullseye)
Release:	11
Codename:	bullseye

Step 2: Enter the user Details in the following location by using the below command

[root@linuxhelp linux]# vim /etc/passwd
user1:x:500:500:testuser:/home/user1:/bin/bash

Step 3: Create Group user by entering the Details by using the below command

[root@linuxhelp linux]# vim /etc/group
user1:x:500:

Step 4: Create password for the user1 by using the below command

[root@linuxhelp linux]# passwd user1
Changing password for user user1.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

Step 5: Check the Encrypted password for user1 by using the below command

[root@linuxhelp linux]# cat /etc/shadow | grep user1
user1:$y$j9T$BcbPeb/pFdnDrIzK73rjs0$SSqEI7hvcj30nGX03VMnmlxNVBZiconxWbwyWfpMY.:19259::::::

Step 6: Switch over user1 by using the below command.

[root@linuxhelp linux]# su user1
User1@linuxhelp:/root$
bash-4.4$ exit

Step 7: Create home directory for user1 by using the below command

 [root@linuxhelp linux]# mkdir /home/user1

Step 8: Change Directory to user1 by using the below command

 [root@linuxhelp linux]# cd /home/user1

Step 9: Now copy the bash file to the current user1 directory by using the below command

[root@linuxhelp:/home/user1]# cp -v /etc/skel/.bash* .
'/etc/skel/.bash_logout' -> './.bash_logout'
'/etc/skel/.bashrc' -> './.bashrc'

Step 10: Now switch over to user1 by using the below command

[root@linuxhelp :/home/user1]# su user1
[user1@linuxhelp ~]$ 
[user1@linuxhelp ~]$ 
[user1@linuxhelp ~]$ 

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to create user without useradd command on Debian 11.3 Your feedback is much welcome.

FAQ
Q
How do I change the user in Linux?
A
To change to a different user and create a session as if the other user had logged in from a command prompt, type "su -" followed by a space and the target user's username. Type the target user's password when prompted.
Q
How do I find my user ID in Linux?
A
You can find the UID in the /etc/passwd file, which is the file that also stores all users registered in the system. To view the /etc/passwd file contents, run the cat command on the file, as shown below on the terminal
Q
What is the purpose of /etc/skel/?
A
The /etc/skel/ contains some hidden files which have profile settings and default values for applications. Hence, it serves as a default home directory and user profile. While using useradd –
Q
How do I list users in Linux?
A
Use the “cat” command to list all the users on the terminal.
Q
What is sudo command?
A
sudo allows a permitted user to execute a command as the superuser or another user, as specified by the security policy.