Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the relevant commands of users in Linux?

2025-02-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "what are the relevant commands of users in Linux". In daily operation, I believe that many people have doubts about the relevant commands of users in Linux. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts of "what are the relevant commands of users in Linux?" Next, please follow the editor to study!

Linux user Management

1) View current user whoami # # View current user

2) user's View id # # View specified user's id information id-u # # View user's uid-g # # View user's gid-G # # View user's id-n # display names instead of id numbers for all groups to which the user belongs

User switching su-user name su-indicates that the current user's environment su is switched at the same time when the user identity is switched. During execution, no password is required for the senior user to switch to the low-level user, while the low-level user switches to the advanced need, and the level user switching also needs to be noted: after each su switch to another user operation, you must exit, and then switch to the storage mode of other users in the system again.

Management of users and groups in Linux system / etc/passwd user information file user name: password: uid:gid: description: home directory: default shell

/ etc/group user group information filegroup name: group password: group id: group member / etc/shadow authentication information file user name; user password; time when the user password was last changed; minimum password validity; maximum password validity; password warning period

Password inactive period; password expiration date; user-defined location. Currently, shell is not enabled / etc/skel/.* is enabled by default, and the user's bone file

/ home/username user's home directory

User Management Command #

1) Linux delete user userdel student # # delete user but not delete user profile userdel-r student # # delete user and delete user profile 2) Linux user establishes watch-n 1 'tail-n 3 / etc/passwd / etc/group Ls-l / home' useradd # # when establishing a user, read / etc/login.defs useradd-u 8888 westos # # specify user uid useradd-g 21 westos # # specify user initial group id, "21 user group must exist" useradd-G 21 westos # # specify user additional group id "21 user group must be an existing" uesradd-c "dasd" westos # # specify user description useradd-d / home/tong westos # # specify user's home directory useradd-s / bin/sh westos # # specify user's default shell groupadd # # establish group groupadd-g # # specify group id goupdel # # delete group

How to use userdel

3) change the user information usermod usermod-l new name westos # # change the user's name usermod-u 6666 westos # # change the user's uid usermod-g 21 westos # # change the user's initial group usermod-G 72 westos # # add the user's additional group

Usermod-G "" westos # # Delete all user additional groups usermod-aG 21 westos # # add user additional group usermod-c "HAHAH" westos # # specify user description usermod-d / home/tong westos # # change user directory pointing to usermod-md / home/tong westos # # change user directory usermod-s / bin/sh westos # # change user shell usermod-L westos # # freeze user usermod-U westos # # unlock user

User authentication information

Use passwd to modify user password / etc/shadow # # authentication information file this file has a total of nine columns of user name; user password; passwd student # # change password passwd-l student # # add "!!" before the user password Passwd-u student # # remove "!" before the user's password Passwd-d student # # clear password

Usermod-L student # # add "!" before the user's password Usermod-U student # # remove "!" before the password

Chage to modify the user

Note: when the average user changes the password 1. You must know the current permanent original password 2. The password cannot be similar to the account name 3. Passwords cannot be pure numbers or pure letters 4. The password cannot be an ordered combination of letters and numbers when the user's password was last changed; passwd-e westos # # will change the last time the user changed the password to 0 # # the user forced to change the password when logging in chage-d 0 # # two command functions similar to the minimum password validity

Passwd-n 1 westos # # westos users cannot change the password within 1 day chage-M1 westos password has a maximum validity period; passwd-x 30 westos # # sets the westos password must change password within 30 days chage-M 30 westos password warning period; passwd-w 2 westos # # password output chage-W2 two days before password expiration

Password inactive period; number of days after passwd-I 1 westos # # password expires chage-I 1 westos password expiration date; chage-E 2018-11-11 westos # # westos users will be frozen user-defined locations on 2018-11-11, which is not currently enabled

User authorization

User Authorization profile / etc/sudoers/ Authorization configuration Command visudo specification operation file about 100 lines

Normal user host name = (convert to new user identity) command 1, command 2. Normal user hostname = (convert to new user identity) NOPASSWD: command

Example: westos hostname = (root) / usr/sbin/useradd # # password to execute command westos hostname = (root) NOPASSWD: / usr/sbin/usradd # # secret-free execution command

At this point, the study of "what are the relevant commands of users in Linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report