Account management

Essential Linux User and Group Management

/etc/passwd

This file contains user account information. Each entry follows this format:

<login>:<password>:<UID>:<GID>:<info>:<homedir>:<shell>
  • <login> – Username

  • <password> – Usually an 'x' (password stored in /etc/shadow)

  • <UID> – User ID

  • <GID> – Group ID

  • <info> – Optional user description

  • <homedir> – Home directory

  • <shell> – Default shell

/etc/group

Defines group memberships with the following format:

<group>:<password>:<GID>:<users>
  • <group> – Group name

  • <password> – Usually an 'x' (password stored in /etc/gshadow)

  • <GID> – Group ID

  • <users> – List of users in the group

/etc/shadow

When performing penetration testing, gaining write access to /etc/shadow is highly valuable, as it allows direct modification of user or service passwords. This circumvents brute-force or dictionary attacks. This file contains user passwords information:

  • <user/service> – Username or system service

  • <$type$salt$hash> – Hashed password with type and salt

  • <last change> – Days since the last password change (since epoch)

  • <min> – Minimum days before changing the password

  • <max> – Maximum days before password expiry

  • <warn> – Days before expiry to warn the user

  • <inactive> – Days after expiry before account deactivation

  • <expire> – Absolute expiration date (days since epoch)

  • <unused> – Reserved for future use

There are some specific commands to generate password hashes for this file.

User Management Commands

Adding Users

An alternative way to add a user interactively:

In Linux, a system account is typically used for running system services rather than for interactive login. These accounts usually have a UID (User ID) below 1000 and are restricted from direct login.

List users

Group Management Commands

Add new group

Add sudo privilege to a group

Last updated