/etc/passwd in Ubuntu

With the help of /etc/passwd file, we can easily check for all the users registered on our machine. We have already covered how to add a user here. /etc/passwd file would reflect relevant entries once user creation part is done. For every user account hence created, there is a corresponding single-line entry in /etc/passwd file.

And, a single-line entry is further divided in seven fields which are separated by :(colons). These seven fields are about –

  1. Login name,
  2. Encrypted password (optional),
  3. User ID,
  4. Group ID,
  5. Full user name or Comments,
  6. User’s home directory,
  7. Default login shell.

/etc/passwd file in Ubuntu

To view contents of /etc/passwd file, use cat command-line utility –

cat /etc/passwd

We just take a sample entry as the output –

techPiezo:x:1001:1002:techPiezo test account:/home/techpiezo:/bin/bash

The first field – techPiezo, shows us the login name.

Next field is for the password, an ‘x‘ here shows that the user has the encrypted password which is stored in shadow (/etc/shadow) file. But, if its just blank then it shows the user can be authenticated without a password, which itself is a red flag. If you’re a System administrator then, just ensure that every user is allowed to access the system only after providing the password. We strongly recommend never to leave password field blank unless there is proper justification of doing so.

Third and fourth fields (1001:1002) are about User IDs and Group IDs.

Then comes, Full user name or comments field (techPiezo test account). Here, we have the option to provide either a user’s full name or some comment which help us identify the user.

Thereafter, its the user’s home directory (/home/techpiezo). If you have gone through add a user article. In case, if we don’t provide default home directory of a user then Ubuntu automatically sets it for us. But, if we want a specific directory to be user’s home directory then, we can do that. So, this shows us the default home directory of a user.

Lastly, the default login shell (/bin/bash). If no value is provided while adding a user then, defaults values are set.

In conclusion, we have covered here /etc/passwd file in Ubuntu.

Similar Posts