# 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.