Are you starting to use the Linux terminal? If so, know linux commands id, last, who, groupadd, useradd and userdel is essential.
Of course, the first step to using them correctly is to understand what each one is for. It does not matter if you are already managing a system in companies, schools or businesses. Or if you just want to learn a little Linux OS programming.
Here you will understand what it is about and when it is appropriate to use each argument. By placing the specific syntax you should not have any problem. You will go from seeing the IDs or identification number to managing groups and more.
What are Linux user commands and what are they for?
Basically the command
user only works for view users who are connected or logged in to the system. This in case no additional option is added. So each one can be traced. Functionality that can even alert us to dangers within the system. However, there are user comands for enumeration, deletion, or addition more complete. All of these are intended to facilitate management by the superuser. Fundamentally in relation to user and group planning.
Learn how to use the commands “go”, “last”, “quien”, “groupadd”, “useradd”, “userdel”
Now you must go further and learn step by step how to use them while in the terminal.
Of course, before each syntax it is good that you see its exact meaning:
With the command
id we will have the specific command to see the current and real identifier number.
This is the case for both a user and a group:
- To access this command you must put the id in the end with the name of the current user
In the end it should be something like this example
- Remember that you have more options, for example, add to it
-gin order to view effective group ID or
-Gin order to see all IDs. -N also works to get group or user name instead of ID.
- Of course, for the latter you must specify if it is -u (user) -g (group) or -G (groups) The same happens with the id -r argument, it helps you to show the real ID of the group or users and not the cash.
On the same line of ideas, the argument last allows us many variations.
But, its main reason is to list accesses to the system, exits, machine restarts, dates and times:
- Insert on the console the argument last
- So it will only show you the last thing in the user list.
- By adding
-nfollowed by a number you will be indicating how many lines to show. The syntax will be like this
last -n.On the other hand, if you place
-Rit won’t show you the hostname field. While with
-awill specify the hostname in the last column.
- You can also write last followed by -x. In this way, you will see what is registered in the list of users together with the shutdown entries and the modifications in the execution list.
As we know Linux is a multi-user OS. Thus, the who command indicates all users who are authenticated within the system at the time. Through this you can determine the name of the active users, login time, machine name, terminal line and more.
To activate the argument write
whofollowed by the corresponding option
-Hso that it is printed to the terminal as a columnar format
-uto have on the list to users with access to the system.
One of the commands you can only run the superuser or administrator is groupadd. This is because it is intended to create a new group account.
For this to work you must follow the steps that you will see below:
- Precedes if necessary as sudo
- And then place the name of the group
In the end you should have a Outcome similar to this:
Keep in mind you can use options preceded to the name of the group. For example, -g it is the numeric value of the group identifier. That is, a specific and unique value. While, the flag -r serves in Linux Redhat to order the account to be added to the system.
This argumentation allows us add a new user using the Linux console. You have to bear in mind that in some versions of the OS it is used adduser. Also, you must remember that this action often requires administrator permission.
You can use the sudo (super user does) argument in front of it if necessary:
- While in the console we write
useraddand then we enter the name of the new user
- So, you should have a result similar to this:
Contrary to useradd, userdel has been formulated to remove users from the terminal.
Knowing this we follow the procedure:
- We start with
- Along with this we add the username to delete
- And then we immediately specify the name of the group where you are
- So if we want to eliminate Juan of the group counters we do the following set of commands:
userdel juan contadores.
If you have any questions, leave them in the comments, we will answer you as soon as possible, and it will also be of great help to more members of the community. Thanks! 😉