Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Understanding Linux /etc Directory Structure and Configuration Files

Tech Oct 22 2

Overview

The /etc directory serves as the central repository for system-wide configuration files across Linux distributions. Understanding these files is esential for system administration, troubleshooting, and server management.

System Identity and Identification

/etc/centos-release          Distribution version information
/etc/machine-id              Unique machine identifier
/etc/hostname                System hostname configuration

These files establish the fundamental identity of a Linux system. The machine-id provides a128-character hexadecimal string that uniquely identifies the host, while centos-release contains distribution-specific metadata.

Time Configuration

/etc/localtime               Timezone data linked to system clock
/etc/adjtime                 Hardware clock adjustment parameters

The localtime file is typically a symlink to timezone data in /usr/share/zoneinfo/. System administrators can modify the timezone using the timedatectl command or by replacing this symlink.

Network and DNS Resolution

/etc/hosts                   Static hostname-to-IP mappings
/etc/resolv.conf             DNS resolver configuration
/etc/host.conf               Host lookup order configuration
/etc/nsswitch.conf           Name service switch configuration

The nsswitch.conf controls how hostname and account lookups resolve. A typical configuration specifies the order for searching local files versus DNS servers:

hosts: files dns

This directive instructs the system to check /etc/hosts first, then query DNS servers defined in resolv.conf.

User and Group Management

/etc/passwd                  User account database
/etc/shadow                  Encrypted password storage
/etc/group                   Group membership definitions
/etc/gshadow                 Group password data

/etc/login.defs              Password aging and UID ranges
/etc/default/useradd         Default user creation parameters
/etc/adduser.conf            Alternative user creation configuration

The passwd file format follows: username:password:uid:gid:gecos:home:shell

Modern systems store password hashes in /etc/shadow, which requires root-only read permissions.

Shell Environment

/etc/profile                 System-wide login script
/etc/bashrc                  Bash interactive configuration
/etc/zshrc                   Zsh configuration
/etc/shells                  Valid login shell list
/etc/environment             Environment variable definitions

The /etc/profile.d/ directory contains modular scripts that execute during login shell initialization.

Text Editor Configuration

/etc/vim/vimrc               Global Vim settings
/etc/virc                    Global Vi settings
/etc/nanorc                  Nano editor configuration

Package Management

/etc/yum.conf                DNF/Yum package manager settings
/etc/dnf/dnf.conf            DNF configuration
/etc/apt/sources.list        APT package sources (Debian/Ubuntu)
/etc/apt/sources.list.d/     Additional APT repository definitions

Cron and Scheduled Tasks

/etc/crontab                 System-wide cron table
/etc/cron.d/                 Drop-in cron configurations
/etc/cron.deny               Deny list for cron access

/var/spool/cron/             User cron job storage

The cron directories define scripts that execute at different intervals:

/etc/cron.hourly/            Runs every hour
/etc/cron.daily/             Runs daily
/etc/cron.weekly/           Runs weekly
/etc/cron.monthly/          Runs monthly

System Logging

/etc/rsyslog.conf            Rsyslog daemon configuration
/etc/rsyslog.d/              Additional logging rules
/etc/logrotate.conf          Log rotation policy
/etc/syslog.conf            Traditional syslog configuration

System Logging

/etc/rsyslog.conf            Rsyslog daemon configuration
/etc/rsyslog.d/              Additional logging rules
/etc/logrotate.conf          Log rotation policy
/etc/syslog.conf            Traditional syslog configuration

Network Services

/etc/exports                 NFS share definitions
/etc/idmapd.conf             NFS ID mapping configuration
/etc/ntp.conf                Network Time Protocol settings
/etc/ssh/sshd_config         SSH server daemon configuration
/etc/ssh/ssh_config          SSH client defaults
/etc/httpd/conf/httpd.conf   Apache web server (RHEL variants)

Dynamic Library Management

/etc/ld.so.conf              Library search path configuration
/etc/ld.so.conf.d/           Additional library paths
/etc/ld.so.cache             Cached library locations

After modifying ld.so.conf, run ldconfig to regenerate the cache.

Kernel Parameters

/etc/sysctl.conf             Persistent kernel parameter settings
/etc/sysctl.d/               Modular kernel parameter files
/proc/sys/                   Runtime kernel parameter interface

Boot and Initialization

/etc/inittab                 System runlevel configuration
/etc/init.d/                 System V init scripts
/etc/systemd/                Systemd unit files and configuration
/etc/grub.d/                 GRUB2 boot loader scripts
/etc/grub.cfg                GRUB boot menu configuration
/etc/dracut.conf             Initial ramdisk configuration

Security Frameworks

/etc/pam.d/                  Pluggable Authentication Modules
/etc/security/               PAM extension configurations
/etc/sudoers                 Sudo privilege elevation rules
/etc/sudoers.d/              Sudo rule fragments
/etc/hosts.allow             TCP wrappers allow rules
/etc/hosts.deny              TCP wrappers deny rules
/etc/selinux/                SELinux policy and configuration

The sudoers file requires editing via visudo to prevent syntax errors that could lock out administrative access.

Hardware and Devices

/etc/fstab                   Static filesystem mount table
/etc/mtab                    Active mount status
/etc/filesystems             Supported filesystem types
/etc/crypttab                Encrypted device mappings
/etc/udev/                   Device manager configuration
/etc/modprobe.d/             Kernel module options
/etc/modules-load.d/         Modules loaded at boot

System Information

/etc/services                Port number to service name mappings
/etc/protocols               IP protocol number definitions
/etc/rpc                     Remote Procedure Call program numbers
/etc/issue                   Pre-login banner
/etc/motd                    Post-login message

Fonts and Localization

/etc/fonts/                  Font configuration
/etc/locale.conf             System locale settings
/etc/timezone                Timezone selection

System Reports

/etc/sos.conf                sosreport collection settings
/etc/updatedb.conf           Filesystem index update configuration

Additional Configuration Locations

/etc/X11/                    X Window System configuration
/etc/opt/                    Optional application configurations
/etc/cups/                   Printing system configuration
/etc/bluetooth/              Bluetooth daemon settings
/etc/sane.d/                 Scanner access configuration

Sysconfig Directory

The /etc/sysconfig/ directory (RHEL/CentOS) contains system service configurations:

/etc/sysconfig/network       Network stack configuration
/etc/sysconfig/iptables      Firewall rules
/etc/sysconfig/selinux       SELinux policy type
/etc/sysconfig/authconfig    Authentication settings

Each service typically stores its runtime parameters here, enabling persistent configuration across reboots.

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.