UNIX account database fields: In /etc/passwd (the classic UNIX user account file), what does the 7th field represent?

Difficulty: Easy

Correct Answer: shell

Explanation:


Introduction / Context:
The /etc/passwd file contains core details for user accounts on UNIX-like systems. Each record is colon-separated and historically included the hashed password (now typically shadowed). Administrators and developers should know what each field means to troubleshoot logins, shells, and user environments.



Given Data / Assumptions:

  • We are referring to the standard 7-field /etc/passwd format.
  • Fields are colon-separated: name:passwd:uid:gid:gecos:home:shell.
  • Modern systems often store the actual password hash in /etc/shadow.


Concept / Approach:

Count fields from left to right and map them to their roles. The 7th field is the user's login shell—such as /bin/bash, /bin/sh, /usr/sbin/nologin—defining the program invoked at login or when spawning an interactive session.



Step-by-Step Solution:

Field 1: login name (username).Field 2: password placeholder (often x or *), real hash in /etc/shadow.Field 3: user ID (UID).Field 4: group ID (GID).Field 5: GECOS/comment (full name or info).Field 6: home directory path.Field 7: login shell program.


Verification / Alternative check:

Use getent passwd username to view the entry. The last colon-separated field will show the shell path (for example, /bin/bash).



Why Other Options Are Wrong:

a: The password hash is not the 7th field and is usually in /etc/shadow.

b: The login (username) is the 1st field.

d: Home directory is the 6th field, not the 7th.

e: Not applicable because the 7th field is the shell.



Common Pitfalls:

Confusing home and shell positions; assuming the password is still stored in /etc/passwd rather than shadowed; overlooking accounts that use a non-interactive shell for service users.



Final Answer:

shell

More Questions from Unix

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion