3. Usermod user modification tool (extremely powerful)
usermod can not only change the user's SHELL type, but also the user group they belong to, but also the validity period of the user's password, and the login name. usermod It seems that it can achieve large-scale transfer of user accounts; for example, I changed user A to new user B;
usermod [-u uid [-o]] [-g group] [-G group,...]
[-d Home Directory [-m]] [-s shell] [-c Comment] [-l New Name]
[-f Expiration date] [-e Expiration date] [-p Password] [-L|-U] User name
The usermod command will modify the system account file according to the part specified on your command column. The following are the parameters that can be used for usermod.
-c comment
To update the annotation column in the password file of the user account, it is generally modified by chfn(1).
-d home_dir
Update the user's new login directory. If the -m option is given, the user's old directory will be moved to the new directory. If the old directory does not exist, a new one will be created.
-e expire_date plus the user account stop date. The date format is MM/DD/YY.
-f inactive_days Permanent suspension of rights after the account expires a few days after it expires. When the value is 0, the account will be suspended immediately. When the value is -1, this function is turned off. The default value is -1.
-g initial_group Update the user's new initial login user group. The user group name must already exist. The user group ID must refer to the existing user group. The user group ID preset value is 1.
-G group,[...] Define the user as a member of a bunch of groups. Each user group uses the "," grid, and cannot be mixed with blank characters. The user group name is the same as the -g option. If the user's current user group no longer has this column, the user is removed from the user group.
-l login_name The name when changing the user's login is login_name. Others remain unchanged. In particular, the user directory name should also be changed into a new login name.
-s shell Specify the new login shell. If you leave blank space in this column, the system will use the system preset shell.
-u uid user ID value. Must be a unique ID value unless the -o option is used. The number cannot be negative. The default setting must not be less than the UID_MIN value defined in /etc/. The value between 0 and UID_MIN is traditionally reserved for use by the system account. The userID of all archive directories under the user directory tree will be automatically changed. Files placed outside the user directory must be manually changed.
Warning: usermod does not allow you to change the name of the user account online. When usermod is used to change userID, it must be confirmed that the user does not execute any programs on the computer. You need to manually change the user's crontab file. You also need to manually change the user's at work file. To use NISserver, the relevant NIS settings must be changed on the server.
To give a simple example, we mentioned the tool about useradd before, and the parameters of usermod tool and useradd are similar; the difference between the two is that useradd is added and usermod is modification;
[root@localhost ~]# usermod -d /opt/linuxfish -m -l fishlinux -U linuxfish
Note: Change the linuxfish username to fishlinux, and transfer its home directory to /opt/linuxfish;
[root@localhost ~]# ls -la /opt/linuxfish/ Note: Check the files and owners of the user fishlinux’s home directory;
Total dosage 48
drwxr-xr-x 3 fishlinux linuxfish 4096 November 5 16:46 .
drwxrwxrwx 29 root root 4096 November 5 16:48 ..
-rw-r--r-- 1 fishlinuxlinuxfish 24 November 5 16:46 .bash_logout
-rw-r--r-- 1 fishlinuxlinuxfish 191 November 5 16:46 .bash_profile
-rw-r--r-- 1 fishlinux linuxfish 124 November 5 16:46 .bashrc
-rw-r--r-- 1 fishlinux linuxfish 5619 November 5 16:46 .canna
-rw-r--r-- 1 fishlinuxlinuxfish 438 November 5 16:46.emacs
-rw-r--r-- 1 fishlinuxlinuxfish 120 November 5 16:46 .gtkrc
drwxr-xr-x 3 fishlinux linuxfish 4096 November 5 16:46 .kde
-rw-r--r-- 1 fishlinuxlinuxfish 0 November 5 16:46
-rw-r--r-- 1 fishlinuxlinuxfish 658 November 5 16:46.zshrc
[root@localhost ~]# more /etc/passwd |grep fishlinux Note: View records about fishlinux;
fishlinux:x:512:512::/opt/linuxfish:/bin/bash
Through the above example, we found that the user group of the file has not changed yet. If you want to change to a fishlinux user group, if you want to use usermod to modify, you must first add the fishlinux user group; then use usermod-g to modify, or you can use chown -R fishlinux:fishlinux/opt/finshlinux to modify;
Warning: It is best not to use usermod to change the user's password, because it displays a clear password in /etc/shadow; it is best to use passwd to modify the user's password;
[root@localhost ~]# usermod -p 123456 fishlinux Note: The password for modifying fishlinux is 123456;
[root@localhost ~]# more /etc/shadow |grep fishlinux Note: Query the fishlinux password in the /etc/shadow file; we see that it is obviously not encrypted;
fishlinux:123456:13092:0:99999:7:::
4. Userinfo graphic interface modification tool;
userinfo The system can be called by ordinary users, but they all modify the current operation user; it’s better to click the mouse to complete it, and click a few more times and it’s OK.
[root@localhost ~]# userinfo
Previous page12Read the full text