Brief description of the Linux and Unix / etc / passwd file

There are many authentication schemes that can be used on Linux systems. The most widely used standard scheme for file validation is /etc/passwd And the /etc/shadow.

The / etc / passwd file is a text database that contains information for all accounts on the system. Owned by root and has permissions 644. Files can only be modified with root or user with permissions sudo It can be read by all system users.

Manually modifying the / etc / passwd file (direct editing with vim or nano text editor) should be avoided unless you know what you’re doing. Always use commands designed for this purpose. For example, to modify a user account, use the command usermod, To change a user’s password using the command passwd And to add a new user account, use the command useradd.

Format in the / etc / passwd file

Files /etc/passwd It is a text file that contains one entry per line, representing user accounts. To view the contents of the file, use a text editor or a command cat:

cat /etc/passwd

Typically, the first line describes the root user, followed by the system and regular user accounts. New entries are added at the end of the file.

Every line of files /etc/passwd It contains seven fields separated by commas:

[--] - [--] [--] [-----] [--------] [--------]
|    |   |    |     |         |        |
|    |   |    |     |         |        +-> 7. Login shell
|    |   |    |     |         +----------> 6. Direktori Home
|    |   |    |     +--------------------> 5. GECOS
|    |   |    +--------------------------> 4. GID
|    |   +-------------------------------> 3. UID
|    +-----------------------------------> 2. Password
+----------------------------------------> 1. Username
  1. user name. The string that you write when logging into the system. Each username must have a unique string on the device. Username maximum length is 32 characters.
  2. password. On older Linux systems, user passwords were encrypted and stored in a file /etc/passwd. This field is set on most modern systems x, And the user’s password is stored in a file /etc/shadow.
  3. UID. User ID is a number assigned to each user. This is used by the operating system to distinguish between one user and another.
  4. GID. The group ID or group ID number refers to the primary group of users. When a user creates a file, the file group is assigned to that group. Usually, the group name is the same as the username. Secondary groups of users are listed in the file /etc/groups.
  5. GECOS Or the full name of the user. This field contains a comma-separated list of values ​​with the following information:
    • Full username or app name.
    • room number.
    • Office phone number.
    • landline number.
    • Other contact information.
  6. Guide Homepage. The absolute path to the home directory. Contains user and configuration files. By default, a user’s home directory is named after the user’s account name and is created within the directory /home.
  7. Login shell. The absolute path of a user’s login shell. This is a shell that starts when the user logs into the system. On most Linux distributions, the default login cover is Bash.
See also  How to Install Anbox on Manjaro


Files /etc/passwd Keep track of all users on the system. Avoid changing this file manually, as just one letter can cause problems with the user account.


Source link

Originally posted 2020-11-17 06:59:03.

About wahyuway

Check Also

How To Deploy Droplet on DigitalOcean With Terraform

Hello good people. In today’s blog post we will be showing you how to create …

Leave a Reply