Site Tools


debian-configuration-files

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

debian-configuration-files.md · Last modified: by 127.0.0.1