Modify the UID and GID of the/etc/passwd and/etc/group files to 0, you can get root privileges, but not recommended ~
UID and GID
How does the Linux system differentiate between different users? It is natural to think that using different usernames should be a good idea, just as everyone in the real world has a name. But "user name" is just a handy human-readable string, which makes no sense to the machine. In fact, the Linux system uses a 32-bit integer to record and differentiate different users, which means that the system can record up to 4 billion different users. The number used to differentiate between different users is called the user ID, or UID. The corresponding relationship between user name and UID is automatically recorded. The users in the Linux system are divided into 3 categories, that is, ordinary users, root users, system users.
A normal user is a real user who uses a Linux system, and such users can log in to the system using their username and password. Linux has a very detailed set of permissions, so in general, ordinary users can only operate in their home directory, System temp directory, or other authorized directory, and manipulate files belonging to that user. Usually the UID of the average user is greater than 500 because the system default User ID is numbered starting with 500 when a normal user is added.
Root user is the root user, whose ID is 0, also known as Superuser, and the root account has full control over the system: You can modify, delete any file, run any command. The root user is also the most dangerous user in the system, and the root user can even delete all file systems while the system is functioning, causing irreparable disaster. So in general, use the root user to log on to the system with great care.
A system user is a user that a system must have at run time, but does not refer to the actual consumer. For example, when running Web services under Redhat or CentOS, the system user Apache is required to run the httpd process, while running the MySQL database service requires the use of the system user MySQL to run the mysqld process. Under Redhat or CentOS, the system user's ID range is 1~499. The example given below shows the process currently running on the system, and the first column is the user who is running the process.
[[email protected] ~] # ps aux
USER PID% CPU% MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 2072 632? Ss Oct18 0:00 init [3]
... (omitted content) ...
apache 7930 0.0 0.1 9944 2064? S 21:23 0:00 / usr / sbin / httpd
In addition to the user in the Linux system, there is the concept of "user group", different user groups are also used to distinguish between the numbers, this is used to distinguish between different user groups ID is called Group ID, also known as GID.
In the following example, when viewing a file using Ls-l, the third and fourth columns show that the owner of the file is the user root, all groups are root, and if the-n parameter is added, the third and fourth columns are displayed with UID and GID, respectively, 0 and 0.
- [[email protected] ~]# ls -l anaconda-ks.cfg
- -rw------- 1 root root 954 Oct 7 21:02 anaconda-ks.cfg
- [[email protected] ~]# ls -ln anaconda-ks.cfg
- -rw------- 1 0 0 954 Oct 7 21:02 anaconda-ks.cfg
So what's the connection between UID and GID? In fact, under Linux, each user belongs to at least one group. For example: Each student in the school use the number to mark, and each student belongs to a class, where the school number is equivalent to the UID, and the class is the equivalent of GID. Of course, each student may also participate in a number of interest classes, and each interest class is also a different group. That is, each student belongs to at least one group and can belong to more than one group at a time. The same is true under Linux. Since this is the case, how do you look at your uid and GID?
To confirm your UID, you can use the following ID command to obtain:
- [[email protected] ~]# id
- uid=0(root)gid=0(root)groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
To confirm the user group that you belong to, you can use the following groups command to obtain:
- [[email protected] ~]# groups
- root bin daemon sys adm disk wheel
If you want to query the current online user, you can use the command after the user logs in to see all users who are currently logged on to the system. The following example shows that there are currently 3 logins, where the user root logs on to the system from Tty1, pts/0, and user John Logs in from PTS/1.
- [email protected] ~]# who
- Root Tty1 2012-10-22 00:13
- Root pts/0 2012-10-22 21:20 (192.168.179.1)
- John Pts/1 2012-10-22 22:35 (192.168.179.1)
Ext.: http://book.51cto.com/art/201401/427710.htm
UID and GID for CentOS account