Table of Contents
Purpose of `/etc`
/etc is the central place for system-wide configuration files on a Linux system. Anything that controls how the system and services behave (for all users) is very likely to live here.
Key points:
- It holds configuration, not user data.
- Files here are typically plain text.
- Changes often take effect on next service restart or next login.
- Many tools have both:
- system-wide config in
/etc/... - per-user config in hidden files under
~(like~/.config/...)
You usually need sudo (or root) to edit files in /etc.
General Conventions in `/etc`
You’ll see a few common patterns:
- Single config files: e.g.
/etc/fstab,/etc/hosts - Config directories: e.g.
/etc/ssh/,/etc/cron.d/ - “d”-style drop-in directories:
- Example:
/etc/sudoers.d/,/etc/sysctl.d/,/etc/apt/sources.list.d/ - Idea: one main file plus many small snippet files
- Distribution-specific paths:
- Debian/Ubuntu:
/etc/apt/,/etc/default/ - Fedora/RHEL:
/etc/dnf/,/etc/yum.repos.d/ - Arch:
/etc/pacman.conf,/etc/pacman.d/
When unsure what a file does, use man (e.g. man fstab, man sshd_config) if available.
Key Areas Inside `/etc`
This is not a complete list, but covers the most commonly encountered parts for beginners.
System Identity and Network Basics
/etc/hostname- Contains the system’s hostname (a single name, e.g.
my-laptop). - Used at boot and shown in your shell prompt on many systems.
/etc/hosts- Local mapping between hostnames and IP addresses.
- Often contains entries like:
127.0.0.1 localhost
127.0.1.1 my-laptop- Useful for overriding DNS for specific names (e.g. for local testing).
/etc/resolv.conf- Defines DNS servers and related settings (which nameserver to query).
- On modern systems, this may be managed automatically by network tools (e.g.
systemd-resolved, NetworkManager), so direct edits may be overwritten.
User and Authentication Configuration
These files do not usually store plain-text passwords anymore, but they define user accounts and related policies:
/etc/passwd- List of user accounts, their home directories, shell, etc.
- Readable by all users.
/etc/shadow- Encrypted password hashes and some password policy data.
- Only readable by root for security reasons.
/etc/group- Group definitions and group membership.
/etc/login.defs- Default settings for user accounts (for tools like
useradd). /etc/sudoersand/etc/sudoers.d/- Rules for who can use
sudoand how. - Must be edited with
visudoto avoid syntax errors that could lock you out of admin access.
System-Wide Shell and Environment Settings
/etc/profile- System-wide shell initialization for login shells (typically
sh/bash). /etc/bash.bashrc(Debian/Ubuntu) or similar- Global configuration for interactive
bashshells. /etc/profile.d/- Directory with small scripts that adjust environment variables or behavior for all users (e.g. paths, language settings).
Per-user shell configuration typically lives in files like ~/.bashrc, ~/.profile, etc., which supplement or override these global settings.
Service and Daemon Configuration
Most system services keep their configuration under /etc, usually in subdirectories:
/etc/ssh/- Settings for the SSH client (
ssh_config) and server (sshd_config). /etc/cron.*(/etc/cron.d/,/etc/cron.daily/, etc.)- System-wide scheduled tasks (cron jobs).
/etc/systemd/- Systemd configuration snippets and overrides.
- Often used for custom service configuration and drop-in files.
When installing new packages, you’ll often see new config files appear in /etc/ or /etc/<package-name>/.
Package Manager Configuration (Distribution-Specific)
Each distribution’s package manager keeps its configuration in /etc:
- Debian/Ubuntu (APT):
/etc/apt/sources.list– main list of package repositories./etc/apt/sources.list.d/– extra repository definitions as separate files./etc/apt/apt.conf.d/– APT behavior snippets.- Fedora/RHEL (DNF/YUM):
/etc/dnf/dnf.conf– DNF main config./etc/yum.repos.d/– repository definitions.- Arch Linux (pacman):
/etc/pacman.conf– pacman configuration./etc/pacman.d/– extra configuration lists (like mirrors).
Editing these files controls where software comes from and how the package manager behaves.
Boot and Filesystem Configuration
/etc/fstab- Table of filesystems to mount at boot.
- Each line describes a device/partition (or network share), mount point, and options.
/etc/mtab(or symlink to/proc/self/mounts)- List of currently mounted filesystems. More informational than edited by hand on modern systems.
Some bootloader-related configs (e.g. GRUB) also live under /etc:
/etc/default/grub(on many distros)- High-level GRUB options (boot timeout, default kernel options).
- After editing, you usually run a command like
update-gruborgrub2-mkconfigdepending on your distribution.
Application and Desktop Configuration (System-Wide)
System-wide defaults for various tools often live under /etc:
/etc/skel/- Template files for new user home directories.
- Files here are copied into a new user’s home when the account is created.
/etc/X11/- X11 (traditional Linux graphical system) configuration files, if used.
/etc/pam.d/- Configuration for PAM (Pluggable Authentication Modules) controlling how authentication is performed for different services.
Many graphical or desktop-related defaults may also be placed here by packages.
Working Safely with `/etc`
Because /etc controls system behavior, changes can easily break things. A few safe practices:
- Make backups before editing
For example:
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak- Use appropriate tools
visudofor/etc/sudoers.- Distribution-specific helpers (e.g.
update-grub) after changing certain files. - Check syntax when possible
Some daemons provide a “test config” mode, for example:
sudo sshd -t
to validate /etc/ssh/sshd_config.
- Restart or reload services after changes
Typically withsystemctl(covered elsewhere), e.g.:
sudo systemctl restart sshWhat Belongs in `/etc` (and What Does Not)
- Belongs in
/etc: - System-wide configuration generated by packages or administrators.
- Text files that can be edited to change behavior.
- Does not belong in
/etc: - Large data files.
- Logs (those go under
/var/log). - User-specific settings (those go in each user’s home directory).
As a rule: if you’re changing how the system as a whole behaves, you’re probably editing something in /etc.