Most system configuration lives in /etc. Understanding common formats and safety practices is essential.
/etc/ — system config~/.config/ — per-user config (modern apps)~/.bashrc, ~/.profile — shell configKey=value:
DEBUG=true MAX_CONNECTIONS=100
INI-style sections:
[database] host=localhost port=5432 [logging] level=info
YAML (indentation matters):
database: host: localhost port: 5432 logging: level: info
JSON:
{
"database": {
"host": "localhost",
"port": 5432
}
}
Always backup before editing:
sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak sudo nano /etc/nginx/nginx.conf
Test configuration (if tool supports it):
sudo nginx -t sudo apachectl configtest
Many services auto-reload on file change. Always verify:
sudo systemctl restart nginx
Check status after restart:
sudo systemctl status nginx
Compare original and backup:
diff /etc/file /etc/file.bak
Show what changed:
sudo git diff /etc/file
On production servers, version control /etc:
cd /etc sudo git init sudo git config user.name "Admin" sudo git config user.email "[email protected]" sudo git add -A sudo git commit -m "Initial config"
Now track all changes:
sudo git diff # uncommitted changes sudo git log --oneline # history
/etc/hostname — system name/etc/hosts — local DNS mappings/etc/resolv.conf — DNS servers/etc/fstab — mount points/etc/sudoers — sudo permissions (edit with visudo)/etc/ssh/sshd_config — SSH server config/etc/cron.d/ — system cron jobs
Never edit by hand:
- /etc/sudoers — use visudo
- /etc/shadow — use passwd, usermod
- /etc/group — use groupadd, groupmod
Comments start with #. Some formats support ; instead. Remove old configs when possible rather than commenting them out.