Introduction to the
When you open the /etc/passwd file on Linux with vim, you’ll see output similar to this.
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
......
Copy the code
For those of you who aren’t familiar with Linux, it might seem a little confusing at first, but if you look closely, you’ll notice that the output is separated by colons (:). The six colons divide each line of information into seven parts. Let’s take a look at what each part represents.
decomposition
root:x:0:0:root:/root:/bin/bash
Copy the code
- The root user name
- A placeholder for the x password. It’s just a marker. The real password is saved in /etc/shadow. When you look at x, you may have the mistake of associating x with x(execution) of file permissions. It’s actually just a symbol. On Ubuntu, the placeholder is x, but on the Mac, it actually becomes an asterisk *.
- 0 User ID. Each user has a unique user ID in the system. The ID of user root is 0.
- 0 Group ID. Each group has a unique group ID in the system. Each user is created with an initial group. The ID of the root group is 0.
- Root is used here to describe the primary responsibilities of the user
- The Home directory of the root user is /root, and the Home directory of other users is/Home/your username
- /bin/bash User command line, which displays the commands to be executed after the user logs in.
summary
Isn’t it easier to look back at the output once you understand what each part does?