Dies ist eine alte Version des Dokuments!
Inhaltsverzeichnis
Wichtige Konfigurationsdateien
Kurzfassung: Linux-Systeme verwenden hunderte Konfigurationsdateien. Dieser Guide dokumentiert die wichtigsten Dateien, ihre Funktionen und Ort. Zielgruppe: Systemadministratoren zur Verwaltung und Konfiguration.
Übersicht
Konfigurationsdateien sind das Herzstück von Linux-Systemen. Sie befinden sich überwiegend unter /etc und werden meist im Textformat gespeichert. Dieser Guide dokumentiert die wichtigsten Dateien, ihre Funktionen, Locations und Backup-Strategien.
Struktur von /etc
/etc/ # Systemweite Konfiguration ├── systemd/ # systemd-Konfiguration ├── init.d/ # SysV Init-Skripte ├── default/ # Service-Defaults ├── network/ # Netzwerk (systemd-networkd) ├── netplan/ # netplan (Netzwerk-Abstraktionslayer) ├── NetworkManager/ # NetworkManager-Konfiguration ├── ssh/ # SSH-Konfiguration ├── ssl/ oder tls/ # SSL/TLS-Zertifikate ├── security/ # Sicherheits-Konfiguration ├── pam.d/ # PAM (Authentifizierung) ├── sudoers.d/ # Sudo-Konfiguration ├── cron.d/ # Cron-Jobs ├── apt/ oder yum.repos/ # Paketquellen ├── rsyslog.d/ # Logging-Konfiguration ├── hostname # Hostname ├── hosts # Host-IP-Mapping ├── fstab # Dateisystem-Mountpoints ├── grub.d/ # Bootloader-Konfiguration └── ...
Wichtigste Konfigurationsdateien
System und Boot
| Datei | Funktion | Backup? |
/etc/hostname | Hostname des Systems | ✓ |
/etc/hosts | Lokales Host-Mapping (IP → Hostname) | ✓ |
/boot/grub/grub.cfg | GRUB Bootloader-Konfiguration (Auto-generiert) | - |
/etc/default/grub | GRUB Einstellungen (bearbeiten, nicht grub.cfg!) | ✓ |
/etc/fstab | Dateisystem-Mountpoints (kritisch!) | ✓ |
/etc/default/locale | Spracheinstellungen | ✓ |
/etc/timezone | Zeitzonen-Konfiguration | ✓ |
/etc/os-release | System-Informationen | - |
/proc/cmdline | Kernel Boot-Parameter | - |
Beispiele:
# Hostname anzeigen/ändern cat /etc/hostname sudo hostnamectl set-hostname newname # Hosts-Datei (für Tests) cat /etc/hosts # 127.0.0.1 localhost # 192.168.1.10 webserver.local # fstab - KRITISCH bei Änderung überprüfen! cat /etc/fstab # UUID=abc123 /home ext4 defaults 0 2 sudo mount -a # Syntax testen (bevor Reboot!) # GRUB-Konfiguration sudo vim /etc/default/grub sudo grub-mkconfig -o /boot/grub/grub.cfg
Netzwerk-Konfiguration
| Datei | Funktion | Backup? |
/etc/netplan/*.yaml | netplan-Netzwerk-Konfiguration (Ubuntu/Debian) | ✓ |
/etc/systemd/network/*.network | systemd-networkd Konfiguration | ✓ |
/etc/NetworkManager/conf.d/ | NetworkManager-Konfiguration | ✓ |
/etc/resolv.conf | DNS-Resolver (wird meist automatisch generiert!) | - |
/run/systemd/resolve/resolv.conf | systemd-resolved aktuelle Konfiguration | - |
/etc/wpa_supplicant/wpa_supplicant.conf | WLAN-Passwörter | ✓ |
/etc/hosts.allow | TCP Wrapper - IP-Whitelist | ✓ |
/etc/hosts.deny | TCP Wrapper - IP-Blacklist | ✓ |
Beispiele:
# netplan-Konfiguration sudo cat /etc/netplan/01-netcfg.yaml # systemd-resolved (moderne Systeme) resolvectl status cat /run/systemd/resolve/resolv.conf # TCP Wrapper (beschränke SSH) sudo vim /etc/hosts.allow # sshd: 192.168.1.0/24 sudo vim /etc/hosts.deny # sshd: ALL
Benutzer und Authentifizierung
| Datei | Funktion | Beachten |
/etc/passwd | Benutzer-Datenbank (Passwörter verschlüsselt!) | - |
/etc/shadow | Verschlüsselte Passwörter (root only) | ✓ |
/etc/group | Gruppen-Datenbank | - |
/etc/gshadow | Verschlüsselte Gruppen-Passwörter | ✓ |
/etc/sudoers | Sudo-Konfiguration (IMMER mit visudo editieren!) | ✓ |
/etc/sudoers.d/ | Sudo-Erweiterungen (drop-in) | ✓ |
/etc/pam.d/ | PAM-Authentifizierungs-Module | ✓ |
/etc/login.defs | Login-Einstellungen (Passwords, UID-Range) | ✓ |
/etc/nsswitch.conf | Name Service Switch (Benutzer-, Host-, DNS-Lookup) | ✓ |
/home/*/ | Home-Verzeichnisse | ✓ |
Beispiele:
# Sudoers editieren (NIEMALS direkt mit nano oder vim! Anpassen auf vim update-alternatives --config editor) sudo visudo # Passwort-Richtlinien cat /etc/login.defs | grep PASS # PAM-Module (z.B. für 2FA, LDAP) ls /etc/pam.d/ cat /etc/pam.d/login # User Info cat /etc/passwd | grep username # username:x:1000:1000:Full Name:/home/username:/bin/bash # nsswitch.conf - Name Service Switch Konfiguration cat /etc/nsswitch.conf
Name Service Switch (nsswitch.conf)
Die /etc/nsswitch.conf definiert, wie das System Informationen zu Benutzern, Gruppen, Hosts und anderen Services auflöst.
| Datei | Funktion | Backup? |
/etc/nsswitch.conf | Name Service Switch - Lookup-Reihenfolge | ✓ |
Wichtige nsswitch-Zeilen:
# Benutzer-Lookup (lokale Dateien → LDAP → NIS) passwd: files ldap # Gruppen-Lookup group: files ldap # Host-Lookup (lokale Datei → DNS) hosts: files dns # Netzwerk-Lookup networks: files # Service-Lookup services: files # Protokoll-Lookup protocols: files # RPC-Lookup rpc: files # Aliases-Lookup (Email) aliases: files # Shadow-Lookup (Passwörter) shadow: files ldap # Automount-Lookup automount: files ldap
Lookup-Module - Erklärung:
| Modul | Erklärung | Dateien/Services | Nutzung |
files | Lokale Dateien durchsuchen | /etc/passwd, /etc/group, /etc/hosts, /etc/shadow | Immer zuerst, Standard |
dns | Internet-DNS abfragen | DNS-Server (8.8.8.8, etc.) | Hostname → IP-Auflösung |
ldap | LDAP-Verzeichnisdienst | LDAP-Server (OpenLDAP, etc.) | Unternehmens-Verzeichnis |
nis | Network Information Service | NIS/YP-Server | Ältere Unix-Netzwerke |
hesiod | Hesiod Informationsdienst | Hesiod-Server | Akademische Netzwerke (veraltet) |
sss | System Security Services (SSSD) | Active Directory, Kerberos, FreeIPA | Windows-Domain-Integration |
db | Berkeley Database | /etc/db.passwd, etc. | Performance-Optimierung |
compat | Kompatibilität mit +/- Syntax | /etc/passwd mit +/- Einträgen | Legacy NIS-Kompatibilität |
Praktische Modul-Beispiele:
Nur lokale Dateien (einfaches System):
passwd: files group: files hosts: files shadow: files
Lokale + DNS (Standard):
passwd: files group: files hosts: files dns shadow: files
Lokale + LDAP (Unternehmens-Setup):
passwd: files ldap group: files ldap hosts: files dns shadow: files ldap
SSSD für Active Directory (Windows-Integration):
passwd: files sss group: files sss hosts: files dns myhostname shadow: files sss
Performance mit Berkeley Database Cache:
passwd: db files group: db files hosts: db files dns
Modul-Reihenfolge Erklärung:
Beispiel: passwd: files ldap
1. Erst in "files" suchen → /etc/passwd durchsuchen 2. Wenn nicht found → "ldap" befragen (LDAP-Server) 3. Wenn noch nicht found → Benutzer nicht vorhanden (Fehler)
Testen welches Modul verwendet wird:
# Welches Modul wird genutzt? strace -e open getent passwd testuser 2>&1 | grep -E "/etc/|ldap|nis" # Einfacher: Benutzer existiert? getent passwd testuser # Sucht nach nsswitch-Konfiguration # Wenn LDAP konfiguriert: ldapwhoami -H ldap://ldap.example.com -D "uid=testuser,ou=people,dc=example,dc=com" -W # Wenn SSSD (Active Directory): sudo getent passwd domain\\\\testuser
Praktisches Beispiel - LDAP + lokale Fallback:
passwd: files ldap shadow: files ldap group: files ldap hosts: files dns
Dies bedeutet:
1. Zuerst lokale Dateien durchsuchen 2. Falls nicht gefunden: LDAP abfragen 3. Für Hosts: lokale /etc/hosts, dann DNS
Beispiel - SSSD (für Active Directory):
passwd: files systemd sss shadow: files sss group: files systemd sss hosts: files dns myhostname resolve
Debugging und Testing:
# nsswitch-Konfiguration anzeigen cat /etc/nsswitch.conf # Benutzer-Auflösung testen getent passwd username # Zeigt Benutzer-Info getent group groupname # Zeigt Gruppen-Info getent hosts example.com # Zeigt Host-Auflösung # DNS-Auflösung testen nslookup example.com dig example.com host example.com # LDAP-Verbindung testen (falls konfiguriert) ldapwhoami -H ldap://ldap.example.com -D "cn=admin,dc=example,dc=com" -W # SSSD Status (falls Active Directory) sudo systemctl status sssd sudo journalctl -u sssd -n 50
SSH und Remote Access
| Datei | Funktion | Backup? |
/etc/ssh/sshd_config | SSH-Server-Konfiguration (kritisch!) | ✓ |
/etc/ssh/ssh_config | SSH-Client-Konfiguration | ✓ |
/etc/ssh/ssh_host_* | SSH-Host-Schlüssel (privat & public) | ✓✓✓ |
~/.ssh/authorized_keys | Public-Keys für Passwort-loses Login | ✓ |
~/.ssh/config | Benutzer-SSH-Konfiguration | ✓ |
~/.ssh/id_rsa | Privater SSH-Schlüssel (Benutzer) | ✓✓✓ |
Beispiele:
# SSH-Daemon konfigurieren sudo vim /etc/ssh/sshd_config # Port 22 # PermitRootLogin no # PasswordAuthentication no # PubkeyAuthentication yes # SSH-Config validieren vor Anwendung sudo sshd -t # SSH-Service neu starten sudo systemctl restart sshd # SSH-Schlüsseln-Backup (KRITISCH!) sudo tar -czf /root/ssh_keys_backup.tar.gz /etc/ssh/ sudo chmod 600 /root/ssh_keys_backup.tar.gz
Firewall und Sicherheit
| Datei | Funktion | Backup? |
/etc/ufw/ufw.conf | UFW Firewall Konfiguration | ✓ |
/etc/ufw/rules.d/ | UFW Firewall-Regeln | ✓ |
/etc/nftables.conf | nftables Firewall-Konfiguration | ✓ |
/etc/iptables/rules.v4 | iptables IPv4-Regeln | ✓ |
/etc/iptables/rules.v6 | iptables IPv6-Regeln | ✓ |
/etc/fail2ban/jail.conf | fail2ban-Konfiguration | ✓ |
/etc/apparmor.d/ | AppArmor-Profile | ✓ |
/etc/selinux/config | SELinux-Konfiguration | ✓ |
Beispiele:
# UFW Status und Regeln sudo ufw status numbered # nftables Regeln sudo nft list ruleset # fail2ban (Brute-Force-Schutz) sudo cat /etc/fail2ban/jail.conf sudo fail2ban-client status # AppArmor Profile sudo aa-status
Systemd
| Datei | Funktion | Backup? |
/etc/systemd/system.conf | systemd Haupt-Konfiguration | ✓ |
/etc/systemd/journald.conf | Journal (Logging) Konfiguration | ✓ |
/etc/systemd/logind.conf | Login-Manager Konfiguration | ✓ |
/etc/systemd/timesyncd.conf | Zeit-Synchronisation | ✓ |
/etc/systemd/resolved.conf | DNS-Resolver | ✓ |
/etc/systemd/networkd.conf | systemd-networkd Konfiguration | ✓ |
/etc/systemd/system/*.service | Benutzer-Services | ✓ |
/etc/systemd/system/*.service.d/ | Service-Overrides (Drop-In) | ✓ |
Beispiele:
# journald-Logging (Journal-Größe) sudo vim /etc/systemd/journald.conf # SystemMaxUse=2G # RuntimeMaxUse=1G # systemd-resolved DNS sudo vim /etc/systemd/resolved.conf # DNS=8.8.8.8 1.1.1.1 sudo systemctl restart systemd-resolved # Service-Override (eigene Werte ohne Datei zu editieren) sudo systemctl edit apache2 # [Service] # Restart=always # RestartSec=5s
Logging und Monitoring
| Datei | Funktion | Backup? |
/etc/rsyslog.conf | rsyslog (Syslog)-Konfiguration | ✓ |
/etc/rsyslog.d/ | rsyslog-Rules | ✓ |
/etc/logrotate.conf | Log-Rotation | ✓ |
/etc/logrotate.d/ | Service-spezifische Log-Rotation | ✓ |
/var/log/syslog oder /var/log/messages | System-Logs | - |
/var/log/auth.log oder /var/log/secure | Authentifizierungs-Logs | - |
/var/log/kern.log | Kernel-Logs | - |
/var/log/journal/ | systemd-journal (binary) | - |
Beispiele:
# rsyslog Konfiguration sudo cat /etc/rsyslog.conf sudo vim /etc/rsyslog.d/custom.conf # Log-Rotation Konfiguration cat /etc/logrotate.conf cat /etc/logrotate.d/apache2 # Journald-Logs anzeigen journalctl -n 50 # Letzte 50 Zeilen journalctl -f # Live-Logs journalctl -u apache2 -n 20 # Service-Logs
Paketmanagement
| Datei | Funktion | Backup? |
/etc/apt/sources.list | APT Paketquellen (Debian/Ubuntu) | ✓ |
/etc/apt/sources.list.d/ | APT Quellen (drop-in) | ✓ |
/etc/apt/apt.conf | APT Konfiguration | ✓ |
/etc/yum.repos.d/ | YUM Repositories (RHEL/CentOS) | ✓ |
/etc/yum.conf | YUM Konfiguration | ✓ |
/etc/pacman.conf | Pacman Konfiguration (Arch) | ✓ |
/var/cache/apt/ | APT Cache | - |
Beispiele:
# Paketquellen (Debian/Ubuntu) sudo vim /etc/apt/sources.list # deb http://archive.ubuntu.com/ubuntu focal main universe # PPA hinzufügen (moderner Weg) sudo add-apt-repository ppa:user/ppa-name # YUM Repositories (RHEL/CentOS) sudo vim /etc/yum.repos.d/rhel.repo
Web Server (Apache, Nginx)
| Datei | Funktion | Backup? |
/etc/apache2/apache2.conf | Apache Haupt-Konfiguration | ✓ |
/etc/apache2/mods-enabled/ | Aktivierte Apache-Module | ✓ |
/etc/apache2/sites-available/ | Apache Virtual Hosts | ✓ |
/etc/apache2/sites-enabled/ | Aktivierte Virtual Hosts (Links) | - |
/etc/nginx/nginx.conf | Nginx Haupt-Konfiguration | ✓ |
/etc/nginx/sites-available/ | Nginx Virtual Hosts | ✓ |
/etc/nginx/sites-enabled/ | Aktivierte Nginx Sites (Links) | - |
/var/www/html/ | Standard-Dokumenten-Root | ✓ |
Beispiele:
# Apache konfigurieren sudo vim /etc/apache2/apache2.conf sudo a2ensite example.com # Site aktivieren sudo a2dissite default-ssl # Site deaktivieren sudo apache2ctl configtest # Syntax-Test sudo systemctl restart apache2 # Nginx konfigurieren sudo vim /etc/nginx/nginx.conf sudo vim /etc/nginx/sites-available/example.com sudo ln -s ../sites-available/example.com /etc/nginx/sites-enabled/ sudo nginx -t # Syntax-Test sudo systemctl restart nginx
Datenbank (MySQL/PostgreSQL)
| Datei | Funktion | Backup? |
/etc/mysql/mysql.conf.d/mysqld.cnf | MySQL Server-Konfiguration | ✓ |
/etc/postgresql/*/main/postgresql.conf | PostgreSQL Konfiguration | ✓ |
/var/lib/mysql/ | MySQL Daten-Verzeichnis | ✓✓✓ |
/var/lib/postgresql/ | PostgreSQL Daten-Verzeichnis | ✓✓✓ |
Beispiele:
# MySQL konfigurieren sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf sudo systemctl restart mysql # PostgreSQL Versionscheck sudo -u postgres psql --version sudo vim /etc/postgresql/14/main/postgresql.conf sudo systemctl restart postgresql
Zeitplanung und Cron
| Datei | Funktion | Backup? |
/etc/crontab | System-Crontab | ✓ |
/etc/cron.d/ | Cron-Jobs (drop-in) | ✓ |
/etc/cron.daily/ | Täglich ausgeführte Scripts | ✓ |
/etc/cron.weekly/ | Wöchentlich ausgeführte Scripts | ✓ |
/etc/cron.monthly/ | Monatlich ausgeführte Scripts | ✓ |
~/.crontab | Benutzer-Crontab | ✓ |
Beispiele:
# System-Crontab sudo vim /etc/crontab # Benutzer-Crontab (sicherer) crontab -e # Cron-Jobs überprüfen sudo crontab -l crontab -l
Wichtige Lokationen zusammengefasst
# Kritische Backups (SEHR WICHTIG!) /etc/passwd /etc/shadow /etc/group /etc/gshadow /etc/ssh/ssh_host_* /etc/fstab /etc/hostname /etc/sudoers /root/.ssh/ # Netzwerk-Konfiguration /etc/netplan/ /etc/systemd/network/ /etc/NetworkManager/ /etc/resolv.conf # Sicherheit /etc/ssh/sshd_config /etc/ufw/ /etc/nftables.conf /etc/fail2ban/ # Services /etc/systemd/system/ /etc/systemd/system/*.service.d/ /etc/init.d/ # Logging /etc/rsyslog.conf /etc/logrotate.conf # Anwendungen /etc/apache2/ oder /etc/nginx/ /etc/mysql/ oder /etc/postgresql/
Backup-Strategie
# Kritische Dateien täglich backen sudo tar -czf /root/etc-backup-$(date +%Y%m%d).tar.gz \ /etc/passwd /etc/shadow /etc/group /etc/gshadow \ /etc/ssh/ /etc/sudoers /etc/fstab /etc/hostname # Gesamtes /etc-Verzeichnis monatlich sudo tar -czf /root/etc-full-backup-$(date +%Y%m%d).tar.gz \ --exclude=/etc/ssl/private \ /etc/ # Wichtige Dateien in Git versionieren (privates Repo!) cd /root/config-repo sudo cp /etc/sudoers ./sudoers.bak git add . git commit -m "Backup vom $(date)"
Häufige Bearbeitungen
Vorher-Nachher: Hostname ändern
# Alt (System V) sudo vim /etc/hostname sudo vim /etc/hosts sudo hostname new-name # Neu (systemd) sudo hostnamectl set-hostname new-name
Statische IP-Adresse setzen
# Ubuntu/Debian (netplan) sudo vim /etc/netplan/01-netcfg.yaml sudo netplan apply # RHEL/CentOS (nmcli) sudo nmcli connection add type ethernet con-name eth0 \ ifname eth0 ipv4.addresses 192.168.1.100/24 \ ipv4.gateway 192.168.1.1 ipv4.method manual # systemd-networkd sudo vim /etc/systemd/network/10-eth0.network sudo systemctl restart systemd-networkd
SSH für Root deaktivieren
sudo vim /etc/ssh/sshd_config # Ändere: PermitRootLogin no sudo sshd -t sudo systemctl restart sshd
Hinweise
/etc/fstab nicht fehlerhaft ändern → System startet nicht mehr!
- /etc/sudoers NUR mit visudo editieren!
- /etc/passwd und /etc/shadow synchronisieren!
- SSH-Konfiguration mit sshd -t testen!
- Netplan mit netplan try testen (Auto-Rollback)!
- NIEMALS /boot/grub/grub.cfg direkt editieren (Auto-generiert!)
/etc regelmäßig in Git versionieren (privates Repo)
- Automatische tägliche Backups: Cron-Job einrichten
- Änderungen dokumentieren: Wer, Wann, Warum
- Neue Konfiguration immer in separater Test-Umgebung prüfen
- SSH-Schlüssel separat backen und verschlüsseln
- sudo Logs überprüfen: sudo journalctl SUDO_COMMAND
- Konfiguration versionen kontrollieren (z.B. Apache-Version in Kommentar)
