03. Important files

As a system admin, you'll be dealing with a number of important files.

/etc/sudoers

When performing root-level tasks, you may do so in three different ways:

  1. Login the host as root when you ssh.
  2. Use the su command to login as root user.
  3. Use the sudo command, which allows you to input a single command as the root user.

The settings in the last of these options is configured through a file named /etc/sudoers. It may be accessed with the visudo command.

$ visudo

Opening the file with visudo is different from opening it in a regular text editor in that it validates the syntax before closing.

/etc/passwd

The /etc/passwd file contains a list of all users and system listing. You may delete a user from the system just by deleting their corresponding line in this file. The usermod command is simply an interface for editing this file and /etc/shadow.

If you open this file, you'll see a colon-separated line with 6 sections:

$ cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin

Each line represents a user, along with seven parameters:

  1. Username.
  2. Encrypted Password (an x indicates that it is stored in the shadow file, an asterisk indicates that the user cannot login and a blank indicates no password is required).
  3. User ID (UID).
  4. User's group ID number (GID).
  5. Full name of user.
  6. User home directory.
  7. Login shell.

The encrypted password will show as an x and is actually stored in /etc/shadow.

Special users

There exists two special users - the root, which has UID and GID of 0, and the nobody user. The nobody user is an underprivileged user used by some processes to prevent writing on the system.

All processes that have a user ID are also known as pseudo-users.

/etc/shadow

The /etc/shadow file contains a colon-separated line per user and process, along with encrypted passwords and expiration information. When a user is created or deleted, this file, along with /etc/passwd, are modified.

  1. Username
  2. Encrypted Password
  3. Days since last password change
  4. Days until password change allowed
  5. Days before password change required
  6. Days for warning for expiration
  7. Days before account inactive

If the encrypted password shows a !, then the account is locked. A !! means that the password has never been set.

A 999999 or -1 specifies that this feature is disabled.

/etc/default/useradd

Within this file are a list of shell variables that are defaulted whenever a user is created with the useradd command.

Here are just some default variables within this file:

SHELL=/bin/sh
HOME=/home
SKEL=/etc/skel
GROUP=100

/etc/group

This file contains a colon-separated list of groups and all its members. Here are its four parameters, all separated by a colon.

  1. Group name.
  2. Password.
  3. GUID (group ID).
  4. List of users.

/etc/gshadow

This file, much like /etc/shadow, contains information about secure group account information.

Take your Linux skills to the next level!

Command Line Kung Fu

Take your Linux skills to the next level! Try Linux & UNIX

Command Line Kung Fu is packed with dozens of tips and practical real-world examples. You won't find theoretical examples in this book. The examples demonstrate how to solve actual problems. The tactics are easy to find, too. Each chapter covers a specific topic and groups related tips and examples together.

$ Check price
14.9914.99Amazon 4.5 logo(27+ reviews)

More Linux & UNIX resources

Want to avoid becoming a code monkey?

Clean Code

Want to avoid becoming a code monkey? Try Good Practice

Software expert Robert C. Martin presents a revolutionary paradigm with Clean Code: A Handbook of Agile Software Craftsmanship. Martin has teamed up with his colleagues from Object Mentor to distill their best agile practice of cleaning code "on the fly" into a book that will instill within you the values of a software craftsman and make you a better programmer.

$ Check price
49.9949.99Amazon 4.5 logo(427+ reviews)

More Good Practice resources

Ad