# Debian Configuration Files Most system configuration lives in `/etc`. Understanding common formats and safety practices is essential. ## File Locations - `/etc/` — system config - `~/.config/` — per-user config (modern apps) - `~/.bashrc`, `~/.profile` — shell config ## Common Formats **Key=value:** ```ini DEBUG=true MAX_CONNECTIONS=100 ``` **INI-style sections:** ```ini [database] host=localhost port=5432 [logging] level=info ``` **YAML (indentation matters):** ```yaml database: host: localhost port: 5432 logging: level: info ``` **JSON:** ```json { "database": { "host": "localhost", "port": 5432 } } ``` ## Editing Safely Always backup before editing: ```bash sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak sudo nano /etc/nginx/nginx.conf ``` Test configuration (if tool supports it): ```bash sudo nginx -t sudo apachectl configtest ``` ## Applying Changes Many services auto-reload on file change. Always verify: ```bash sudo systemctl restart nginx ``` Check status after restart: ```bash sudo systemctl status nginx ``` ## Viewing Changes Compare original and backup: ```bash diff /etc/file /etc/file.bak ``` Show what changed: ```bash sudo git diff /etc/file ``` ## Version Control On production servers, version control `/etc`: ```bash cd /etc sudo git init sudo git config user.name "Admin" sudo git config user.email "admin@example.com" sudo git add -A sudo git commit -m "Initial config" ``` Now track all changes: ```bash sudo git diff # uncommitted changes sudo git log --oneline # history ``` ## Common Files - `/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 Comments start with `#`. Some formats support `;` instead. Remove old configs when possible rather than commenting them out.