What is the purpose of the /etc directory in Linux?
/etc holds system-wide configuration files, mostly plain text, such as user accounts, network settings, service configs and the package manager's source lists. Programs read them at start-up, so editing a file here changes how the system behaves.
Explain it simply
Think of the notice board in a college office where all the rules are pinned: timings, who may enter which room, which phone numbers to call. /etc is that notice board for the whole machine. Nothing here is a program; these are settings the programs read.
Some files you will meet again and again: /etc/passwd (list of users), /etc/group, /etc/hosts (local name to IP mapping), /etc/fstab (what to mount at boot), /etc/ssh/sshd_config (SSH server settings) and /etc/crontab. Many services use a sub-folder, for example /etc/nginx/.
Because it is system-wide, only root can normally edit it. Per-user settings live in the user's home as dotfiles such as ~/.bashrc.
Example
ls /etc | head -5
cat /etc/hosts
# 127.0.0.1 localhost
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak # back up before editingWhat to say in the interview
"/etc is the standard place for host-specific, system-wide configuration, mostly text files. I read them to understand a service, and I always make a backup copy before editing, then validate the syntax and reload the service. User-level settings live in dotfiles in the home directory, not in /etc."
Common mistakes
- Saying /etc is for executables; it is for configuration.
- Editing a config in place without a backup copy.