How to add/delete users and user groups in Linux

  
 

This article summarizes some of the commands and parameters that are commonly used when Linux adds or removes users and user groups. 1, built users: adduser phpq //new phpq user passwd phpq //phpq user set password

2, build work group groupadd test //new test work group

3, new user At the same time increase the working group useradd -g test phpq //create a new phpq user and add to the test working group

Note: :-g belongs to the group -d home directory -s SHELL

4 Add the working group usermod -G groupname username

or :gpasswd -a user group

5 to the existing user, temporarily close: the line belonging to the user in the /etc/shadow file The second field (password) is preceded by *. To restore this user, remove *.

Or use the following command to close the user account: passwd peter –l

Re-release: passwd peter –u

6, permanently delete the user account userdel peter

groupdel peter

usermod –G peter peter (forces deletion of all files and subdirectories of the user's home directory and home directory)

7. Delete user edits from the group /etc/group Find the row of GROUP1, delete A or use the command gpasswd -d A GROUP

8, display user information id usercat /etc/passwd

More detailed users and user groups Explain the Linux user and user group in detail. This article mainly describes the concept of user (user) and user group (group) management in Linux system; the list of user (user) and user group (group) related commands; Single-user multi-tasking, multi-user multi-tasking is also done to explain.

This article is from PHP
Information original link: http://www.phpq.net/linux/linux-add-delete-user-group.html


Linux user (user) and user group (group) management overview


, understand Linux single-user multi-tasking, multi-user multi-tasking concept; Linux is a Multi-user, multi-tasking operating system
; we should understand the concept of single-user multi-tasking and multi-user multi-tasking;

1, single-user multitasking for Linux; single-user multitasking; For example, if we log in to the system with beinan, after entering the system, I want to open gedit to write the document, but in the process of writing the document, I feel less music, so I open xmms to order music; of course, listening to music is not enough, MSN also I have to open it, I want to know what several brothers are doing now. In this way, when I log in with beinan users, I have executed gedit, xmms, msn, etc., of course, the input method fcitx; this is a bit simple, a beinan The user, in order to complete the work, performed several tasks; of course, the beinan user, other people can still go far When you log in, you can do other work.

2, multi-user, multi-tasking of Linux;

Sometimes it may be that many users use the same system at the same time, but not all users must do the same thing, so this There are multi-user multi-tasking;

For example, LinuxSir.Org server with FTP users, system administrators, web users, regular users, etc. At the same time, there may be brothers Visiting the forum; some may be uploading package management sub-sites, such as luma or Yuking brothers managing their home page system and FTP; at the same time, there may be system administrators maintaining the system; browsing the home page It is the nobody user, everyone uses the same one, and the uploading package uses the FTP user; the administrator's maintenance or viewing of the system may use a normal account or a super-privileged root account; different users have different permissions. Different users are required to complete different tasks. It can also be said that different users may not be able to do the same work;

It is worth noting that multi-user multi-tasking is not crowded at the same time. Connected to the keyboard and display of a machine to operate the machine, multiple users may be through remote login, such as remote control of the server, as long as there is user rights, anyone can operate or access;

3, the role of the user is differentiated;

The user is divided into roles in the system. In the Linux system, the permissions and tasks are different due to different roles; it is worth noting that the role of the user is Through UID and identification, especially UID; in system management, system administrators must adhere to the unique features of UID;

root user: system unique, real, can log in to the system, can operate any system Files and commands, with the highest authority; virtual users: These users are also called pseudo-users or fake users, which are distinguished from real users. Such users do not have the ability to log in to the system, but they are indispensable for system operation. Users, such as bin, daemon, adm, ftp, mail, etc.; such users are owned by the system itself, not added later, of course, we can also add virtual users; User: This type of user can log in to the system, but can only operate the contents of his home directory; permissions are limited; such users are added by the system administrator;

4, multi-user operating system security; Br>

Multi-user systems are more convenient for system management in fact. From a security perspective, a multi-user managed system is more secure. For example, a file under a beinan user does not want other users to see it. It is only a file permission. Only beinan can read and edit it. In this way, only one user of beinan can operate on its private files. Linux performs best under multiple users. Linux can protect the security of each user well, but we also have to learn Linux, and then secure the system. Such systems are not secure without security-conscious administrators or management techniques.

From the perspective of the server, the system security under multi-user is also the most important. The commonly used Windows
operating system, its ability to manage the spinning rights can only be said to be In general, there is no way to compare with Linux or Unix-like systems;

second, user (user) and user group (group) concepts; 1, user (user) concept; through the front of Linux With the understanding of multiple users, we understand that Linux is a truly multi-user operating system, so we can build several users in the Linux system. For example, our colleague wants to use my computer, but I don't want him to log in with my username, because my user name has information and information (that is, private content) that I don't want others to see. Then I can give it. He built a new username, let him use the username I opened to toss, which is in line with the operational rules from the perspective of computer security;

Of course, the concept of user (user) is not only understood Here, there are some users in the Linux system to complete specific tasks, such as nobody and ftp, etc., we access the LinuxSir.Org web application, which is the nobody user; when we anonymously access ftp, we will use the user ftp or Nobody ; If you want to know some accounts of Linux system, please check /etc/passwd ;

2, the concept of user group; group is the user with the same characteristics (user) Aggregate; for example, sometimes we want to have multiple users with the same permissions, such as viewing, modifying a file or executing a command, then we need a user group, we define the user to the same user group By modifying the permissions of the file or directory, the user group has certain operational permissions, so that the user under the user group has the same permissions to the file or directory, which is achieved by defining the group and modifying the file permissions;

Example: In order to let some users have permission to view a document, such as a timetable, and the person who writes the timetable must have read and write execution rights, we want some users to know the timetable. Content, not let them modify, so we can put these users into a group, and then modify the permissions of this file, so that the user group can be read, so that each user under the user group is readable; user and The correspondence of user groups is: one-to-one, many-to-one, one-to-many or many-to-many; one-to-one: a user can be the only member of a group; many-to-one: multiple users can be some The members of the unique group are not attributed to other user groups; for example, beinan and linuxsir are only attributed to the beinan user group; one-to-many: a user can be a member of multiple user groups; For example, beinan can be a member of the root group, a member of the linuxsir user group, or a member of the adm user group; many-to-many: multiple users correspond to multiple user groups, and several users can belong to the same group; The relationship between many is the extension of the first three; understanding the above three, this can also be understood;

Copyright © Windows knowledge All Rights Reserved