Have you ever wondered how you can add a new user to your Ubuntu or Debian machine? Did you know that it’s possible to add a new user without using the root account? If yes, then read on. Creating users in your operating system is important. Not everyone who uses your computer should have access to all its files and folders.
This article will guide you through the process of creating and deleting user accounts in Ubuntu, Debian, and other Debian derivatives Linux machines.
How to Create a New User
For this tutorial, we are using adduser command for example.
- With default options: The following command will create a new user account named ‘rahul’ in your system.
sudo adduser rahul
Adding user `rahul' ...
Adding new group `rahul' (1006) ...
Adding new user `rahul' (1005) with group `rahul' ...
Creating home directory `/home/rahul' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: **************
Retype new UNIX password: **************
passwd: password updated successfully
Changing the user information for rahul
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
sudo adduser rahul --home=/var/home/rahul
sudo adduser rahul --shell=/bin/bash
sudo adduser rahul --no-create-home
How to Delete User from System
Now it’s good to lock or delete any user from the system who is no longer required. Use the following command to delete any user from the system.
sudo deluser rahul
The above command will not delete the user’s home directory. If you also want to delete users’ home directory add --remove-home
parameter with the command, For example below command, will delete user rahul and their home directory permanently.
sudo deluser rahul --remove-home
You may also take a backup of the user’s home directory before deleting it using the following command.
sudo deluser rahul --remove-home --backup --backup-to /var/archives/
Conclusion
In this tutorial, we have discussed creating a new user account on Debian based system. Also provides you quick reference to delete existing users from Linux machines.
4 Comments
Worked perfectly, thanks…
i am Checkvil. This i my login on this forum. it is good ? 🙂
Hello i am from Andora and i can help you with all of problems.
Please write. Relgise
Those commands did nothing, I copied and pasted them nothing changed.