Understanding Linux Security

Understanding Linux Security : /etc/passwd & /etc/shadow file

Security cycle

No system is complete without some form of security. There must be a mechanism available to protect files from unauthorized viewing or modification. The Linux system follows the Unix method of file permissions, allowing individual users and groups access to files based on a set of security settings for each file and directory.

Linux Security

Linux security

The core of the Linux security system is the user account . Each individual who accesses a Linux system should have a unique user account assigned. The permissions users have to objects on the system depend on the user account they log in with. User permissions are tracked using a user ID (often called a UID), which is assigned to an account when it’s created. The UID is a numerical value, unique for each user. However, you don’t log in to a Linux system using your UID. Instead, you use a login name . The login name is an alphanumeric text string of eight characters or fewer that the user uses to log in to the system (along with an associated password).

The Linux system uses special files and utilities to track and manage user accounts on the system.

The /etc/passwd File

The Linux system uses a special file to match the login name to a corresponding UID value. This file is the /etc/passwd file. The /etc/passwd file contains several pieces of information about the user. Here’s what a typical /etc/passwd file looks like on a Linux system:

 # 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
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologi

The root user account is the administrator for the Linux system and is always assigned UID. As you can see, the Linux system creates lots of user accounts for various functions that aren’t actual users.

These are called system accounts . A system account is a special account that services running on the system use to gain access to resources on the system. All services that run in background mode need to be logged in to the Linux system under a system user account.

Before security became a big issue, these services often just logged in using the root user account. Unfortunately, if an unauthorized person broke into one of these services, he instantly gained access to the system as the root user. To prevent this, now just about every service that runs in background on a Linux server has its own user account to log in with. This way, if a troublemaker does compromise a service, he still can’t necessarily get access to the whole system.

Linux reserves UIDs below 500 for system accounts. Some services even require specific UIDs to work properly. When you create accounts for normal users, most Linux systems assign the first available UID starting at 500 (although this is not necessarily true for all Linux distributions). Probably noticed that the /etc/passwd file contains lots more than just the login name and UID for the user.

The fields of the /etc/passwd file contain the following information:

  • The login username
  • The password for the user
  • The numerical UID of the user account
  • The numerical group ID (GID) of the user account
  • A text description of the user account (called the comment field)
  • The location of the HOME directory for the user
  • The default shell for the user
PreWebHost.com

PreWebHost.com

Leave a Reply

Your email address will not be published. Required fields are marked *