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

How linux views all users and user groups

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces linux how to view all users and user groups, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

1. Check all users in linux

(1) in the terminal. In fact, all you need to do is look at the / etc/passwd file.

(2) look at the third parameter: more than 500, it is the user built later. Others are users of the system.

Or use cat / etc/passwd | cut-f 1-d:

2. User management commands

Useradd Note: add user

Adduser Note: add user

Passwd Note: set the password for the user

Usermod Note: modify user commands, you can use usermod to modify login, user's home directory, and so on.

Pwcov Note: synchronize users from / etc/passwd to / etc/shadow

Pwck Note: pwck verifies whether the contents of the user profile / etc/passwd and / etc/shadow files are legal or complete

Pwunconv Note: it is a vertical reverse operation of pwcov, which creates / etc/passwd from / etc/shadow and / etc/passwd, and then deletes the / etc/shadow file

Finger Note: view user Information tool

Id Note: check the user's UID, GID and the user group to which they belong

Chfn Note: change user Information tool

Su Note: user switching tool

Sudo Note: sudo executes commands (execute a command as another user) through another user, su is used to switch users, and then completes the corresponding tasks by switching to users, but sudo can directly execute commands later, for example, sudo does not need root password to execute root assigned execution, only root can execute corresponding commands; but it has to be edited / etc/sudoers through visudo.

Visudo Note: visodo is the command for editing / etc/sudoers; you can also use vi to edit / etc/sudoers directly without this command.

Sudoedit Note: similar to sudo function

3. Tools or commands for managing user groups (group)

Groupadd Note: add a user group

Groupdel note: delete a user group

Groupmod Note: modify user group information

Groups note: displays the user group to which the user belongs

Grpck

Grpconv Note: synchronize or create / etc/gshadow through the file contents of / etc/group and / etc/gshadow, or create / etc/gshadow if / etc/gshadow does not exist

Grpunconv Note: synchronize or create / etc/group with the contents of / etc/group and / etc/gshadow files, and then delete the gshadow file

First create the home directory of the user groups test and FTP

The code is as follows:

Groupadd test

Mkdir / tmp/test

Then create a user

The code is as follows:

Useradd-G test-d / tmp/test-M usr1

Note: G: the group in which the user belongs d: the location where the user's own directory is created is specified.

M: do not set up a default home directory, that is to say, you do not have your own directory under / home

The code is as follows:

Useradd-G test-d / tmp/test-M usr2

[code]

Then change the owner and permissions of the folder

Chown usr1.test / tmp/test-this means that the owner of / tmp/test is usr1

Chmod 750s / tmp/test-7 means wrx 5 means rx 0 means nothing.

The purpose of this experiment is that usr1 has permission to upload, delete and download.

Usr2 only has the permission to download, not the permission to upload or delete.

Of course, don't forget our main configuration file vsftpd.conf.

Change or add a user password

Take user name as an example, add user: useradd name, set password: passwd name, and then enter the password twice as prompted.

Delete user: userdel name, in fact, it is not completely deleted, but the user can not log in, and the files in its directory are still retained.

Such as:

[code]

Useradd username

Passwd username

Userdel username

Thank you for reading this article carefully. I hope the article "how to view all users and user groups in linux" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and follow the industry information channel. More related knowledge is waiting for you to learn!

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: 271

*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

Development

Wechat

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

12
Report