| name | linux-administration |
| description | System administration for Linux servers. Manage packages, services, and system configuration. Use when administering Linux systems. |
| license | MIT |
| metadata | {"author":"devops-skills","version":"1.0"} |
Linux Administration
Core Linux system administration skills for managing production servers, development environments, and infrastructure hosts across Debian/Ubuntu and Arch-based distributions.
When to Use
- Provisioning and maintaining Linux servers in any environment
- Installing, updating, or removing software packages
- Managing filesystems, disk usage, and mount points
- Investigating runaway processes or high resource consumption
- Scheduling recurring tasks with cron or systemd timers
- Analyzing system and application logs for troubleshooting
Prerequisites
- Root or sudo access on the target system
- SSH access configured (see
ssh-configuration skill)
- Familiarity with a terminal text editor (helix, vim, nano)
- Package manager available (
apt on Debian/Ubuntu, pacman or paru on Arch)
Package Management
Debian / Ubuntu (apt)
apt update && apt upgrade -y
apt search nginx
apt show nginx
apt install nginx=1.24.0-1ubuntu1
apt install -y nginx certbot python3-certbot-nginx
apt remove nginx
apt purge nginx
apt autoremove -y
dpkg -l | grep nginx
cat <<'EOF' > /etc/apt/preferences.d/pin-nginx
Package: nginx
Pin: version 1.24.0-1ubuntu1
Pin-Priority: 1001
EOF
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
> /etc/apt/sources.list.d/docker.list
apt update
RHEL / CentOS / Fedora (dnf)
pacman -Syu
paru -Syu
pacman -Ss nginx
pacman -Si nginx
pacman -S nginx
pacman -R nginx
pacman -Rs nginx
pacman -Q | grep nginx
pacman -Qs nginx
pacman -Syy
rg "^\[.*\]" /etc/pacman.conf | rg -v "^#"
pacman -Sc
pacman -Scc
System Information
uname -a
cat /etc/os-release
hostnamectl
lscpu
nproc
free -h
df -hT
du -sh /var/log/*
ip addr show
ip route show
uptime
w
Filesystem Management
lsblk
fdisk -l
mkfs.ext4 /dev/sdb1
mount /dev/sdb1 /mnt/data
echo '/dev/sdb1 /mnt/data ext4 defaults,noatime 0 2' >> /etc/fstab
mount -a
umount /dev/sdb1
fsck.ext4 -y /dev/sdb1
iostat -xz 2
find / -xdev -type f -size +100M -exec ls -lh {} \;
df -i
Process Management
ps auxf
top
htop
pgrep -la nginx
pstree -p
kill '<pid>'
kill -9 '<pid>'
pkill nginx
lsof -p '<pid>'
ss -tlnp | grep :80
lsof -i :80
nohup /opt/myapp/start.sh > /var/log/myapp.log 2>&1 &
systemd-run --scope -p CPUQuota=25% --unit=limit-myapp /opt/myapp/start.sh
Cron Job Management
crontab -e
crontab -l
30 2 * * * /usr/local/bin/backup.sh >> /var/log/backup.log 2>&1
0 0 * * 0 /usr/local/bin/cleanup.sh
*/5 * * * * /usr/local/bin/healthcheck.sh
ls /etc/cron.daily/
ls /etc/cron.weekly/
echo "deploy" >> /etc/cron.allow
Log Management
journalctl -u nginx -f
journalctl -b
journalctl --since "2025-01-15 08:00" --until "2025-01-15 12:00"
journalctl -p err
tail -f /var/log/syslog
tail -f /var/log/messages
dmesg -T
dmesg --level=err,warn
du -sh /var/log/*
cat <<'EOF' > /etc/logrotate.d/myapp
/var/log/myapp/*.log {
daily
missingok
rotate 14
compress
delaycompress
notifempty
create 0640 myapp myapp
sharedscripts
postrotate
systemctl reload myapp > /dev/null 2>&1 || true
endscript
}
EOF
logrotate -f /etc/logrotate.d/myapp
Networking Essentials
ping -c 4 8.8.8.8
dig example.com
nslookup example.com
traceroute example.com
ss -tlnp
ss -tunap
ufw allow 22/tcp
ufw allow 80/tcp
ufw allow 443/tcp
ufw enable
ufw status verbose
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload
firewall-cmd --list-all
Troubleshooting
| Symptom | Diagnostic Command | Common Fix |
|---|
| Disk full | df -h and du -sh /var/log/* | Clear old logs, run logrotate -f, remove temp files |
| Out of inodes | df -i | Delete many small files, check /tmp and mail spools |
| High CPU usage | top, ps aux --sort=-%cpu | Identify and restart or kill the offending process |
| High memory / swapping | free -h, vmstat 1 | Tune vm.swappiness, add RAM, identify memory leak |
| Service won't start | systemctl status <svc>, journalctl -u <svc> | Check config syntax, file permissions, port conflicts |
| DNS resolution fails | dig @8.8.8.8 example.com, cat /etc/resolv.conf | Fix nameserver entries, restart systemd-resolved |
| Package dependency error | apt --fix-broken install or pacman -Syu | Resolve held or conflicting packages |
| SSH connection refused | ss -tlnp | grep 22, systemctl status sshd | Ensure sshd is running and firewall allows port 22 |
Related Skills
ssh-configuration -- Secure remote access to Linux servers
user-management -- Create and manage users, groups, and sudo
systemd-services -- Write and manage systemd unit files
performance-tuning -- Kernel and application performance optimization
backup-recovery -- Protect server data with automated backups