• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

Understanding the /etc/passwd File Format

Written by Admin, Updated On August 15, 2020
terminal
etc-passwd-file

The /etc/passwd is a text-based based database that stores the user account information. /etc/passwd file can be modified by root or users with sudo privileges and can be read by all the system users. It is owned by root and has 644 permissions and commonly used for user authentication.

It’s recommended to use the usermod command to modify the user account and useradd command to add new user account. Avoid the modification of the /etc/passwd file by hand.

/etc/passwd Format#

The /etc/passwd file contains one entry per line for each user. All the fields are separated by colon (:) symbol and total seven fields per line. Use the cat command to view the content of /etc/passwd file.

cat /etc/passwd
kunj:x:1000:1000:Kunj,,,:/home/kunj:/bin/bash
[--] - [--] [--] [-----] [--------] [--------]
|    |   |    |     |         |        |
|    |   |    |     |         |        +-> 7. Login shell
|    |   |    |     |         +----------> 6. Home directory
|    |   |    |     +--------------------> 5. GECOS
|    |   |    +--------------------------> 4. GID
|    |   +-------------------------------> 3. UID
|    +-----------------------------------> 2. Password
+----------------------------------------> 1. Username
  • Username – It’s a unique name used to login on system. The maximum length of the username is restricted to 32 characters.
  • Password – The value x indicates that the user’s password is encrypted and stored in /etc/shadow file.
  • UID – The system provide a unique id to each user which is used by system to identify the user.
  • GID – GID is user’s group identifier number, referring to the user’s primary group. When a user creates a file, the file’s group is set to this group. Typically, the name of the group is the same as the name of the user.
  • GECOS – This fields contains the additional information about the user such as full name, phone number, etc.
  • Home directory – The absolute path to the directory the user will be in when they log in.
  • Login shell – It’s absolute path to the user’s login shell. This is the shell that is started when the user logs into the system. Bash is the default login shell in most of Linux distribution.

Conclusion#

This article explained the information about the /etc/passwd file. The /etc/passwd file contains the information about the system users.

If you have any questions or feedback, feel free to leave a comment.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Install CouchDB on Ubuntu 20.04
Next Article   How to Install MongoDB on Ubuntu 20.04

Related Posts

  • How to Use sed to Find and Replace String in Files

    How to Use sed to Find and Replace String in Files

    December 18, 2020
  • Linux Head Command

    Linux Head Command

    December 16, 2020
  • Rename Files and Directories in Linux

    How to Rename Files and Directories in Linux

    December 15, 2020

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook