토. 8월 2nd, 2025

The /etc directory is the central hub for system-wide configuration files in Linux and Unix-like operating systems. Its name originates from early Unix conventions (“et cetera”), but today it holds critical settings that control everything from user accounts to network services. For sysadmins and power users, mastering /etc is essential. Let’s break down its structure and key files.


What Lives in /etc?

Unlike user-specific configs (e.g., ~/.config), /etc stores global settings affecting all users and system behavior. Key characteristics:

  • Static files: Not modified by the system during runtime (unlike /var).
  • Hierarchical organization: Subdirectories categorize configs (e.g., /etc/ssh/ for SSH settings).
  • Ownership: Most files require root privileges to edit.

Essential Subdirectories

Directory Purpose
/etc/network/ Network interface configurations (Debian-based).
/etc/systemd/ Settings for systemd (service manager).
/etc/apt/ APT package manager sources (Debian/Ubuntu).
/etc/ssh/ SSH server/client configuration.
/etc/cron.d/ Scheduled tasks (cron jobs).

Critical Configuration Files

Here’s a deep dive into 7 must-know files:

  1. /etc/passwd

    • Purpose: User account information.
    • Format: username:x:UID:GID:comment:home_dir:shell
    • Note: The x indicates encrypted passwords are stored in /etc/shadow.
  2. /etc/shadow

    • Purpose: Secured user passwords and expiration policies.
    • Permissions: Root-only access (-rw-r-----).
    • Fields: Includes password hash, last change date, and expiry details.
  3. /etc/group

    • Purpose: Defines user groups and group memberships.
    • Format: group_name:password:GID:member_list
  4. /etc/fstab

    • Purpose: Configures filesystem mounting at boot.
    • Fields: Device, mount point, filesystem type, options, dump, pass.
    • Example:
      UUID=123... /home ext4 defaults 0 2
  5. /etc/hosts

    • Purpose: Maps hostnames to IP addresses (bypasses DNS).
    • Use Case: Local development or blocking websites.
    • Example:
      127.0.0.1 localhost
  6. /etc/resolv.conf

    • Purpose: DNS resolver configuration (nameservers, search domains).
    • Note: Often auto-generated by network managers.
  7. /etc/sudoers

    • Purpose: Controls sudo access permissions.
    • Edit Safely: Always use visudo to avoid syntax errors!

Best Practices for Editing /etc Files

  • Backup First: Copy files before editing (e.g., cp fstab fstab.bak).
  • Use CLI Editors: Prefer nano, vim, or vi for precision.
  • Validate Syntax: Many services offer checks (e.g., sudo systemctl daemon-reload after editing systemd files).
  • Comment Liberally: Use # to explain changes for future reference.

Why /etc Matters

Misconfiguring /etc files can render a system unbootable or insecure. Always:

  1. Understand what a file controls before editing.
  2. Test changes in staging environments.
  3. Document modifications.

Whether you’re setting up a server or troubleshooting, /etc is your roadmap to a well-tuned Linux system. 🐧

> Pro Tip: Explore /etc with ls -l /etc to discover more gems like /etc/os-release (OS info) or /etc/crontab (system cron jobs)!

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다