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.

Want to avoid becoming a code monkey?

Pragmatic Thinking

Want to avoid becoming a code monkey? Try Good Practice

Programmers have to constantly learn new concepts and technologies. In this book by Andy Hunt, you'll learn how our brains are wired, and how to take advantage of your brain's architecture to make the most of your learning. You'll learn new tricks and tips to learn more, faster, and retain more of what you learn.

$ Check price
34.9534.95Amazon 4.5 logo(86+ reviews)

More Good Practice resources

Take your Linux skills to the next level!

The Linux Command Line

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

The Linux Command Line takes you from your very first terminal keystrokes to writing full programs in Bash, the most popular Linux shell. Along the way you'll learn the timeless skills handed down by generations of gray-bearded, mouse-shunning gurus: file navigation, environment configuration, command chaining, pattern matching with regular expressions, and more.

$ Check price
39.9539.95Amazon 4.5 logo(274+ reviews)

More Linux & UNIX resources

Ad