wiki:debian-configuration-files
Table of Contents
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:
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
}
}
Editing Safely
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
Applying Changes
Many services auto-reload on file change. Always verify:
sudo systemctl restart nginx
Check status after restart:
sudo systemctl status nginx
Viewing Changes
Compare original and backup:
diff /etc/file /etc/file.bak
Show what changed:
sudo git diff /etc/file
Version Control
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
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 withvisudo)/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.
wiki/debian-configuration-files.md · Last modified: (external edit)
