Linux study notes - forgot the first few days: simple user management commands

Today, let's record a simple user management command

1 Add user command: useradd

Adding a user is a command that only root has authority. To add a user, just add useradd and add the user name.

When the user you add has not been added, there will be no prompt after the execution is completed, but at this time your user has been added successfully. If the added user already exists, the system will give you a prompt that the user already exists. However, it should be known that the user at this time has not set a password, but only set some basic information of the user. To set a password, you need to use a new command, passwd

2 Set and modify the password: passwd

Format: passwd plus username

The only people who can change the password are the user and root, and root can change anyone's password.

I used root to modify this time. You can see that after executing passwd hj, the system will ask you to enter the password. I entered 123 at this time. After the system detects the password, it will prompt that the password is too short and too simple. But it still let me continue to enter, the second input is not to re-select a new password, but to repeat the last password. Because I am root, I have a lot of authority, and I can change it as I want. However, if the user changes the password by himself, such a password is not allowed. When changing the password by yourself, the password must conform to the password principles, otherwise the change will fail. . Although the root password can be changed without abiding by the password rules, it is still recommended that you must follow the password principles when setting the password, and set a password with high security.

3 View connected users: who

The who command can view the current connected users

As you can see, the first column is the login user name, the second column is the login emmmmmmm, that is, tty is logged in on your linux machine, and pts is remote login. The third column is the login time, and the address in parentheses is the login address.

4 View linked user's: w

Similar to the function of the who command, but the w command displays slightly more things

As you can see, the w command displays more things than who. The yellow part, the first one is the current time, up 5:09 is the system running time, mine has been running for 5 hours and 9 minutes, you can judge the stability of a server by this, for example, my server has been running for a period of time. It's been a year, and the machine has not been turned off yet, which shows that the stability of this server is still very good. 4users is how many people are currently logged in, I am four people. The last load average is the load of the system in the past 1 minute, 5 minutes and 15 minutes. I have no load, of course it's all 0. I don't know how much is a high load . It seems that if it is 1, it is a high load.

Looking down, USER TTY FROM LOGIN@ needless to say, you can see it at a glance. The IDLE is the idle time of the account. Since you do not operate, the system will start to count your idle time. 0.00s means that you have just performed an operation. But what is the operation? Look at the WHAT in the last column, such as the second root, his IDLE is 0.00s, which means that it has just performed an operation, and the content of the operation is the w command (that is, the one in the last column, bash means no operation ), how much CPU time does this command take? It is the PCPU in the penultimate column. As shown in the above figure, it takes 0.05 seconds for the root to execute the w command. After the root logs in, the total time spent on the CPU is the JCPU, and the root is 0.19 seconds. Is it a bit messy to say this? Forget it, let me make a table.

USER login username
TTY Connection method: tty represents a local connection, that is, a connection on the machine where the system is located, and pts is a remote connection
FROM The logged-in ip, if not displayed, is a local connection
LOGIN@ login time
IDLE idle time, i.e. how long you haven't done anything
JCPU After the account is logged in, how much time does the CPU take up?
PCPU How much CPU time is occupied by the user's operation
WHAT user action

It should be clear by now. emmmmmmmmmmm, there seems to be nothing else to say, so be it

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326995327&siteId=291194637