Parsing of user and user configuration files in Linux

Source: Internet
Author: User
Article Title: parsing user and user configuration files in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

In addition to creating user accounts like in Windows systems, some user accounts in Linux systems also exist after the system is installed, just like built-in accounts in Windows systems. If you want to know some Linux accounts, you can view the/etc/passwd file, as shown below.

Root: x: 0: 0: root:/bin/bash

Bin: x: 1: 1: bin:/sbin/nologin

Daemon: x: 2: 2: daemon:/sbin/nologin

Adm: x: 3: 4: adm:/var/adm:/sbin/nologin

Lp: x: 4: 7: lp:/var/spool/lpd:/sbin/nologin

Sync: x: 5: 0: sync:/sbin:/bin/sync

Shutdown: x: 6: 0: shutdown:/sbin/shutdown

Halt: x: 7: 0: halt:/sbin/halt

Mail: x: 8: 12: mail:/var/spool/mail:/sbin/nologin

News: x: 9: 13: news:/etc/news:

Uucp: x: 10: 14: uucp:/var/spool/uucp:/sbin/nologin

Operator: x: 11: 0: operator:/root:/sbin/nologin

Games: x: 12: 100: games:/usr/games:/sbin/nologin

Gopher: x: 13: 30: gopher:/var/gopher:/sbin/nologin

Ftp: x: 14: 50: FTP User:/var/ftp:/sbin/nologin

Nobody: x: 99: 99: Nobody: // sbin/nologin

Messages: x: 81: 81: System message bus: // sbin/nologin

Vcsa: x: 69: 69: virtual console memory owner:/dev:/sbin/nologin

Rpm: x: 37: 37:/var/lib/rpm:/sbin/nologin

Haldaemon: x: 68: 68: HAL daemon: // sbin/nologin

Netdump: x: 34: 34: Network Crash Dump user:/var/crash:/bin/bash

Nscd: x: 28: 28: NSCD Daemon: // sbin/nologin

Sshd: x: 74: 74: Privilege-separated SSH:/var/empty/sshd:/sbin/nologin

Rpc: x: 32: 32: Portmapper RPC user: // sbin/nologin

Rpcuser: x: 29: 29: RPC Service User:/var/lib/nfs:/sbin/nologin

Nfsnobody: x: 65534: 65534: Anonymous NFS User:/var/lib/nfs:/sbin/nologin

Mailnull: x: 47: 47:/var/spool/mqueue:/sbin/nologin

Smmsp: x: 51: 51:/var/spool/mqueue:/sbin/nologin

Pcap: x: 77: 77:/var/arpwatch:/sbin/nologin

Apache: x: 48: 48: Apache:/var/www:/sbin/nologin

Squid: x: 23: 23:/var/spool/squid:/sbin/nologin

Webalizer: x: 67: 67: Webalizer:/var/www/usage:/sbin/nologin

Xfs: x: 43: 43: X Font Server:/etc/X11/fs:/sbin/nologin

Ntp: x: 38: 38:/etc/ntp:/sbin/nologin

EM: x: 42: 42:/var/EM:/sbin/nologin

Htt: x: 100: 101: IIIMF Htt:/usr/lib/im:/sbin/nologin

Winda: x: 500: 500: wangda:/home/winda:/bin/bash

Cyrus: x: 76: 12: Cyrus IMAP Server:/var/lib/imap:/bin/bash

Named: x: 25: 25: Named:/var/named:/sbin/nologin

Pegasus: x: 66: 65: tog-pegasus OpenPegasus WBEM/CIM services:/var/lib/Pegasus:/sbin/nologin

Alice: x: 501: 501: Alicechen:/home/alice:/bin/bash

Exim: x: 93: 93:/var/spool/exim:/sbin/nologin

Postfix: x: 89: 89:/var/spool/postfix:/sbin/nologin

Mailman: x: 41: 41: GNU Mailing List Manager:/usr/lib/mailman:/sbin/nologin

Amanda: x: 33: 6: Amanda user:/var/lib/amanda:/bin/bash

There are two configuration files related to users:

/Etc/passwd: user configuration file;

/Etc/shadow: User shadow password file;

For details about the Password file, refer to the above content. Only the root account has the permission to modify it. This file contains the usernames of all users in the system and their related information. Each user account corresponds to a row in the file and is divided into seven parts by colon (;) ("Domain" in Linux). Each part is separated by colon. The format is as follows:

Account name: encrypted password: User ID: Group ID: account full name or description: logon Directory: logon shell

As listed above, the root user's behavior in this file:

Root: x: 0: 0: root:/bin/bash

It indicates that the root account has a password (indicated by x, but not by x ), the user ID and group ID are both "0" (the user ID and group ID of the built-in account are less than 500, and the user ID and group ID of the newly created account are both equal to or greater than 500). The full account name is root, the used logon shell has/bin/bash.

The/etc/passwd file is readable to all users of the system. The advantage is that every user can know which users are on the system, however, the disadvantage is that passwords of other users are vulnerable to attacks (especially when passwords are relatively simple ). Therefore, the shadow password format is used in Linux, such as red hats and red flags. the user's password is stored in another file/etc/shadow, Which is readable only by the root user, therefore, security is greatly improved. As follows:

Root: $1 $ qnvzih07 $ LKCr9gldeq1ajos5tuLPH.: 13670: 0: 99999: 7 :::

Bin: *: 13670: 0: 99999: 7 :::

Daemon: *: 13670: 0: 99999: 7 :::

Adm: *: 13670: 0: 99999: 7 :::

Lp: *: 13670: 0: 99999: 7 :::

Sync: *: 13670: 0: 99999: 7 :::

Shutdown: *: 13670: 0: 99999: 7 :::

Halt: *: 13670: 0: 99999: 7 :::

Mail: *: 13670: 0: 99999: 7 :::

News: *: 13670: 0: 99999: 7 :::

Uucp: *: 13670: 0: 99999: 7 :::

Operator: *: 13670: 0: 99999: 7 :::

Games: *: 13670: 0: 99999: 7 :::

Gopher: *: 13670: 0: 99999: 7 :::

Ftp: *: 13670: 0: 99999: 7 :::

Nobody: *: 13670: 0: 99999: 7 :::

Success :!! : 13670: 0: 99999: 7 :::

Vcsa :!! : 13670: 0: 99999: 7 :::

Rpm :!! : 13670: 0: 99999: 7 :::

Haldaemon :!! : 13670: 0: 99999: 7 :::

Netdump :!! : 13670: 0: 99999: 7 :::

Nscd :!! : 13670: 0: 99999: 7 :::

Sshd :!! : 13670: 0: 99999: 7 :::

Rpc :!! : 13670: 0: 99999: 7 :::

Rpcuser :!! : 13670: 0: 99999: 7 :::

Nfsnobody :!! : 13670: 0: 99999: 7 :::

Mailnull :!! : 13670: 0: 99999: 7 :::

Smmsp :!! : 13670: 0: 99999: 7 :::

Pcap :!! : 13670: 0: 99999: 7 :::

Apache :!! : 13670: 0: 99999: 7 :::

Squid :!! : 13670: 0: 99999: 7 :::

Webalizer :!! : 13670: 0: 99999: 7 :::

Xfs :!! : 13670: 0: 99999: 7 :::

Ntp :!! : 13670: 0: 99999: 7 :::

TPD :!! : 13670: 0: 99999: 7 :::

Htt :!! : 13670: 0: 99999: 7 :::

Winda: $1 $ EzhNNTg6 $ Zgh0TrLsnuAnWOdb2w1ut.: 13670: 0: 99999: 7 :::

Cyrus :!! : 13670 ::::::

Named :!! : 13670 ::::::

Pegasus :!! : 13670 ::::::

Alice: $1 $ vw2uWRMJ $ l20TPyj1M3L8x2uqUN/wn.: 13670: 0: 99999: 7 :::

Exim :!! : 13670 ::::::

Postfix :!! : 13670 ::::::

Mailman :!! : 13670 ::::::

Amanda :!! : 13670 ::::::

Similarly, in this file, each user corresponds to a row and is divided into nine parts by a colon ("Domain" in Linux "). The format of each row is as follows:

User Login Name

User's encrypted password (if it is blank, it indicates that the user can log on without a password. If it is *, it indicates that the account is disabled)

The number of days from January 1, January 1, 1970 to the last password Modification

How many days cannot the password be modified by the user?

The number of days after which the password must be modified (0 is not modified)

How many days after the password expires, the user account is forbidden

How many days does the password expire before it is issued to the user?

Password: the number of days banned on January 1, January 1, 1970

Reserved domain

Take the root account as an example. The code above is:

Root: $1 $ qnvzih07 $ LKCr9gldeq1ajos5tuLPH.: 13670: 0: 99999: 7 :::

According to the preceding format, the user login name is root and the encrypted password is $1 $ qnvzih07 $ LKCr9gldeq1ajos5tuLPH. "(because the password is encrypted, It is not displayed as a direct password.) The last time the password was changed from January 1, January 1, 1970 to 13670 days, the password cannot be modified, the password must be modified after 99999 days. The user account is forbidden 7 days after the password expires, and the subsequent three domains are not configured.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.