In IT’s World, it is common to hear about system users, especially if you work in the administration of systems under that environment. GNU/LINUX is a multiuser and reliable operating system in terms of security, but it is always good to know the basics of managing system users. Well, today we’ll be talking about creating, modifying and deleting users in the GNU/LINUX systems. Here, i will explain how to add user to Linux and Modify or remove user to Linux machine.
USERS IN GNU/LINUX
The first thing we need to know is that, in GNU/LINUX there are different types of users already predefined and each of them have different characteristics for the correct functioning of the system. The first of these is the root user.
Root user
The Root user is the administrator of the operating system, with all options and permissions to perform operations and changes in the system. Its main features are:
- It is the only user account with system-wide privileges.
- In charge of controlling the administration of user accounts.
- It is the only user that can stop the system.
- The root user can install, uninstall and update basic system programs and libraries.
In other words, the root user is the all-powerful user of the system.
Special Users
They are also called users without login. Their roles in the system are determined by the addition of installed programs. They are distinguished by:
- They are created (usually) automatically at the time of Linux or application installation.
- It does not have all the privileges of the root user, but depending on the account they assume different root privileges.
- They are created when installing the system or any of its extra components.
- Some of them are: bin, daemon, adm, lp, sync, shutdown, mail, operator, squid, apache
Common Users
These last users are us. That is, they are accounts that are created to use all accessible parts of the system, such as assigned programs and directories. They have a Home directory where they can easily access their documents and files.
- Such users have only full privileges in their working directory or HOME.
- They are used for individual users.
- These users do not have privileges to manage the system or install software.
How to Create or Add USERS TO Linux Systems?
The adduser command is a “new” alternative to the useradd binary that allows us to add common users to our GNU/LINUX distribution. It is much more “friendly” and intuitive than useradd and allows us to add additional information about the new user. Here we will learn how to create user on Linux system.
In order to use the adduser command we must be root users, for that reason write the following command in a terminal
#Connect using su. su
You need to write the root password then we can use adduser. The most basic way to use the adduser command is:
adduser new_user
where new_user is the name of user account. With this “basic” form a new user is created and by giving Enter we are asked to enter the new password for this new user account.
Type the password for your new user account and press Enter. Prompt will ask you to reenter the same password. Re-enter the password and press enter button.
After that you will be asked for any additional information such as Full Name, phone number etc.
At the end, prompt will ask us to confirm the information provided. Type Y to proceed if all information is correct.
Now, as mentioned above, that is the most basic way to create a user but adduser also has options and alternatives to create users. These alternatives are given by the options that can be added to the command, some of them are:
adduser [--home DIR] [--shell SHELL] [--no-create-home] [--uid ID] [--firstuid ID] [--lastuid ID] [--gecos GECOS] [--ingroup GROUP | --gid ID] [--disabled-password] [--disabled-login] [--add_extra_groups] USER
You can see various options available with adduser command in above screenshot. Let’s look at example. If you would like to add a user named angelob, and set their home directory to /opt/angelob/ the the command will be as follows.
adduser --home /opt/angelob/ angelob
And then it will ask us for the new password and basic user information. This way you can add user to Linux system.
How to Delete Linux User Accounts?
As in above section we have learnt how to create user on Linux system. Here i will explain how remove user from Linux system. Removing users from the Linux system is simple and the command to do so is userdel and has many fewer options to make the task. You can see the descriptions for this command in below image.
The easiest way to delete a user is to remove it by running below command. Here user is the name of user account.
#user is the name of user account.
userdel user
We can also delete your entire personal directory with the -r option. Run below command to do this.
userdel -r user
How to Modify Linux User Accounts?
I have shown how to remove Linux user in above section. Here, i will explain how to modify a Linux user. To modify users in the GNU/LINUX system we use the command usermod. We can see in the following image the possibilities shown in command:
For example, if we wanted to change the password of a created user, it would be as follows.
#user is the name of Linux user account. usermod -p ‘new_password’ user
Obviously this method is not recommended because it leaves the password visible. Be careful. Read below article if you want to change your Linux user account password.
Another useful example is to move the personal folder of the desired user to another one, for it we must combine the options -d and -m in the following way.
usermod -d /opt/angelob1/ -m angelob
With the rest of the options, we only have to place them according to our needs.
In conclusion we can say that the administration of GNU/LINUX users is a matter for system administrators, the subject is wide and with many options to take into account for the creation of them.
Adduser simplifies the creation of user accounts and usermod allows us to modify them in a very fast and dynamic way. And if a user has already completed his life cycle in the system, we can remove it with userdel.
I hope this small guide has been useful to understand a little bit about GNU/LINUX users, clarifying that the commands explained in the article can be used in all popular distributions such as Ubuntu, Red Hat, Suse, Debian and others.
I hope you like this article. Please follow our Facebook page and Twitter handle to get latest updates.
Read More:
- RHEL Interview Questions and Answers
- How to Change Hostname of RHEL system?
- How to Install and Use Htop to Monitor Linux Processes?
- Install Debian 9 Stretch in Step by Step Process
- How to Use CAT Command on Linux System? - April 24, 2018
- How to Install Zabbix on Ubuntu Server 16.04? - March 29, 2018
- 11 Examples of ls Command to List Files in Linux - March 20, 2018
Leave a Comment