linux modify user

linux modify user

Linux provides a number of different tools to modify existing user account information.

command description
usermod Modify user accounts fields, you can also specify the relationship between the main group and belongs to the group of additional
passwd Modify existing user's password
chpasswd Reads the login password from the file and update passwords
chage Change the password expiration date
chfn Remarks modify user account information
chsh Modify the default user account login shell
usermod

usermod command to modify user account is the most powerful tool a. It can be used to modify / etc / passwd file in most of the fields, simply use the command as the field you want to modify the corresponding line parameters on it. Most of the parameters with the same parameters useradd command (for example, -c modified memo field, -e modify the expiration date, -g modify the default login group). In addition, there are other options might come in handy.

  • -l modify the login name of the user account.

  • -L locked account, so that users can not log on.

  • -p modify the password for the account.

  • -U Unlock that enables users to log on.

-L option is particularly useful. It can lock the account so that users can not log on, but without deleting user accounts and data.

Let the account back to normal, as long as the -U option on the line.

passwd and chpasswd

An easy way to change the user's password is to use the passwd command.

If only the passwd command, it will change your own password. Any user on the system can change their own passwords, but only the root user has permission to change someone else's password.

-e option can force the user to change the password the next time you log. You can give the user to set a simple password, and then later forced into more complex passwords that they can remember the next time you log in.

If you need to change the password for the system in a large number of users, chpasswd command can do more with less. chpasswd command automatically read from the standard input the login name and password (separated by a colon) list, to password encryption, and then set up the account for the user. You can also use the redirect command containing userid: passwd file to redirect to the command.

chsh 、 chfn 和 chage

chsh, chfn and chage tool specifically designed to modify specific account information. chsh command, you can quickly modify the default user login shell. It must be the full path name of the shell parameters of use, not only the name of the shell.

chfn command provides a standard method for storing information in a memo field / etc / passwd file. Chfn command information for Unix finger command will deposit into a memo field, rather than simply random text into a number (such as a name or nickname of the class), or the memo field blank. finger command can easily view the user information on the Linux system.

[root@localhost ~]# finger rich
Login: rich Name: Rich Blum
Directory: /home/rich Shell: /bin/bash
On since Thu Sep 20 18:03 (EDT) on pts/0 from 192.168.1.2
No mail.
No Plan.
说明 出于安全性考虑,很多Linux系统管理员会在系统上禁用 finger 命令,不少Linux发行版甚至都没有默认安装该命令。
Published 233 original articles · won praise 189 · views 390 000 +

Guess you like

Origin blog.csdn.net/sinat_32366329/article/details/104081946