Important /etc Linux Files

Important /etc Linux Files

What are /etc Files?

Your system's brain is located here, and any configuration files relevant to the system may be found here or in its subdirectories. A local file used to manage a program's operations is referred to as a "configuration file"; it must be static and cannot be an executable binary. This makes it a good idea to frequently back up this directory. If you reinstall or lose your present installation, it will undoubtedly save you a lot of reconfiguration work later. Binaries shouldn't typically be or be found here.

Some Important /etc Files

  • etc/passwd file.

  • etc/ shadow file.

  • etc/group file.

etc/passwd File

The /etc/passwd file is the most important file in the Linux operating system. This file stores essential information about the users on the system. This file is owned by the root user and to edit this file we must have root privileges. But try to avoid editing this file. Now let’s see actually how this file look

This file contains one entry per line. That means it stores one user’s information on one line. The user information contains seven fields and each field is separated by the colon ( : )symbol.

Now let's understand each field.

  • Username: This field stores the usernames which are used while login into the system. The length of this field is between 1 and 32 characters.

  • Password: This field stores the password of the user. The x character indicates the password is stored in the/etc/shadow file in the encrypted format. We can use the passwd command to update this field.

  • User ID(UID): A user identifier is a number assigned to each user by the operating system to refer the users. The 0 UID is reserved for the root user. And 1-99 UID are reserved for other predefined accounts. And 100-999 are reserved by the system for administrative and system accounts/groups.

  • Group ID(GID): The group identifier is the number indicating the primary group of users. Most of the time it is the same as the UID.

  • User ID Info (GECOS): This is a comment field. This field contains information like the user's phone number, address, or full name of the user. This field is used by the finger command to get information about the user.

  • Home directory: This field contains the absolute path of the user’s home directory. By default**,** the users are created under the /home directory. If this file is empty**,** then the home directory of that user will be /

  • Login shell: This field stores the absolute path of the user shell. This shell is started when the user is login to the system.

etc/shadow File

Basically, the /etc/shadow file stores secure user account information. All fields are separated by a colon (:)symbol. It contains one entry per line for each user listed in the/etc/passwd file. Generally, shadow file entry looks as follows (click to enlarge image)

Now let's understand each field.

  • Username: A valid account name, which exists on the system.

  • Password: Your encrypted password is in hash format. The password should be a minimum of 15-20 characters long including special characters, digits, lowercase alphabetic and more.

  • Last password change (last changed): The date of the last password change, expressed as the number of days since Jan 1, 1970 (Unix time). The value 0 has a special meaning, which is that the user should change her password the next time she will log in to the system.

  • Minimum: The minimum number of days required between password changes i.e. the number of days left before the user is allowed to change her password again. An empty field and a value of 0 mean that there is no minimum password age.

  • Maximum: The maximum number of days the password is valid, after that user is forced to change her password again.

  • Warn: The number of days before the password is to expire that user is warned that his/her password must be changed.

  • Expire The date of expiration of the account, expressed as the number of days since Jan 1, 1970.

etc/group File

/etc/group Defines the default system group entries for system groups that support some system-wide tasks, such as printing, network administration, or electronic mail. Many of these groups have corresponding entries in the /etc/passwd file. Because most Linux systems use a UPG scheme, a new entry is automatically created in the/etc/group when a new user is added. The group name is the same as the username.

  • Group name - Contains the name assigned to the group.

  • Group-password (x) - x in this field indicates that shadow passwords are used.

  • GID - Contains the group’s GID number.

  • Username list - List of users that are members of the group.

Commands for User

  1. Useradd - useradd is a command in Linux that is used to add user accounts to your system. It is just a symbolic link to the adduser command in Linux and the difference between both them is that useradd is a native binary compiled with the system whereas adduser is a Perl script that uses useradd binary in the background. It makes changes to the following files:

    • /etc/passwd

    • /etc/shadow

    • /etc/group

    • creates a directory for new users in /home

  2. Usermod - usermod command or modify user is a command in Linux that is used to change the properties of a user in Linux through the command line. After creating a user we have to sometimes change their attributes like password or login directory etc. so in order to do that we use the Usermod command. The information of a user is stored in the following files:

    • /etc/passwd

    • /etc/group

    • /etc/shadow

    • /etc/login.defs

  3. Userdel - userdel command in the Linux system is used to delete a user account and related files. This command basically modifies the system account files, deleting all the entries which refer to the username LOGIN. It is a low-level utility for removing users.