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!

How Linux Works

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

In this completely revised second edition of the perennial best seller How Linux Works, author Brian Ward makes the concepts behind Linux internals accessible to anyone curious about the inner workings of the operating system. Inside, you'll find the kind of knowledge that normally comes from years of experience doing things the hard way.

$ Check price
39.9539.95Amazon 5 logo(114+ reviews)

More Linux & UNIX resources

Want to avoid becoming a code monkey?

The Pragramatic Programmer

Want to avoid becoming a code monkey? Try Good Practice

The Pragmatic Programmer illustrates the best practices and major pitfalls of many different aspects of software development.Whether you're a new coder, an experienced programmer, or a manager responsible for software projects, use these lessons daily, and you'll quickly see improvements in personal productivity, accuracy, and job satisfaction.

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

More Good Practice resources

Ad