Disk space, inodes and filesystems
๐ฅ Learn this hands-on with DevOps Shack โ YouTube @devopsshack ยท Hindi @shackverse ยท Courses at devopsshack.com
Q1 Writes fail with No space left on device, but df -h shows the filesystem is only 40% used.
Intermediate
No space left on device, but df -h shows the filesystem is only 40% used.Likely causes โ Inodes are exhausted (millions of tiny files), or you're looking at the wrong mount.
Diagnose โ
df -i /var # IUse% at 100%?
sudo find /var -xdev -type f | cut -d/ -f2-4 | sort | uniq -c | sort -rn | head
df -h "$(dirname /path/that/fails)"Fix โ Delete the small-file pile (session files, mail queue, cache dirs) with find <dir> -type f -mtime +7 -delete. If ext4 legitimately needs more inodes, it must be reformatted with -i/-N, or move the data to XFS.
Prevent โ Alert on df -i as well as df -h; set cleanup for session/cache directories.
Q2 df -h shows / at 100%, but du -sh / only adds up to 12 GB on a 50 GB disk.
Intermediate
df -h shows / at 100%, but du -sh / only adds up to 12 GB on a 50 GB disk.Likely causes โ A deleted file is still held open by a process (often a log deleted with rm while the app writes to it), or data is hidden under a mount point.
Diagnose โ
sudo lsof -nP +L1 | sort -k7 -n | tail # NLINK 0 = deleted but open
sudo lsof -nP | grep '(deleted)'Fix โ Restart or reload the process holding the file so it releases it. If you can't restart, truncate through the fd: sudo truncate -s 0 /proc/<PID>/fd/<FD>.
Prevent โ Rotate logs with logrotate (postrotate signal or copytruncate), never rm active logs.
Q3 du and df disagree by 20 GB and lsof +L1 shows nothing. What else could hide the space?
Advanced
du and df disagree by 20 GB and lsof +L1 shows nothing. What else could hide the space?Likely causes โ Files written into a directory before a filesystem was mounted on top of it, reserved blocks, or snapshot/metadata space.
Diagnose โ
sudo mkdir /mnt/rootonly
sudo mount --bind / /mnt/rootonly
sudo du -xsh /mnt/rootonly/{var,data,srv,mnt} 2>/dev/null
sudo tune2fs -l /dev/nvme0n1p1 | grep -i 'reserved block'Fix โ Delete or move the hidden files seen through the bind mount, then umount /mnt/rootonly. For a data disk, reduce reserved blocks: tune2fs -m 1 /dev/sdb1.
Prevent โ Use nofail and monitor that data mounts are actually mounted, so apps don't silently write to root.
Q4 A cron job that runs rm /var/spool/app/* fails with /bin/rm: Argument list too long.
Beginner
rm /var/spool/app/* fails with /bin/rm: Argument list too long.Likely causes โ The glob expands to more arguments than ARG_MAX allows.
Diagnose โ
getconf ARG_MAX
find /var/spool/app -maxdepth 1 -type f | wc -lFix โ find /var/spool/app -maxdepth 1 -type f -delete, or find ... -print0 | xargs -0 rm.
Prevent โ Use find in scripts for anything that can grow; clean the directory more often.
Q5 touch /data/test returns touch: cannot touch '/data/test': Read-only file system.
Beginner
touch /data/test returns touch: cannot touch '/data/test': Read-only file system.Likely causes โ The kernel remounted it read-only after I/O or filesystem errors (errors=remount-ro), it was mounted ro, or the underlying device is read-only (EBS issue, snapshot).
Diagnose โ
findmnt /data
dmesg -T | grep -Ei 'EXT4-fs error|XFS|I/O error|remount'
sudo smartctl -H /dev/sdb 2>/dev/nullFix โ If it was a mount option, mount -o remount,rw /data. If errors caused it: stop apps, unmount, run e2fsck -f or xfs_repair, then mount again. Replace the disk if errors are hardware.
Prevent โ Alert on filesystem errors in kernel logs and on SMART health.
Q6 After a power failure, mounting an XFS volume fails with mount: /data: wrong fs type, bad option, bad superblock on /dev/sdb1.
Intermediate
mount: /data: wrong fs type, bad option, bad superblock on /dev/sdb1.Likely causes โ Corrupted log/superblock, wrong device name, or the XFS log needs replay.
Diagnose โ
lsblk -f
sudo blkid /dev/sdb1
dmesg -T | tail -30
sudo xfs_repair -n /dev/sdb1 # dry runFix โ Mount once normally to replay the log; if it fails, run xfs_repair /dev/sdb1. Use xfs_repair -L (zero the log) only as a last resort, as it can lose recent changes. Take a snapshot first.
Prevent โ UPS/redundancy, and storage with write cache protection.
Q7 mount -a says mount: /backup: can't find UUID=3f1a... after someone recreated the filesystem.
Beginner
mount -a says mount: /backup: can't find UUID=3f1a... after someone recreated the filesystem.Likely causes โ mkfs generated a new UUID; fstab still has the old one.
Diagnose โ
sudo blkid
grep backup /etc/fstabFix โ Update fstab with the new UUID, then sudo systemctl daemon-reload && sudo mount -a.
Prevent โ Use labels (mkfs.xfs -L backup and LABEL=backup) when disks get recreated, and add nofail to non-critical mounts.
Q8 Disk filled up overnight and du points at /var/log/journal, which is 18 GB.
Beginner
du points at /var/log/journal, which is 18 GB.Likely causes โ No size limit on persistent journald, plus a chatty service logging in a loop.
Diagnose โ
journalctl --disk-usage
journalctl --since "1 hour ago" -o short | awk '{print $5}' | sort | uniq -c | sort -rn | headFix โ sudo journalctl --vacuum-size=1G, fix or quiet the noisy service, and set SystemMaxUse=1G in /etc/systemd/journald.conf, then systemctl restart systemd-journald.
Prevent โ Keep the size cap in your baseline; use RateLimitBurst/RateLimitIntervalSec against log storms.
Q9 /var/lib/docker keeps filling the root disk on a build host.
Beginner
/var/lib/docker keeps filling the root disk on a build host.Likely causes โ Dangling images, build cache and stopped containers accumulate.
Diagnose โ
docker system df -v
sudo du -sh /var/lib/docker/*Fix โ docker system prune -af --filter "until=72h" and docker builder prune -af. Move Docker's data root to a separate volume ("data-root": "/data/docker" in /etc/docker/daemon.json).
Prevent โ Scheduled prune job on build hosts and a dedicated volume for container data.
Q10 An NFS client shows df hanging forever, and the shell becomes unusable.
Intermediate
df hanging forever, and the shell becomes unusable.Likely causes โ An NFS server is unreachable and the mount is hard, so statfs() blocks in D state.
Diagnose โ
mount -t nfs,nfs4
df -h -x nfs -x nfs4 # works without touching NFS
rpcinfo -t nfsserver nfs 4 ; showmount -e nfsserver
ps -eo pid,stat,cmd | awk '$2 ~ /D/'Fix โ Restore the server or network. If the server is gone for good, umount -f -l /mnt/share.
Prevent โ Use autofs for rarely used shares; monitor NFS servers; avoid NFS mounts on paths that system tools scan.
Q11 NFS-mounted files show owner nobody and chown fails with Operation not permitted.
Intermediate
nobody and chown fails with Operation not permitted.Likely causes โ NFSv4 ID mapping domain mismatch between client and server, or root_squash applying to root on the client.
Diagnose โ
grep -i domain /etc/idmapd.conf # on client and server
nfsidmap -l 2>/dev/null
cat /etc/exports # on serverFix โ Set the same Domain = example.internal in /etc/idmapd.conf on both, run nfsidmap -c, remount. Do ownership changes on the server, or use no_root_squash only where truly required.
Prevent โ Central identity with matching UIDs; consistent idmapd config in your baseline.
Q12 xfs_growfs /data fails with xfs_growfs: /data is not a mounted XFS filesystem right after lvextend.
Beginner
xfs_growfs /data fails with xfs_growfs: /data is not a mounted XFS filesystem right after lvextend.Likely causes โ You passed the device instead of the mount point on an older xfsprogs, the filesystem is ext4, or a typo in the path.
Diagnose โ
findmnt -no FSTYPE,SOURCE /data
lsblk -fFix โ For XFS: xfs_growfs /data (mount point). For ext4: resize2fs /dev/vg0/data. Next time use lvextend -r to resize both in one step.
Prevent โ Use lvextend -r in runbooks.
Q13 lvextend fails with Insufficient free space: 2560 extents needed, but only 0 available.
Beginner
lvextend fails with Insufficient free space: 2560 extents needed, but only 0 available.Likely causes โ The volume group has no free extents.
Diagnose โ
sudo vgs
sudo pvs
lsblkFix โ Add a disk (pvcreate, vgextend), or grow the existing PV after enlarging the disk (growpart then pvresize /dev/sda2), then retry lvextend -r.
Prevent โ Leave headroom in the VG and alert on vg_free.
Q14 A disk shows up in lsblk but pvcreate says Cannot use /dev/sdc: device is partitioned.
Intermediate
lsblk but pvcreate says Cannot use /dev/sdc: device is partitioned.Likely causes โ Leftover partition table or filesystem signatures from a previous use.
Diagnose โ
lsblk -f /dev/sdc
sudo wipefs /dev/sdcFix โ After confirming the disk is really unused: sudo wipefs -a /dev/sdc, then pvcreate /dev/sdc.
Prevent โ Wipe disks when decommissioning; always double-check the device name before wiping.
Q15 ls on a directory prints ls: cannot access 'file': Input/output error and dmesg shows blk_update_request: I/O error, dev sda, sector ....
Advanced
ls on a directory prints ls: cannot access 'file': Input/output error and dmesg shows blk_update_request: I/O error, dev sda, sector ....Likely causes โ Failing disk (bad sectors), controller or cable fault, or a cloud volume impairment.
Diagnose โ
dmesg -T | grep -Ei 'I/O error|medium|reset'
sudo smartctl -a /dev/sda | grep -Ei 'Reallocated|Pending|Uncorrectable'
cat /proc/mdstatFix โ Copy off readable data immediately (ddrescue /dev/sda /mnt/new/sda.img /mnt/new/map for a failing disk). Replace the disk or restore the volume from snapshot, then fsck the copy.
Prevent โ RAID or replicated storage, SMART monitoring, tested backups.
Q16 An LVM snapshot used for backups suddenly shows Invalid and the backup failed.
Intermediate
Invalid and the backup failed.Likely causes โ The snapshot's copy-on-write space filled because the origin changed more than expected.
Diagnose โ
sudo lvs -o lv_name,origin,data_percent,lv_attr
dmesg | grep -i snapshotFix โ Remove it (lvremove) and create a bigger one (-L sized to the change rate during the backup), or enable autoextend: snapshot_autoextend_threshold = 70 and snapshot_autoextend_percent = 20 in /etc/lvm/lvm.conf.
Prevent โ Keep snapshots short-lived and monitor data_percent.
Q17 A swap file won't activate: swapon: /swapfile: insecure permissions 0644, 0600 suggested followed by swapon failed: Invalid argument.
Intermediate
swapon: /swapfile: insecure permissions 0644, 0600 suggested followed by swapon failed: Invalid argument.Likely causes โ The permissions warning is cosmetic; Invalid argument usually means the file has holes (created with fallocate on a filesystem that doesn't support it for swap, like older XFS or btrfs) or wasn't mkswaped.
Diagnose โ
ls -l /swapfile; file /swapfile
findmnt -no FSTYPE /Fix โ
sudo swapoff /swapfile 2>/dev/null; sudo rm /swapfile
sudo dd if=/dev/zero of=/swapfile bs=1M count=4096
sudo chmod 600 /swapfile && sudo mkswap /swapfile && sudo swapon /swapfileOn btrfs use btrfs filesystem mkswapfile.
Prevent โ Use dd for swap files in scripts that must work on any filesystem.
Q18 rm -rf on a directory reports Directory not empty even though ls -la shows nothing inside.
Advanced
rm -rf on a directory reports Directory not empty even though ls -la shows nothing inside.Likely causes โ Something is mounted inside it, a process keeps creating files, or (on NFS) .nfsXXXX silly-rename files for files still open on a client.
Diagnose โ
findmnt -R /path/dir
ls -la /path/dir; sudo lsof +D /path/dirFix โ Unmount nested mounts, stop the writing process, or close the files on the NFS client (the .nfs* files disappear afterwards). Then retry.
Prevent โ Stop services before cleanup; avoid deleting files still in use on NFS.
Q19 A file can't be deleted even by root: rm: cannot remove 'resolv.conf': Operation not permitted.
Beginner
rm: cannot remove 'resolv.conf': Operation not permitted.Likely causes โ The immutable (i) or append-only (a) attribute is set.
Diagnose โ
lsattr /etc/resolv.confFix โ sudo chattr -i /etc/resolv.conf, make the change, then re-apply if that was intentional.
Prevent โ Document when you set chattr +i; config tools fail strangely when they hit immutable files.
Q20 A database server shows EXT4-fs warning: ext4_dx_add_entry: Directory index full! and inserts start failing.
Advanced
EXT4-fs warning: ext4_dx_add_entry: Directory index full! and inserts start failing.Likely causes โ A single directory has reached the ext4 htree limit (millions of entries).
Diagnose โ
dmesg -T | grep -i 'index full'
sudo find /data -xdev -type d -exec sh -c 'echo "$(ls -f "$1" | wc -l) $1"' _ {} \; | sort -rn | head
sudo tune2fs -l /dev/sdb1 | grep featuresFix โ Move files into subdirectories. On newer kernels you can enable large_dir: tune2fs -O large_dir /dev/sdb1 (check kernel and e2fsprogs support first).
Prevent โ Application-level directory sharding; alert on directory entry counts.
Q21 After restoring files from a tar backup, the app fails because every file is owned by root.
Beginner
root.Likely causes โ The archive was extracted as a non-root user (ownership dropped) or with --no-same-owner, or the UIDs differ on the new host.
Diagnose โ
tar -tvzf backup.tgz | head
ls -ln /srv/app | head
getent passwd appFix โ Re-extract as root with tar --same-owner -xpzf backup.tgz, or chown -R app:app /srv/app. Use --numeric-owner when UIDs matter more than names.
Prevent โ Back up and restore as root with -p (preserve permissions), and keep UIDs consistent.
Q22 An app logs Disk quota exceeded but df shows plenty of space.
Beginner
Disk quota exceeded but df shows plenty of space.Likely causes โ The app's user or group has reached its quota.
Diagnose โ
sudo quota -u appuser
sudo repquota -a # ext4
sudo xfs_quota -x -c 'report -h' /home # XFSFix โ Clean up the user's files or raise the limit with setquota / xfs_quota -x -c 'limit bhard=20g appuser'.
Prevent โ Warn on soft-limit breaches before the hard limit hits.
Q23 Mounting a disk cloned from another server fails: mount: /mnt/clone: wrong fs type ... and dmesg says XFS (nvme1n1p1): Filesystem has duplicate UUID.
Intermediate
mount: /mnt/clone: wrong fs type ... and dmesg says XFS (nvme1n1p1): Filesystem has duplicate UUID.Likely causes โ The clone has the same XFS UUID as a mounted filesystem (common when mounting a snapshot of the root volume on the same instance).
Diagnose โ
sudo blkid
dmesg -T | tailFix โ Mount with -o nouuid for a temporary mount, or give it a new UUID permanently: sudo xfs_admin -U generate /dev/nvme1n1p1.
Prevent โ Use nouuid in rescue runbooks.
Q24 Disk usage on /tmp keeps growing and du shows a few huge files named like /tmp/php* or /tmp/sort*.
Intermediate
/tmp keeps growing and du shows a few huge files named like /tmp/php* or /tmp/sort*.Likely causes โ Applications or tools (sort, uploads, DB temp files) writing big temp files and not cleaning up, or crashing mid-way.
Diagnose โ
sudo du -ah /tmp | sort -h | tail
sudo lsof +D /tmp | head
systemctl status systemd-tmpfiles-clean.timerFix โ Remove files not held open; set TMPDIR for big jobs to a dedicated volume.
Prevent โ Make sure systemd-tmpfiles-clean.timer runs with an age rule (/usr/lib/tmpfiles.d/tmp.conf), or mount /tmp as size-limited tmpfs.
Q25 A RAID 1 array reports [U_] in /proc/mdstat and the server is slow.
Advanced
[U_] in /proc/mdstat and the server is slow.Likely causes โ One mirror member failed or dropped out; the array may also be resyncing, which consumes I/O.
Diagnose โ
cat /proc/mdstat
sudo mdadm --detail /dev/md0
dmesg -T | grep -Ei 'md0|raid1|sd[a-z]'
sudo smartctl -a /dev/sdbFix โ Replace the failed disk and mdadm /dev/md0 --add /dev/sdX. If a member just dropped out but is healthy, re-add it: mdadm /dev/md0 --re-add /dev/sdb1. Limit resync impact with echo 50000 > /proc/sys/dev/raid/speed_limit_max.
Prevent โ mdmonitor with email alerts; a write-intent bitmap (mdadm --grow --bitmap=internal /dev/md0) for faster resyncs.
Permissions, ownership, SELinux and mounts
๐ฅ Learn this hands-on with DevOps Shack โ YouTube @devopsshack ยท Hindi @shackverse ยท Courses at devopsshack.com
Q26 nginx returns 403 and logs open() "/srv/www/index.html" failed (13: Permission denied), even after chmod -R 777 /srv/www.
Intermediate
open() "/srv/www/index.html" failed (13: Permission denied), even after chmod -R 777 /srv/www.Likely causes โ SELinux is denying access because the files have the wrong context (default_t or user_home_t instead of httpd_sys_content_t), or a parent directory lacks x for nginx.
Diagnose โ
getenforce
ls -Z /srv/www/index.html
sudo ausearch -m AVC -ts recent | grep nginx
namei -l /srv/www/index.html # permissions on every path componentFix โ
sudo semanage fcontext -a -t httpd_sys_content_t '/srv/www(/.*)?'
sudo restorecon -Rv /srv/www
sudo chmod -R u=rwX,go=rX /srv/www # undo the 777Prevent โ Use standard paths (/var/www) or register custom paths with semanage fcontext in config management.
Q27 A script fails with bash: ./deploy.sh: Permission denied even though ls -l shows -rwxr-xr-x.
Beginner
bash: ./deploy.sh: Permission denied even though ls -l shows -rwxr-xr-x.Likely causes โ The filesystem is mounted with noexec (common on /tmp, /home or USB/NFS mounts).
Diagnose โ
findmnt -no OPTIONS --target ./deploy.shFix โ Run it through the interpreter (bash ./deploy.sh), or move it to a filesystem without noexec. Don't drop noexec from /tmp just for this.
Prevent โ Keep scripts in /opt or /usr/local/bin; set TMPDIR for installers that execute from /tmp.
Q28 A script fails with /bin/bash^M: bad interpreter: No such file or directory.
Beginner
/bin/bash^M: bad interpreter: No such file or directory.Likely causes โ Windows CRLF line endings; the kernel looks for an interpreter literally named bash\r.
Diagnose โ
file deploy.sh # "with CRLF line terminators"
head -1 deploy.sh | cat -AFix โ sed -i 's/\r$//' deploy.sh or dos2unix deploy.sh.
Prevent โ Add *.sh text eol=lf to .gitattributes and a pre-commit check.
Q29 A user gets -bash: cd: /srv/project: Permission denied although they're in the group that owns /srv/project (mode 770).
Beginner
-bash: cd: /srv/project: Permission denied although they're in the group that owns /srv/project (mode 770).Likely causes โ Their current session was started before they were added to the group, or a parent directory blocks traversal.
Diagnose โ
id # in their session
id alice # from the database
namei -l /srv/projectFix โ Log out and back in (or newgrp devteam). Add x for the group on parent directories if missing.
Prevent โ Tell users group changes need a new login; restart services after adding service users to groups.
Q30 Apache can't connect to a backend: AH00957: HTTP: attempt to connect to 127.0.0.1:8080 (localhost) failed and ausearch shows denied { name_connect }.
Intermediate
AH00957: HTTP: attempt to connect to 127.0.0.1:8080 (localhost) failed and ausearch shows denied { name_connect }.Likely causes โ SELinux blocks httpd_t from making outbound network connections by default.
Diagnose โ
sudo ausearch -m AVC -c httpd -ts recent
getsebool httpd_can_network_connectFix โ sudo setsebool -P httpd_can_network_connect on (or the narrower httpd_can_network_relay). If the backend port is unusual, label it: semanage port -a -t http_port_t -p tcp 8080 (8080 is usually already http_cache_port_t, which is allowed).
Prevent โ Include required SELinux booleans in the role that deploys the reverse proxy.
Q31 A service fails to bind to a custom port: bind() to 0.0.0.0:8888 failed (13: Permission denied) while running as root.
Intermediate
bind() to 0.0.0.0:8888 failed (13: Permission denied) while running as root.Likely causes โ SELinux only allows the service's domain to bind ports with specific labels.
Diagnose โ
sudo ausearch -m AVC -ts recent | grep name_bind
sudo semanage port -l | grep -w 8888Fix โ sudo semanage port -a -t http_port_t -p tcp 8888 (use the type matching the service), then restart.
Prevent โ Prefer standard ports or label custom ones in automation.
Q32 Files moved with mv from a home directory into /var/www/html give 403 errors, but files created there directly work.
Intermediate
mv from a home directory into /var/www/html give 403 errors, but files created there directly work.Likely causes โ mv keeps the original SELinux context (user_home_t); cp creates new files with the destination's context.
Diagnose โ
ls -Z /var/www/html
matchpathcon /var/www/html/page.htmlFix โ sudo restorecon -Rv /var/www/html.
Prevent โ Deploy with cp, rsync or packages, or run restorecon as part of deployment.
Q33 After restoring /etc/shadow from backup on an SELinux system, nobody can log in and logs show pam_unix(sshd:auth): authentication failure.
Advanced
/etc/shadow from backup on an SELinux system, nobody can log in and logs show pam_unix(sshd:auth): authentication failure.Likely causes โ The restored file has the wrong SELinux label (or wrong mode), so login processes can't read it.
Diagnose โ From console or rescue:
ls -lZ /etc/shadow # expect ---------- root root system_u:object_r:shadow_t
sudo ausearch -m AVC -ts today | grep shadowFix โ restorecon -v /etc/shadow and chmod 000 /etc/shadow (RHEL) or 640 root:shadow (Debian). If you can't log in at all, boot with rd.break or rescue media, fix the file and touch /.autorelabel.
Prevent โ Restore system files with tools that keep xattrs (tar --selinux, rsync -X) and always run restorecon after.
Q34 A container with a bind mount gets Permission denied reading files on a RHEL/Fedora host, even with matching UIDs.
Intermediate
Permission denied reading files on a RHEL/Fedora host, even with matching UIDs.Likely causes โ SELinux blocks the container (container_t) from host-labelled files.
Diagnose โ
ls -Z /srv/data
sudo ausearch -m AVC -ts recent | grep container_tFix โ Mount with a relabel flag: -v /srv/data:/data:Z (private) or :z (shared between containers). Don't use :Z on system directories like /home or /etc.
Prevent โ Keep container data in dedicated directories labelled container_file_t.
Q35 sudo -u app touch /var/log/app/x.log works, but the app itself (running as app under systemd) gets EACCES on the same path.
Advanced
sudo -u app touch /var/log/app/x.log works, but the app itself (running as app under systemd) gets EACCES on the same path.Likely causes โ systemd sandboxing: ProtectSystem=strict makes /var read-only unless listed in ReadWritePaths=, or ProtectHome, PrivateTmp, or an SELinux domain differs between the shell and the service.
Diagnose โ
systemctl show app -p ProtectSystem -p ReadWritePaths -p ProtectHome
systemctl cat app
sudo ausearch -m AVC -ts recentFix โ Add ReadWritePaths=/var/log/app (or LogsDirectory=app, which creates and permits /var/log/app), then daemon-reload and restart.
Prevent โ Use StateDirectory=, LogsDirectory=, RuntimeDirectory= instead of hand-made directories.
Q36 An upload directory is set 2775 and owned by group web, but new files still get the user's primary group.
Intermediate
2775 and owned by group web, but new files still get the user's primary group.Likely causes โ Files are moved in (keep their group) rather than created there, or the app sets the group explicitly, or the directory was replaced by a deploy without setgid.
Diagnose โ
stat -c '%A %U:%G %n' /srv/uploads
ls -l /srv/uploads | headFix โ Re-apply chmod g+s /srv/uploads, chgrp -R web /srv/uploads; change the app to create files in place, or use a default ACL: setfacl -d -m g:web:rwX /srv/uploads.
Prevent โ Enforce directory modes in config management.
Q37 chmod on a file under /mnt/usb returns success but the permissions don't change.
Beginner
chmod on a file under /mnt/usb returns success but the permissions don't change.Likely causes โ The filesystem (FAT/exFAT/NTFS) doesn't store Unix permissions; they come from mount options.
Diagnose โ
findmnt -no FSTYPE,OPTIONS /mnt/usbFix โ Remount with the desired owner and mask: mount -o uid=1000,gid=1000,umask=022 /dev/sdb1 /mnt/usb.
Prevent โ Use ext4/XFS for anything needing Unix permissions.
Q38 Users can delete each other's files in a shared /srv/shared directory with mode 777.
Beginner
/srv/shared directory with mode 777.Likely causes โ Without the sticky bit, anyone with write on a directory can delete any file in it.
Diagnose โ
stat -c '%A' /srv/sharedFix โ chmod 1777 /srv/shared (or better, a group with 2770 + sticky: chmod 3770).
Prevent โ Use group-based shared dirs instead of world-writable ones.
Q39 An ACL was set with setfacl -m u:bob:rw file, but Bob still gets Permission denied writing to it.
Intermediate
setfacl -m u:bob:rw file, but Bob still gets Permission denied writing to it.Likely causes โ The ACL mask limits effective permissions (a later chmod reduced the mask), or Bob can't traverse a parent directory.
Diagnose โ
getfacl file # look for "#effective:r--"
namei -l /path/to/fileFix โ setfacl -m m::rw file to raise the mask, and give x on parent directories (setfacl -m u:bob:x /path /path/to).
Prevent โ Remember chmod g= changes the ACL mask on files with ACLs.
Q40 A setuid binary you built doesn't run as root: it still runs with the caller's UID.
Advanced
Likely causes โ The filesystem is mounted nosuid, the binary is a script (the kernel ignores setuid on scripts), or the owner isn't root.
Diagnose โ
ls -l /opt/tool/bin/helper # expect -rwsr-xr-x root
findmnt -no OPTIONS --target /opt/tool/bin/helper
file /opt/tool/bin/helperFix โ Avoid setuid entirely: use a narrow sudo rule or file capabilities (setcap cap_net_raw+ep helper). If setuid is really needed, place a compiled binary on a filesystem without nosuid.
Prevent โ Treat any setuid requirement as a security review item.
Q41 ping fails for normal users with ping: socket: Operation not permitted on a minimal image.
Intermediate
ping fails for normal users with ping: socket: Operation not permitted on a minimal image.Likely causes โ ping lost its file capability (cap_net_raw) when copied or installed by a tool that strips xattrs, and unprivileged ICMP sockets are disabled.
Diagnose โ
getcap /usr/bin/ping
sysctl net.ipv4.ping_group_rangeFix โ sudo setcap cap_net_raw+ep /usr/bin/ping, or allow ICMP sockets: sysctl -w net.ipv4.ping_group_range="0 2147483647" (persist in /etc/sysctl.d/). Reinstalling the iputils package also restores it.
Prevent โ Use image build tools that preserve xattrs (tar --xattrs).
Q42 A user's crontab edit fails with You (alice) are not allowed to use this program (crontab).
Beginner
You (alice) are not allowed to use this program (crontab).Likely causes โ /etc/cron.allow exists and doesn't list the user, or the user is in /etc/cron.deny.
Diagnose โ
ls -l /etc/cron.allow /etc/cron.deny
grep -w alice /etc/cron.allow /etc/cron.denyFix โ Add the user to cron.allow (or remove them from cron.deny) if policy allows.
Prevent โ Manage these files in config management with the approved user list.
Q43 AppArmor on Ubuntu blocks MySQL from using a new data directory: mysqld: Can't create/write to file '/data/mysql/...' (Errcode: 13).
Intermediate
mysqld: Can't create/write to file '/data/mysql/...' (Errcode: 13).Likely causes โ The usr.sbin.mysqld AppArmor profile only allows /var/lib/mysql.
Diagnose โ
sudo aa-status | grep mysqld
sudo journalctl -k | grep -i apparmor | grep DENIEDFix โ Add the path to /etc/apparmor.d/local/usr.sbin.mysqld:
/data/mysql/ r,
/data/mysql/** rwk,Then sudo apparmor_parser -r /etc/apparmor.d/usr.sbin.mysqld and restart MySQL. Or bind-mount /data/mysql onto /var/lib/mysql.
Prevent โ Use the local/ override files so package updates don't wipe your changes.
Q44 Writing to a file on an NFS mount fails with Permission denied for root, but works for the file owner.
Intermediate
Permission denied for root, but works for the file owner.Likely causes โ root_squash on the export maps client root to nobody.
Diagnose โ
cat /etc/exports # on the server
ls -ln /mnt/share/fileFix โ Perform the action as the owning user (sudo -u app ...), or use no_root_squash only for trusted admin hosts.
Prevent โ Run apps as consistent non-root UIDs across clients.
Q45 After a package update, an app can't read its key: Permission denied on /etc/pki/tls/private/app.key, and the mode looks right.
Advanced
Permission denied on /etc/pki/tls/private/app.key, and the mode looks right.Likely causes โ SELinux label on the key is wrong (it was copied from elsewhere, admin_home_t), or a policy update tightened rules for that domain.
Diagnose โ
ls -lZ /etc/pki/tls/private/app.key
matchpathcon /etc/pki/tls/private/app.key
sudo ausearch -m AVC -ts today -i | tailFix โ sudo restorecon -v /etc/pki/tls/private/app.key. If the denial is for a custom domain, add a reviewed local policy module (audit2allow -M appkey).
Prevent โ Place keys with install -m 600 -Z or run restorecon in the deploy step.
Q46 A shell script works when run with bash script.sh but fails with sh: 3: [[: not found from cron.
Beginner
bash script.sh but fails with sh: 3: [[: not found from cron.Likely causes โ Cron or a missing shebang runs it with /bin/sh (dash on Debian/Ubuntu), which doesn't support bash features.
Diagnose โ
head -1 script.sh
ls -l /bin/shFix โ Add #!/usr/bin/env bash as the first line and call the script directly, or set SHELL=/bin/bash in the crontab.
Prevent โ Run shellcheck and always include a shebang.
Q47 A file shows as owned by a numeric UID like 1003 instead of a username.
Beginner
1003 instead of a username.Likely causes โ The user was deleted, the files came from another system with a different UID mapping, or the identity service (SSSD/LDAP) is unreachable.
Diagnose โ
getent passwd 1003
systemctl status sssdFix โ Restore the identity service, recreate the user with that UID, or chown to the correct current user.
Prevent โ Use userdel with a file-ownership cleanup step; keep UIDs consistent across hosts.
Q48 sudo prints sudo: /etc/sudoers.d/ops is world writable and then fails.
Intermediate
sudo prints sudo: /etc/sudoers.d/ops is world writable and then fails.Likely causes โ A sudoers include file has unsafe permissions or ownership, so sudo refuses it.
Diagnose โ
ls -l /etc/sudoers /etc/sudoers.d/Fix โ As root (via pkexec, console, or another working sudo rule): chmod 0440 /etc/sudoers.d/ops && chown root:root /etc/sudoers.d/ops. Check syntax with visudo -c.
Prevent โ Deploy sudoers files with validate: visudo -cf %s and mode: 0440 in Ansible.
Q49 An application running as a non-root user can't write core dumps or create files larger than 1 GB: File size limit exceeded (core dumped).
Advanced
File size limit exceeded (core dumped).Likely causes โ RLIMIT_FSIZE is set (via /etc/security/limits.conf fsize, shell ulimit -f, or the systemd unit LimitFSIZE=).
Diagnose โ
cat /proc/<PID>/limits | grep -i 'file size'
grep -r fsize /etc/security/limits.conf /etc/security/limits.d/
systemctl show app -p LimitFSIZEFix โ Remove or raise the limit in the right place (LimitFSIZE=infinity for systemd services; limits.conf only applies to PAM sessions), then restart.
Prevent โ Know that systemd services ignore limits.conf; set limits in the unit.
Q50 After mounting a new volume over /var/www/uploads, the app can no longer write there.
Intermediate
/var/www/uploads, the app can no longer write there.Likely causes โ The new filesystem's root directory is owned by root:root with 755, hiding the old directory's ownership; on SELinux hosts the new mount root has the wrong label.
Diagnose โ
ls -ldZ /var/www/uploads
findmnt /var/www/uploadsFix โ chown www-data:www-data /var/www/uploads (on the mounted FS), set the mode, and restorecon -Rv /var/www/uploads.
Prevent โ Include ownership and labels in the step that adds a mount.
Processes, memory and OOM
๐ฅ Learn this hands-on with DevOps Shack โ YouTube @devopsshack ยท Hindi @shackverse ยท Courses at devopsshack.com
Q51 A Java service disappears without an error in its own log. dmesg shows Out of memory: Killed process 4121 (java) total-vm:... anon-rss:....
Beginner
dmesg shows Out of memory: Killed process 4121 (java) total-vm:... anon-rss:....Likely causes โ The kernel OOM killer picked the biggest process when the host (or its cgroup) ran out of memory.
Diagnose โ
dmesg -T | grep -Ei 'out of memory|oom-kill|killed process'
journalctl -k -b | grep -i oom
free -h; ps aux --sort=-rss | headFix โ Find out who used the memory (the OOM report lists every process's RSS). Size the JVM heap to fit (-Xmx well below RAM, leaving room for metaspace, threads and the OS), add RAM, or move other workloads off.
Prevent โ Alert on memory available and on oom_kill counters (/proc/vmstat), and set per-service memory limits.
Q52 A service gets killed with Memory cgroup out of memory: Killed process ... but the host has 20 GB free.
Intermediate
Memory cgroup out of memory: Killed process ... but the host has 20 GB free.Likely causes โ The service's cgroup limit (MemoryMax= in systemd or a container limit) was reached, not host memory.
Diagnose โ
systemctl show app -p MemoryMax -p MemoryCurrent -p MemoryPeak
cat /sys/fs/cgroup/system.slice/app.service/memory.events # oom_kill countFix โ Raise the limit if the usage is legitimate, or fix the leak. Use MemoryHigh= slightly below MemoryMax= to throttle before killing.
Prevent โ Track memory.current against the limit per service.
Q53 ps shows dozens of processes in state Z with <defunct>.
Beginner
ps shows dozens of processes in state Z with <defunct>.Likely causes โ Zombie processes: children have exited, but the parent hasn't called wait() to reap them.
Diagnose โ
ps -eo pid,ppid,stat,cmd | awk '$3 ~ /Z/'
ps -o pid,cmd -p <PPID>Fix โ You can't kill a zombie; it's already dead. Signal the parent (kill -CHLD <PPID>) or restart the parent; once the parent exits, PID 1 adopts and reaps the zombies.
Prevent โ Fix the parent's child handling; in containers use an init like tini (docker run --init).
Q54 Zombie count keeps climbing into the thousands and new processes fail with fork: Resource temporarily unavailable.
Advanced
fork: Resource temporarily unavailable.Likely causes โ Zombies hold PIDs; the user or system has hit pids.max, ulimit -u (nproc), or kernel.pid_max.
Diagnose โ
ps -eo stat | grep -c Z
cat /proc/sys/kernel/pid_max
ulimit -u
systemctl show app -p TasksMax -p TasksCurrentFix โ Restart the parent that isn't reaping (frees all its zombies at once). Temporarily raise TasksMax= or nproc only if the load is legitimate.
Prevent โ Fix the reaping bug; alert on zombie count and task counts per service.
Q55 An app crashes under load with java.io.IOException: Too many open files (or EMFILE).
Beginner
java.io.IOException: Too many open files (or EMFILE).Likely causes โ The process hit its open-file limit (RLIMIT_NOFILE), often 1024 by default, or it's leaking file descriptors/sockets.
Diagnose โ
cat /proc/<PID>/limits | grep 'open files'
ls /proc/<PID>/fd | wc -l
sudo lsof -p <PID> | awk '{print $5}' | sort | uniq -c | sort -rn | headFix โ For a systemd service, set LimitNOFILE=65536 in a drop-in, daemon-reload and restart. If the count grows forever, fix the leak (unclosed sockets/files).
Prevent โ Monitor fd count vs limit per process.
Q56 You raised nofile in /etc/security/limits.conf to 65536, but the service still shows Max open files 1024.
Intermediate
nofile in /etc/security/limits.conf to 65536, but the service still shows Max open files 1024.Likely causes โ limits.conf is applied by PAM to login sessions; systemd services don't go through PAM.
Diagnose โ
systemctl show app -p LimitNOFILE
cat /proc/$(systemctl show -p MainPID --value app)/limits | grep 'open files'Fix โ
sudo systemctl edit app
# [Service]
# LimitNOFILE=65536
sudo systemctl restart appPrevent โ Set limits in unit files; use DefaultLimitNOFILE= in /etc/systemd/system.conf for a host-wide default.
Q57 The whole host can't open files: VFS: file-max limit 98304 reached in dmesg.
Advanced
VFS: file-max limit 98304 reached in dmesg.Likely causes โ The system-wide file handle limit was reached, usually by one leaking process.
Diagnose โ
cat /proc/sys/fs/file-nr # allocated unused max
for p in /proc/[0-9]*; do echo "$(ls $p/fd 2>/dev/null | wc -l) $(cat $p/comm 2>/dev/null)"; done | sort -rn | headFix โ Restart the leaking process. Raise the limit if needed: sysctl -w fs.file-max=2097152, persisted in /etc/sysctl.d/.
Prevent โ Alert on file-nr usage; set per-service LimitNOFILE so one process can't take everything.
Q58 kill -9 <PID> doesn't kill a process; it stays in state D.
Intermediate
kill -9 <PID> doesn't kill a process; it stays in state D.Likely causes โ The process is in uninterruptible sleep, waiting on I/O in the kernel (dead NFS server, failing disk, hung storage driver). Signals are only delivered when it leaves that state.
Diagnose โ
ps -o pid,stat,wchan:32,cmd -p <PID>
sudo cat /proc/<PID>/stack
dmesg -T | grep -Ei 'hung_task|blocked for more than'Fix โ Fix what it's waiting on: restore the NFS server, umount -f the dead mount, or replace the failing device. If the kernel is stuck, a reboot is the only option.
Prevent โ Monitor storage and NFS health; avoid hard NFS mounts on critical paths.
Q59 A process ignores kill <PID> (SIGTERM) and keeps running.
Beginner
kill <PID> (SIGTERM) and keeps running.Likely causes โ The process catches or ignores SIGTERM, is busy in a long shutdown, or you're signalling a wrapper and not the real worker.
Diagnose โ
grep -E 'SigCgt|SigIgn' /proc/<PID>/status
pstree -p <PID>Fix โ Wait for graceful shutdown; check the app's logs. If it's truly stuck, kill -KILL <PID>. For process trees, signal the group: kill -TERM -- -<PGID>.
Prevent โ Make apps handle SIGTERM properly; in containers, make the app PID 1 or use exec in entrypoint scripts.
Q60 The server has 64 GB RAM, free shows only 2 GB free, and the team wants to add RAM.
Beginner
free shows only 2 GB free, and the team wants to add RAM.Likely causes โ Page cache is using the rest, which is normal.
Diagnose โ
free -h # check "available"
cat /proc/pressure/memory # some/full stall percentages
vmstat 1 5 # si/so swap activityFix โ Nothing, if available is healthy and there's no swapping or memory pressure.
Prevent โ Alert on MemAvailable and PSI, never on "free".
Q61 Memory usage keeps climbing but no process in top shows high RSS.
Advanced
top shows high RSS.Likely causes โ Kernel memory: slab caches (dentries/inodes from millions of files), a leaking kernel module, tmpfs/shm usage, or huge pages reserved.
Diagnose โ
grep -E 'Slab|SReclaimable|SUnreclaim|Shmem|HugePages_Total|Hugetlb' /proc/meminfo
sudo slabtop -o | head -20
df -h -t tmpfsFix โ Shmem: clean up /dev/shm or tmpfs files. Large SReclaimable dentry cache is reclaimable under pressure (test with echo 2 > /proc/sys/vm/drop_caches, don't schedule it). Growing SUnreclaim suggests a kernel/driver leak: update the kernel or driver.
Prevent โ Graph slab and shmem in monitoring, not just process RSS.
Q62 A Node.js process crashes with FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory.
Intermediate
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory.Likely causes โ V8's heap limit was reached (default depends on version and available memory), not the OS limit; or a leak.
Diagnose โ
node -e 'console.log(v8.getHeapStatistics().heap_size_limit/1024/1024)'
ps -o rss,cmd -p <PID>Fix โ Raise the heap if usage is legitimate: NODE_OPTIONS=--max-old-space-size=3072, keeping it below the container/cgroup limit. Take heap snapshots (--heapsnapshot-near-heap-limit=2) to find leaks.
Prevent โ Align runtime heap limits with cgroup limits; monitor heap usage.
Q63 A server becomes unresponsive for minutes at a time and then recovers; vmstat during the event shows high si/so.
Intermediate
vmstat during the event shows high si/so.Likely causes โ Heavy swapping (thrashing): the working set exceeds RAM and the kernel spends its time moving pages.
Diagnose โ
vmstat 1
sar -W 1 5 # pswpin/s pswpout/s
for f in /proc/[0-9]*/status; do awk '/^Name|^VmSwap/{printf "%s ", $2} END{print ""}' $f; done | sort -k2 -n | tail
cat /proc/pressure/memoryFix โ Find the process pushing memory, reduce its footprint or limit it with MemoryHigh=. Add RAM if the workload legitimately needs it.
Prevent โ Use systemd-oomd or earlyoom to kill runaway processes before the host thrashes.
Q64 The OOM killer keeps killing sshd and the database instead of the leaking batch job.
Advanced
sshd and the database instead of the leaking batch job.Likely causes โ OOM victim selection is based on oom_score (memory use plus oom_score_adj); priorities aren't set.
Diagnose โ
for p in $(pgrep -d' ' 'sshd|postgres|batch'); do echo "$p $(cat /proc/$p/oom_score) $(cat /proc/$p/comm)"; doneFix โ Protect critical services in their units: OOMScoreAdjust=-900 for the DB and sshd (-1000 disables killing). Make the batch job preferred: OOMScoreAdjust=500 and cap it with MemoryMax=.
Prevent โ Every service gets a memory limit and an OOM priority in its unit.
Q65 A process runs much slower than on other identical hosts; top shows it at 100% in %st.
Intermediate
top shows it at 100% in %st.Likely causes โ CPU steal: the hypervisor is giving CPU time to other VMs (noisy neighbour, or burstable instance out of credits).
Diagnose โ
mpstat -P ALL 1 5 # %steal column
top # "st" in the Cpu(s) lineIn AWS check CPUCreditBalance for t-family instances.
Fix โ Move to a non-burstable instance type, enable unlimited mode, or migrate the VM (stop/start moves it to another host in many clouds).
Prevent โ Alert on steal time; avoid burstable instances for steady CPU workloads.
Q66 A process consumes a lot of CPU in sy (system) time instead of us (user).
Advanced
sy (system) time instead of us (user).Likely causes โ Too many syscalls (tiny reads/writes, busy polling), lock contention, page faults, or heavy context switching.
Diagnose โ
pidstat -u -w -p <PID> 1 5 # %system, cswch/s
sudo strace -c -f -p <PID> # syscall counts for a few seconds
sudo perf top -p <PID>Fix โ Depends on findings: bigger buffers, fewer threads, use epoll instead of polling loops, fix spin locks. Report the hot syscalls to devs.
Prevent โ Profile under load in staging; watch %sys in dashboards.
Q67 top shows a process using 400% CPU. Is it broken?
Beginner
top shows a process using 400% CPU. Is it broken?Likely causes โ top reports per-process CPU relative to a single core; 400% means four cores fully busy, normal for multi-threaded apps.
Diagnose โ
nproc
top -H -p <PID> # per-thread viewFix โ Nothing, if expected. If not, find hot threads with top -H and match TIDs to a thread dump (Java uses hex TIDs in jstack).
Prevent โ Normalise CPU metrics by core count in dashboards.
Q68 A command hangs forever, and strace -p shows it stuck on futex(...) or read(3, ...). How do you dig in?
Intermediate
strace -p shows it stuck on futex(...) or read(3, ...). How do you dig in?Likely causes โ Waiting on a lock held by another thread (futex), or blocked reading from a pipe, socket or file that never delivers.
Diagnose โ
ls -l /proc/<PID>/fd/3 # what is fd 3?
sudo lsof -p <PID> | grep ' 3'
sudo cat /proc/<PID>/stack
gdb -p <PID> -batch -ex 'thread apply all bt' # if debuginfo is availableFix โ If it's a socket, check the remote end (DB, API). If it's a lock, find the thread holding it from the backtrace. Add timeouts in the code.
Prevent โ Use timeouts for all network calls; capture thread dumps automatically on hang detection.
Q69 top shows load and CPU fine, but an app reports frequent java.lang.OutOfMemoryError: unable to create native thread.
Advanced
top shows load and CPU fine, but an app reports frequent java.lang.OutOfMemoryError: unable to create native thread.Likely causes โ Thread limits, not heap: TasksMax= of the systemd unit (default often 15% of pid_max or 4915 on some versions), ulimit -u, or pids.max in a container.
Diagnose โ
ls /proc/<PID>/task | wc -l
systemctl show app -p TasksMax -p TasksCurrent
cat /proc/<PID>/limits | grep processesFix โ Raise TasksMax= (or infinity) and LimitNPROC= in the unit if the thread count is legitimate; otherwise fix thread pool sizing.
Prevent โ Bound thread pools in the app; monitor task counts.
Q70 A binary fails with error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory.
Beginner
error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory.Likely causes โ The binary was built for another distro/version and the library version isn't installed (e.g. OpenSSL 1.1 vs 3 on newer distros).
Diagnose โ
ldd ./app | grep 'not found'
ldconfig -p | grep libsslFix โ Install the matching compat package if available, rebuild the binary for the current distro, or run it in a container with the right base image. Avoid symlinking libssl.so.3 to .so.1.1; ABIs differ.
Prevent โ Build artefacts on the same OS version you deploy to, or ship containers.
Q71 An app installed in /opt/app/lib can't find its own libraries even though they're there.
Intermediate
/opt/app/lib can't find its own libraries even though they're there.Likely causes โ /opt/app/lib isn't in the dynamic linker's search path, and the binary has no RPATH.
Diagnose โ
ldd /opt/app/bin/app
readelf -d /opt/app/bin/app | grep -Ei 'rpath|runpath'Fix โ Add /opt/app/lib to /etc/ld.so.conf.d/app.conf and run sudo ldconfig, or set Environment=LD_LIBRARY_PATH=/opt/app/lib in the service unit.
Prevent โ Package apps with proper RPATH or a wrapper script.
Q72 A process has been running for weeks and you need to know which config file and environment it started with.
Beginner
Likely causes โ Config may have changed on disk since start; you need the process's own view.
Diagnose โ
tr '\0' ' ' < /proc/<PID>/cmdline; echo
sudo tr '\0' '\n' < /proc/<PID>/environ
sudo ls -l /proc/<PID>/cwd /proc/<PID>/exe
sudo ls -l /proc/<PID>/fd | grep -E '\.conf|\.yml'Fix โ Compare with the current files; if they differ, plan a reload/restart.
Prevent โ Reload services after config changes via config management handlers.
Q73 A program crashes with Segmentation fault (core dumped) but you can't find the core file.
Intermediate
Segmentation fault (core dumped) but you can't find the core file.Likely causes โ systemd-coredump captures cores into the journal storage, or ulimit -c 0 disables them.
Diagnose โ
cat /proc/sys/kernel/core_pattern
coredumpctl list
ulimit -cFix โ coredumpctl info <PID> for the stack, coredumpctl debug <PID> to open in gdb, coredumpctl dump <PID> -o core.file to export.
Prevent โ Keep systemd-coredump storage limits (/etc/systemd/coredump.conf) sensible, and install debuginfo in staging.
Q74 After a deploy, a process uses far more memory than before, with high VSZ but normal RSS. Should you worry?
Beginner
VSZ but normal RSS. Should you worry?Likely causes โ VSZ counts reserved virtual address space (thread stacks, mmap'd files, allocator arenas), not real memory use.
Diagnose โ
ps -o pid,vsz,rss,cmd -p <PID>
sudo pmap -x <PID> | tail -5
grep -E 'VmRSS|RssAnon|RssFile' /proc/<PID>/statusFix โ Nothing, if RSS and PSS are stable. glibc arenas can inflate VSZ; MALLOC_ARENA_MAX=2 reduces it for many-threaded apps if needed.
Prevent โ Monitor RSS/PSS and cgroup memory.current, not VSZ.
Q75 A process is slow and perf or top shows it constantly page-faulting (majflt/s high in pidstat -r).
Advanced
perf or top shows it constantly page-faulting (majflt/s high in pidstat -r).Likely causes โ Memory pages are being read back from disk: swap-ins, or its memory-mapped files are being evicted from page cache because of memory pressure.
Diagnose โ
pidstat -r -p <PID> 1 5 # majflt/s
grep -E 'VmSwap' /proc/<PID>/status
cat /proc/pressure/memory /proc/pressure/ioFix โ Give the host or cgroup more memory, reduce other memory consumers, or protect the working set with MemoryLow= / MemoryMin= for that service.
Prevent โ Size hosts for the working set plus cache; watch major faults and PSI.
Load, CPU and I/O performance
๐ฅ Learn this hands-on with DevOps Shack โ YouTube @devopsshack ยท Hindi @shackverse ยท Courses at devopsshack.com
Q76 Load average is 35 on an 8-core server, but top shows CPU 85% idle.
Intermediate
top shows CPU 85% idle.Likely causes โ Linux load counts tasks in uninterruptible sleep (state D) as well as runnable ones. Many processes blocked on slow disk or NFS raise load without using CPU.
Diagnose โ
vmstat 1 5 # high "b" column and "wa"
ps -eo pid,stat,wchan:30,cmd | awk '$2 ~ /^D/'
iostat -xz 1 3 # %util, r_await/w_await
cat /proc/pressure/ioFix โ Find the blocked resource: a saturated disk (reduce I/O, move workload, faster volume), or a hung NFS mount (restore server, unmount). Load drops as soon as the blocked tasks complete.
Prevent โ Alert on I/O PSI and disk latency, not just load average.
Q77 top shows wa at 60% and the application is crawling.
Beginner
top shows wa at 60% and the application is crawling.Likely causes โ CPUs are idle waiting for disk I/O to complete; the disk is the bottleneck.
Diagnose โ
iostat -xz 1 5 # which device, %util, await
sudo iotop -oPa # which process
pidstat -d 1 5Fix โ Stop or throttle the heavy I/O process (ionice -c3 -p <PID>), move it off-peak, or upgrade storage (more IOPS/throughput).
Prevent โ Separate volumes for logs, data and backups; monitor disk await.
Q78 iostat shows a disk at %util 100 but throughput is only 5 MB/s.
Intermediate
iostat shows a disk at %util 100 but throughput is only 5 MB/s.Likely causes โ Random small I/O on a device with low IOPS (HDD or small cloud volume), or the cloud volume is throttled at its IOPS limit / out of burst credits.
Diagnose โ
iostat -xz 1 5 # r/s, w/s, rareq-sz, wareq-sz, aqu-szIn AWS check BurstBalance and VolumeQueueLength for gp2, or provisioned IOPS for gp3/io2.
Fix โ Move to a volume with more IOPS (gp3 with provisioned IOPS, NVMe), or reduce random I/O (batch writes, caching).
Prevent โ Size volumes for IOPS, not just capacity. Note %util is misleading on SSD/NVMe arrays that handle requests in parallel; prefer await and queue size.
Q79 CPU usage is moderate, but the app's latency doubled after moving to a larger VM with two NUMA nodes.
Advanced
Likely causes โ Memory accessed across NUMA nodes (remote memory is slower), or threads bouncing between sockets.
Diagnose โ
lscpu | grep -i numa
numactl --hardware
numastat -p <PID> # memory per node
perf stat -e cache-misses -p <PID> -- sleep 10Fix โ Pin the process and its memory to a node: numactl --cpunodebind=0 --membind=0 app, or run one instance per node. Check kernel.numa_balancing settings for your workload.
Prevent โ Test on the target instance type; for latency-sensitive services consider instances that fit in one NUMA node.
Q80 A server's CPU usage is 100% and top shows kworker or ksoftirqd at the top.
Advanced
top shows kworker or ksoftirqd at the top.Likely causes โ ksoftirqd high means the kernel is overwhelmed by soft interrupts, typically network packet processing (traffic flood, single queue NIC). kworker high can be I/O, a driver bug or ACPI issues.
Diagnose โ
mpstat -P ALL 1 3 # %soft per CPU, often one CPU at 100%
cat /proc/softirqs; watch -d -n1 'cat /proc/interrupts | head -30'
sar -n DEV 1 3
sudo perf top -gFix โ Spread interrupts across CPUs: enable multiple NIC queues (ethtool -L eth0 combined 8), run irqbalance, enable RPS/RFS. If it's an attack, filter upstream.
Prevent โ Use NICs/instances with multi-queue support; monitor softirq per CPU.
Q81 One CPU core sits at 100% while the others are idle, and the app can't go faster.
Intermediate
Likely causes โ A single-threaded app or a hot lock, or all network interrupts land on CPU0.
Diagnose โ
mpstat -P ALL 1 3 # is it %usr or %soft/%irq?
top -H -p <PID> # one hot thread?
cat /proc/interrupts | grep -E 'eth0|ens'Fix โ For app bottlenecks: run more processes/workers (e.g. nginx worker_processes auto, gunicorn workers). For IRQs: irqbalance or multi-queue NICs.
Prevent โ Load-test to find single-thread limits before production.
Q82 uptime shows load averages 0.5, 4.0, 12.0. What does that tell you?
Beginner
uptime shows load averages 0.5, 4.0, 12.0. What does that tell you?Likely causes โ The three numbers are 1, 5 and 15-minute averages; load was high and is now falling. The incident is ending.
Diagnose โ
uptime
sar -q -s 08:00:00 -e 09:30:00 # historical run queue from sysstat
journalctl --since "20 min ago" -p warningFix โ Find what ran in the past 15 minutes (cron, backup, deploy) using sar history and logs.
Prevent โ Keep sysstat collecting (systemctl enable --now sysstat) for after-the-fact analysis.
Q83 A server is slow and vmstat shows a high cs (context switches) value, 500k per second.
Advanced
vmstat shows a high cs (context switches) value, 500k per second.Likely causes โ Too many threads competing for CPUs, lock contention, or very chatty IPC/network patterns.
Diagnose โ
vmstat 1 5
pidstat -w 1 5 # cswch/s (voluntary) and nvcswch/s (involuntary) per process
ps -eLf | wc -l # total threadsFix โ High involuntary switches: too many runnable threads; reduce thread pools to near core count. High voluntary: threads blocking on locks or I/O; investigate contention.
Prevent โ Size thread pools deliberately; load test.
Q84 sar isn't available and you need historical CPU and disk data from last night's incident.
Beginner
sar isn't available and you need historical CPU and disk data from last night's incident.Likely causes โ sysstat isn't installed or the collector timer isn't enabled.
Diagnose โ
systemctl status sysstat sysstat-collect.timer
ls /var/log/sa/ /var/log/sysstat/ 2>/dev/nullFix โ For now, use other sources: monitoring (Prometheus/CloudWatch), journalctl for that window, dmesg -T. Install and enable sysstat: dnf install sysstat && systemctl enable --now sysstat.
Prevent โ Include sysstat and a metrics agent in the base image.
Q85 free shows plenty of memory, but dmesg shows page allocation failure: order:4 and network drivers fail.
Advanced
free shows plenty of memory, but dmesg shows page allocation failure: order:4 and network drivers fail.Likely causes โ Memory fragmentation: the kernel can't find enough contiguous pages for a high-order allocation, even with free memory available.
Diagnose โ
cat /proc/buddyinfo
dmesg -T | grep -i 'page allocation failure'
sysctl vm.min_free_kbytesFix โ Trigger compaction: echo 1 > /proc/sys/vm/compact_memory. Raise vm.min_free_kbytes moderately so the kernel keeps a reserve.
Prevent โ Tune min_free_kbytes on high-throughput network hosts, keep kernels and drivers updated.
Q86 Disk latency spikes every 30 seconds and the app stalls briefly.
Advanced
Likely causes โ Dirty page writeback bursts: the kernel accumulates writes in memory and flushes large batches, saturating the disk.
Diagnose โ
watch -n1 'grep -E "Dirty|Writeback" /proc/meminfo'
sysctl vm.dirty_ratio vm.dirty_background_ratio vm.dirty_expire_centisecs
iostat -xz 1Fix โ Flush earlier and in smaller batches with byte limits:
sysctl -w vm.dirty_background_bytes=67108864
sysctl -w vm.dirty_bytes=268435456Persist in /etc/sysctl.d/.
Prevent โ On large-RAM hosts use *_bytes rather than percentage settings.
Q87 A backup job makes the production database slow every night.
Beginner
Likely causes โ The backup saturates disk I/O or network shared with the database.
Diagnose โ
iotop -oPa # during the backup window
iostat -xz 1
sar -n DEV 1Fix โ Run the backup with lower priority (ionice -c3 nice -n19), rate-limit (rsync --bwlimit, pv -L), take backups from a replica, or use storage snapshots.
Prevent โ Schedule backups away from peak; use a replica for backups.
Q88 iostat shows await of 200 ms on an NVMe disk that should do under 1 ms.
Intermediate
iostat shows await of 200 ms on an NVMe disk that should do under 1 ms.Likely causes โ Queue saturation from too many concurrent requests, device throttling (cloud limits), thermal throttling, or a failing device.
Diagnose โ
iostat -xz 1 5 # aqu-sz large?
sudo nvme smart-log /dev/nvme0n1 # temperature, media errors
cat /sys/block/nvme0n1/queue/scheduler
dmesg -T | grep -i nvmeFix โ Reduce concurrency or spread I/O across devices; for cloud volumes raise provisioned IOPS/throughput; replace hardware showing media errors.
Prevent โ Monitor latency per device and cloud throttling metrics.
Q89 The app is slow, but CPU, memory, and disk all look fine. Where do you look next?
Intermediate
Likely causes โ Waiting on something external: DNS, a slow downstream API/DB, network retransmits, lock contention, or connection pool exhaustion.
Diagnose โ
ss -tnp state established | wc -l
nstat -az | grep -Ei 'retrans|timeout'
strace -f -tt -T -e trace=network -p <PID> 2>&1 | head -50 # slow connect()/recv()
time getent hosts api.internalFix โ Fix the slow dependency: DNS caching, increase pool size, timeouts with retries, or fix packet loss.
Prevent โ Distributed tracing and per-dependency latency metrics.
Q90 Running ls or any command on the server takes several seconds to start.
Intermediate
ls or any command on the server takes several seconds to start.Likely causes โ Name service lookups timing out (user/group lookups to an unreachable LDAP/SSSD server), a slow shell profile, or a hung NFS mount in PATH.
Diagnose โ
time /bin/true
strace -f -tt -e trace=connect,openat ls 2>&1 | tail -20
grep -E 'passwd|group' /etc/nsswitch.conf
systemctl status sssdFix โ Restore the directory service, or order files before sss/ldap in nsswitch. Remove NFS paths from PATH.
Prevent โ Enable SSSD caching and monitor directory reachability.
Q91 CPU frequency seems low and benchmarks are 30% slower than expected on bare metal.
Intermediate
Likely causes โ CPU frequency governor set to powersave, BIOS power profile, or thermal throttling.
Diagnose โ
cpupower frequency-info
grep MHz /proc/cpuinfo | head
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
dmesg -T | grep -i thermalFix โ sudo cpupower frequency-set -g performance or tuned-adm profile throughput-performance. Set the BIOS profile to performance; fix cooling.
Prevent โ Use tuned profiles in your baseline.
Q92 top itself is slow to refresh and ps takes seconds on a host with 50,000 processes.
Beginner
top itself is slow to refresh and ps takes seconds on a host with 50,000 processes.Likely causes โ Reading /proc for that many processes is costly; often a fork bomb or a runaway process spawner.
Diagnose โ
ps -eo user= | sort | uniq -c | sort -rn | head
ps -eo comm= | sort | uniq -c | sort -rn | headFix โ Stop the spawner (pkill -STOP -u <user> first to freeze, then kill), fix the script or service.
Prevent โ Set TasksMax= per service and nproc limits per user.
Q93 A VM's clock-sensitive app reports timing glitches, and dmesg shows clocksource: Switched to clocksource ... or TSC unstable.
Advanced
dmesg shows clocksource: Switched to clocksource ... or TSC unstable.Likely causes โ The kernel detected an unreliable clocksource (TSC) and switched to a slower one (hpet/acpi_pm), hurting time-related syscalls and accuracy.
Diagnose โ
cat /sys/devices/system/clocksource/clocksource0/current_clocksource
cat /sys/devices/system/clocksource/clocksource0/available_clocksource
dmesg -T | grep -i clocksourceFix โ Use the hypervisor-recommended clocksource (kvm-clock, tsc on Nitro, hyperv_clocksource_tsc_page), set via clocksource= kernel parameter if needed.
Prevent โ Follow cloud vendor guidance for clocksource on each instance family.
Q94 top shows the CPU fully busy in ni (nice). Should you be concerned?
Beginner
top shows the CPU fully busy in ni (nice). Should you be concerned?Likely causes โ Low-priority (niced) processes are using spare CPU; that's what nice is for.
Diagnose โ
ps -eo pid,ni,pcpu,cmd --sort=-pcpu | headFix โ Nothing, if normal-priority workloads are still responsive. If they suffer, lower the niced job further with cgroups (CPUWeight=).
Prevent โ Use cgroup weights for predictable sharing.
Q95 After enabling auditd with many rules, the server's CPU usage and latency rose noticeably.
Intermediate
Likely causes โ Broad syscall rules (e.g. -S open or execve for all users) generate huge event volumes, or the audit backlog fills and the kernel blocks.
Diagnose โ
sudo auditctl -s # backlog, lost
sudo auditctl -l
sudo aureport --summaryFix โ Narrow rules with filters (-F auid>=1000 -F auid!=unset, specific paths), raise -b backlog size, and set --backlog_wait_time appropriately.
Prevent โ Benchmark audit rules in staging; follow a curated rule set.
Q96 A server's disk I/O is high, yet iotop shows no process doing I/O.
Advanced
iotop shows no process doing I/O.Likely causes โ Kernel threads doing writeback (kworker/flush), journal commits (jbd2), swap, RAID resync, or I/O from another VM on shared storage.
Diagnose โ
sudo iotop -oPa -k # include kernel threads
cat /proc/mdstat
vmstat 1 5 # si/so for swap
sudo biosnoop-bpfcc 2>/dev/null | head # per-I/O process attribution (bcc tools)Fix โ Depends on source: limit RAID resync speed, address swapping, tune dirty page writeback.
Prevent โ Have eBPF tools (bcc/bpftrace) installed for attribution.
Q97 Response times degrade as a host's uptime grows; restarting the app fixes it for a few days.
Intermediate
Likely causes โ A resource leak inside the app: memory, file descriptors, threads, connections or a growing in-memory cache.
Diagnose โ
ps -o pid,etime,rss,nlwp -p <PID>
ls /proc/<PID>/fd | wc -lGraph RSS, fd count and thread count over days.
Fix โ Hand the trend data to the developers along with heap and thread dumps. Meanwhile, use scheduled rolling restarts as a stopgap.
Prevent โ Add per-process resource metrics to your dashboards.
Q98 A process is throttled even though the host has idle CPU, and cpu.stat shows a large nr_throttled.
Intermediate
cpu.stat shows a large nr_throttled.Likely causes โ The process's cgroup CPU quota (CPUQuota= or a container CPU limit) is too low for its bursty usage.
Diagnose โ
systemctl show app -p CPUQuotaPerSecUSec
cat /sys/fs/cgroup/system.slice/app.service/cpu.max
cat /sys/fs/cgroup/system.slice/app.service/cpu.stat # nr_throttled, throttled_usecFix โ Raise the quota, or use CPUWeight= (a proportional share) instead of a hard cap for latency-sensitive services.
Prevent โ Monitor throttling; size CPU limits against peak usage, not average.
Q99 vmstat shows r (run queue) at 40 on a 4-core box and the CPU is 100% us.
Beginner
vmstat shows r (run queue) at 40 on a 4-core box and the CPU is 100% us.Likely causes โ Genuine CPU saturation: far more runnable work than cores.
Diagnose โ
vmstat 1 5
top -c -o %CPU
pidstat -u 1 5Fix โ Find the top consumers, kill or limit runaway work, scale out or move to more cores; optimise hot code with profiling.
Prevent โ Capacity alerts on run queue length relative to core count.
Q100 Network throughput tops out at 1 Gbps on a 10 Gbps instance.
Intermediate
Likely causes โ Single TCP stream limited by window size or latency, driver/feature issues (no ENA/virtio enhancements), a 1 Gbps link negotiated, or instance network limits.
Diagnose โ
ethtool eth0 | grep -i speed
ethtool -i eth0 # driver
iperf3 -c peer -P 8 # parallel streams improve it?
sysctl net.ipv4.tcp_rmem net.ipv4.tcp_wmemFix โ Use parallel streams, raise TCP buffer maximums for high-latency links, update drivers, and check instance type network specs.
Prevent โ Benchmark the network when choosing instance types.
systemd services and journald
๐ฅ Learn this hands-on with DevOps Shack โ YouTube @devopsshack ยท Hindi @shackverse ยท Courses at devopsshack.com
Q101 systemctl status myapp shows Main process exited, code=exited, status=203/EXEC.
Beginner
systemctl status myapp shows Main process exited, code=exited, status=203/EXEC.Likely causes โ systemd couldn't execute ExecStart: wrong path, file not executable, missing shebang or interpreter, CRLF line endings, noexec mount, or SELinux blocking execution (e.g. a binary in a home directory).
Diagnose โ
systemctl cat myapp | grep ExecStart
ls -l /opt/myapp/bin/start.sh
head -1 /opt/myapp/bin/start.sh | cat -A
findmnt -no OPTIONS --target /opt/myapp/bin/start.sh
sudo ausearch -m AVC -ts recent | grep start.shFix โ Use an absolute path, chmod +x, add a correct shebang, convert line endings, move it off noexec mounts, or restorecon -v the file. Then systemctl daemon-reload && systemctl restart myapp.
Prevent โ Test units in CI or staging; keep service binaries under /opt or /usr/local/bin.
Q102 A service fails with status=217/USER.
Beginner
status=217/USER.Likely causes โ The user in User= doesn't exist on this host (typo, or not created yet by provisioning).
Diagnose โ
systemctl cat myapp | grep -E 'User|Group'
getent passwd appuserFix โ Create the user (useradd --system appuser) or correct the name, then restart. Or use DynamicUser=yes if the service needs no fixed identity.
Prevent โ Create service users in the same automation step that installs the unit, ordered before the start.
Q103 A service fails with status=200/CHDIR.
Beginner
status=200/CHDIR.Likely causes โ WorkingDirectory= doesn't exist or the service user can't enter it.
Diagnose โ
systemctl cat myapp | grep WorkingDirectory
sudo -u appuser test -x /opt/myapp && echo ok
namei -l /opt/myappFix โ Create the directory with correct ownership, fix parent permissions, or prefix with - (WorkingDirectory=-/opt/myapp) to make it optional.
Prevent โ Use StateDirectory= / RuntimeDirectory= so systemd creates directories with the right owner.
Q104 A unit fails with status=226/NAMESPACE.
Advanced
status=226/NAMESPACE.Likely causes โ systemd couldn't set up the mount namespace for sandboxing options: a path in ReadWritePaths=, ReadOnlyPaths=, BindPaths= or InaccessiblePaths= doesn't exist, or the kernel/container doesn't allow namespaces.
Diagnose โ
journalctl -u myapp -b | grep -i namespace
systemctl cat myapp | grep -E 'Paths=|Protect|Private'Fix โ Create the missing paths or prefix them with - to ignore missing ones (ReadWritePaths=-/var/lib/myapp). Inside unprivileged containers, drop the sandboxing options that need namespaces.
Prevent โ Use StateDirectory=/LogsDirectory= so paths exist before the namespace is built.
Q105 You edited a unit file, restarted the service, but the old behaviour persists. systemctl status shows Warning: The unit file, source configuration file or drop-ins of myapp.service changed on disk.
Beginner
systemctl status shows Warning: The unit file, source configuration file or drop-ins of myapp.service changed on disk.Likely causes โ systemd hasn't reloaded unit definitions.
Diagnose โ
systemctl status myapp | grep -i warning
systemctl cat myappFix โ sudo systemctl daemon-reload && sudo systemctl restart myapp.
Prevent โ Use systemctl edit, which reloads automatically, and add a daemon-reload handler in Ansible (systemd: daemon_reload: true).
Q106 You edited /usr/lib/systemd/system/nginx.service directly and after a package update your change vanished.
Beginner
/usr/lib/systemd/system/nginx.service directly and after a package update your change vanished.Likely causes โ Vendor unit files are owned by the package and get overwritten.
Diagnose โ
systemctl cat nginx # shows which files are used
systemd-delta --type=extended,overriddenFix โ Put the change in a drop-in: systemctl edit nginx (creates /etc/systemd/system/nginx.service.d/override.conf).
Prevent โ Never edit /usr/lib/systemd/system/; systemd-delta in audits finds local overrides.
Q107 systemctl start myapp returns immediately with success, but the app isn't running a second later and status shows inactive (dead) with code=exited, status=0/SUCCESS.
Intermediate
systemctl start myapp returns immediately with success, but the app isn't running a second later and status shows inactive (dead) with code=exited, status=0/SUCCESS.Likely causes โ ExecStart runs a script that launches the app in the background and exits (& or nohup), so systemd sees the main process end and cleans up the cgroup.
Diagnose โ
systemctl cat myapp
journalctl -u myapp -bFix โ Make the script exec the app in the foreground (exec /opt/myapp/bin/server), and keep Type=simple or Type=exec.
Prevent โ Avoid wrapper scripts that daemonise; let systemd supervise directly.
Q108 A service stays in activating (start) for 90 seconds and then fails with Failed with result 'timeout'.
Intermediate
activating (start) for 90 seconds and then fails with Failed with result 'timeout'.Likely causes โ Type=notify but the app never sends READY=1, Type=forking but the parent never exits, or a ExecStartPre that hangs. Sometimes the app really needs longer to start.
Diagnose โ
systemctl show myapp -p Type -p TimeoutStartUSec -p NotifyAccess
journalctl -u myapp -bFix โ Use the right Type (simple/exec if the app doesn't support sd_notify), fix the hanging pre-step, or raise TimeoutStartSec= for slow starts.
Prevent โ Match Type= to how the app actually behaves; document required start time.
Q109 A service starts fine manually but fails at boot because the network isn't up: bind: Cannot assign requested address.
Intermediate
bind: Cannot assign requested address.Likely causes โ It binds to a specific IP that isn't configured yet when the service starts.
Diagnose โ
journalctl -b -u myapp
systemctl list-dependencies myapp --after | grep network
systemctl is-enabled NetworkManager-wait-online systemd-networkd-wait-onlineFix โ Add After=network-online.target and Wants=network-online.target, and make sure the matching wait-online service is enabled. Alternatively, bind to 0.0.0.0, or allow binding to absent addresses with net.ipv4.ip_nonlocal_bind=1 (useful for VIPs).
Prevent โ Prefer network-online.target for services that bind to specific addresses.
Q110 systemctl enable myapp prints The unit files have no installation config (WantedBy=, RequiredBy=, Also=, Alias= settings in the [Install] section...).
Beginner
systemctl enable myapp prints The unit files have no installation config (WantedBy=, RequiredBy=, Also=, Alias= settings in the [Install] section...).Likely causes โ The unit has no [Install] section, so there's nothing to enable.
Diagnose โ
systemctl cat myapp | grep -A3 '\[Install\]'Fix โ Add:
[Install]
WantedBy=multi-user.targetThen daemon-reload and systemctl enable myapp.
Prevent โ Use a standard unit template for new services.
Q111 A service fails with status=209/STDOUT after you added StandardOutput=append:/var/log/myapp/out.log.
Intermediate
status=209/STDOUT after you added StandardOutput=append:/var/log/myapp/out.log.Likely causes โ systemd couldn't open the log file: the directory doesn't exist, or sandboxing/SELinux prevents it.
Diagnose โ
ls -ld /var/log/myapp
journalctl -u myapp -b | head
sudo ausearch -m AVC -ts recentFix โ Use LogsDirectory=myapp so systemd creates /var/log/myapp with the right owner, or create it manually. Simplest: drop the file and let output go to the journal.
Prevent โ Prefer journald plus log shipping over custom log files.
Q112 Logs from a service appear in journalctl with long delays or arrive in bursts.
Intermediate
journalctl with long delays or arrive in bursts.Likely causes โ The app's stdout is block-buffered when not attached to a terminal (Python, C stdio), so output is flushed only when the buffer fills.
Diagnose โ
journalctl -u myapp -f # compare timestamps with app eventsFix โ Disable buffering: for Python Environment=PYTHONUNBUFFERED=1, or stdbuf -oL in ExecStart, or flush in the app.
Prevent โ Standardise logging libraries that flush per line.
Q113 journald shows Suppressed 12345 messages from myapp.service.
Intermediate
Suppressed 12345 messages from myapp.service.Likely causes โ journald rate limiting kicked in because the service logged too fast (default 10,000 messages per 30 s per service in recent versions).
Diagnose โ
journalctl -u systemd-journald -b | grep Suppressed
grep -E 'RateLimit' /etc/systemd/journald.confFix โ Reduce log volume in the app first (debug logging left on?). If high volume is legitimate, set per-unit limits: LogRateLimitIntervalSec=30s and LogRateLimitBurst=50000 in the service unit.
Prevent โ Keep log levels at INFO in production; alert on suppression messages.
Q114 journalctl is very slow and returns Journal file ... is truncated, ignoring file warnings.
Advanced
journalctl is very slow and returns Journal file ... is truncated, ignoring file warnings.Likely causes โ Corrupted journal files (unclean shutdown, disk full while writing), or a huge number of journal files.
Diagnose โ
journalctl --verify
journalctl --disk-usage
ls /var/log/journal/*/ | wc -lFix โ Rotate and clean: journalctl --rotate && journalctl --vacuum-time=7d. Move corrupted files out of the directory (journald keeps working). Restart systemd-journald.
Prevent โ Keep disk space headroom and size limits (SystemMaxUse=, SystemMaxFileSize=).
Q115 A service using a template unit fails: Failed to start [email protected]: Unit name [email protected] is missing the instance name.
Beginner
Failed to start [email protected]: Unit name [email protected] is missing the instance name.Likely causes โ You tried to start the template itself instead of an instance.
Diagnose โ
systemctl list-units 'worker@*'Fix โ Start an instance: systemctl start worker@emails. To enable instances at boot, systemctl enable worker@emails.
Prevent โ Document instance names in the runbook.
Q116 A service is masked and can't be started: Failed to start foo.service: Unit foo.service is masked.
Beginner
Failed to start foo.service: Unit foo.service is masked.Likely causes โ Someone ran systemctl mask (or a package/hardening script did), linking the unit to /dev/null.
Diagnose โ
systemctl is-enabled foo
ls -l /etc/systemd/system/foo.serviceFix โ If it should run: systemctl unmask foo && systemctl enable --now foo. Check with the team first; masking is usually deliberate.
Prevent โ Track masks in config management with a reason.
Q117 A oneshot unit shows active (exited) and running systemctl start again does nothing.
Intermediate
active (exited) and running systemctl start again does nothing.Likely causes โ RemainAfterExit=yes keeps the unit "active", so starting it again is a no-op.
Diagnose โ
systemctl show myjob -p Type -p RemainAfterExitFix โ Use systemctl restart myjob to run it again, or remove RemainAfterExit if the unit is meant to run repeatedly (e.g. from a timer).
Prevent โ Use RemainAfterExit=yes only for "set up once" units.
Q118 A service dies when you log out of SSH, even though you started it with systemctl --user start.
Intermediate
systemctl --user start.Likely causes โ The user's systemd manager stops when the last session ends because lingering isn't enabled.
Diagnose โ
loginctl show-user $USER -p LingerFix โ sudo loginctl enable-linger <user>.
Prevent โ Enable linger for any account running user services or rootless containers.
Q119 Processes started from an SSH session (e.g. tmux) get killed when the user logs out on a newer distro.
Advanced
tmux) get killed when the user logs out on a newer distro.Likely causes โ KillUserProcesses=yes in /etc/systemd/logind.conf kills all processes in the session scope at logout.
Diagnose โ
grep -i KillUserProcesses /etc/systemd/logind.conf
loginctl show-session $XDG_SESSION_IDFix โ Set KillUserProcesses=no (or add users to KillExcludeUsers=), restart systemd-logind carefully, or run long tasks with systemd-run --user --scope plus linger.
Prevent โ Run long-lived work as services, not inside interactive sessions.
Q120 A service's ExecStartPre fails and the main service never starts: Control process exited, code=exited, status=1/FAILURE.
Beginner
ExecStartPre fails and the main service never starts: Control process exited, code=exited, status=1/FAILURE.Likely causes โ A pre-start step (config test, migration, directory creation) returned non-zero.
Diagnose โ
journalctl -u myapp -b --no-pager | tail -30
systemctl cat myapp | grep ExecStartPreRun the pre-step by hand as the service user.
Fix โ Fix the config error it reports (e.g. nginx -t output). If a step is optional, prefix with - (ExecStartPre=-/usr/bin/cleanup) so failure is ignored.
Prevent โ Validate config in CI before deploy.
Q121 A unit stopped working after you added DynamicUser=yes; the app can't find its data in /var/lib/myapp.
Advanced
DynamicUser=yes; the app can't find its data in /var/lib/myapp.Likely causes โ With DynamicUser=yes, the UID changes and /var/lib/myapp is owned by the old user; dynamic users can only write to StateDirectory=, which lives under /var/lib/private/.
Diagnose โ
systemctl show myapp -p DynamicUser -p StateDirectory
ls -ld /var/lib/myapp /var/lib/private/myappFix โ Set StateDirectory=myapp; systemd migrates ownership and symlinks /var/lib/myapp to /var/lib/private/myapp. Move existing data into it if needed.
Prevent โ Plan state directories when adopting DynamicUser.
Q122 systemctl commands hang or fail with Failed to connect to bus: No such file or directory inside a container or via su.
Intermediate
systemctl commands hang or fail with Failed to connect to bus: No such file or directory inside a container or via su.Likely causes โ No systemd running as PID 1 (most containers), or for --user, no XDG_RUNTIME_DIR/user bus because the session was started with su instead of a full login.
Diagnose โ
ps -p 1 -o comm=
echo $XDG_RUNTIME_DIR $DBUS_SESSION_BUS_ADDRESSFix โ In containers, run the process directly (no systemd). For user units, log in properly (machinectl shell user@ or SSH) or set XDG_RUNTIME_DIR=/run/user/$(id -u).
Prevent โ Use machinectl shell or sudo -iu user with linger for user-unit management.
Q123 A service restarts every few seconds; the journal shows Main process exited, code=killed, status=9/KILL but nobody runs kill.
Advanced
Main process exited, code=killed, status=9/KILL but nobody runs kill.Likely causes โ The cgroup memory limit (MemoryMax=) triggers the OOM killer, systemd-oomd kills it under pressure, or a watchdog (WatchdogSec=) timeout expires.
Diagnose โ
journalctl -u myapp -b | grep -Ei 'oom|watchdog'
journalctl -u systemd-oomd -b
systemctl show myapp -p MemoryMax -p WatchdogUSec -p NRestarts
dmesg -T | grep -i oomFix โ Raise or fix the memory limit; if it's the watchdog, make the app send WATCHDOG=1 in time or increase WatchdogSec=.
Prevent โ Alert on NRestarts growth and OOM events per unit.
Q124 After a reboot, a service that depends on an NFS mount starts before the mount and writes to the local disk.
Intermediate
Likely causes โ No dependency between the service and the mount; the service starts as soon as networking is up.
Diagnose โ
systemctl list-dependencies myapp | grep mount
systemctl status mnt-share.mountFix โ Add RequiresMountsFor=/mnt/share to the [Unit] section, which adds Requires= and After= on the mount unit.
Prevent โ Always declare mount dependencies for services using network storage.
Q125 systemd fails a unit with Failed to load environment files: No such file or directory.
Beginner
Failed to load environment files: No such file or directory.Likely causes โ EnvironmentFile= points to a file that doesn't exist.
Diagnose โ
systemctl cat myapp | grep EnvironmentFile
ls -l /etc/myapp/myapp.envFix โ Create the file or make it optional with a leading dash: EnvironmentFile=-/etc/myapp/myapp.env.
Prevent โ Deploy the env file before the unit; validate in your deployment playbook.
Networking, DNS and firewalls
๐ฅ Learn this hands-on with DevOps Shack โ YouTube @devopsshack ยท Hindi @shackverse ยท Courses at devopsshack.com
Q126 curl http://10.0.1.20:8080 returns curl: (7) Failed to connect to 10.0.1.20 port 8080: Connection refused.
Beginner
curl http://10.0.1.20:8080 returns curl: (7) Failed to connect to 10.0.1.20 port 8080: Connection refused.Likely causes โ The host is reachable but nothing listens on that port/IP (service down, bound to 127.0.0.1 only), or a firewall rule actively rejects with a TCP RST/ICMP.
Diagnose โ
# on the server
sudo ss -tlnp | grep 8080 # listening? on 0.0.0.0 or 127.0.0.1?
systemctl status myapp
sudo nft list ruleset | grep -i rejectFix โ Start the service, or change its bind address to 0.0.0.0/the right interface; remove the reject rule if it's wrong.
Prevent โ Health checks that test from outside the host, not just localhost.
Q127 The same request instead hangs and ends with curl: (28) Failed to connect to 10.0.1.20 port 8080 after 130000 ms: Connection timed out. How is this different from "refused"?
Beginner
curl: (28) Failed to connect to 10.0.1.20 port 8080 after 130000 ms: Connection timed out. How is this different from "refused"?Likely causes โ Packets are silently dropped: a firewall/security group with DROP, wrong routing, host down, or the SYN-ACK can't get back (asymmetric routing).
Diagnose โ
ping -c3 10.0.1.20
traceroute -T -p 8080 10.0.1.20
# on the server: are SYNs arriving?
sudo tcpdump -ni any 'tcp port 8080 and tcp[tcpflags] & tcp-syn != 0'Fix โ If no SYNs arrive, fix the security group, NACL or network firewall upstream. If SYNs arrive but no reply leaves, check the host firewall and return routes.
Prevent โ Remember the rule: refused means you reached the host; timeout means something dropped the packets.
Q128 ping google.com fails with ping: google.com: Temporary failure in name resolution, but ping 8.8.8.8 works.
Beginner
ping google.com fails with ping: google.com: Temporary failure in name resolution, but ping 8.8.8.8 works.Likely causes โ DNS is broken: no or wrong nameservers, resolver service down, or port 53 blocked.
Diagnose โ
cat /etc/resolv.conf
resolvectl status 2>/dev/null
dig google.com @8.8.8.8 # does a public resolver work?
dig google.com # using system configFix โ Point to working resolvers via NetworkManager/netplan (nmcli con mod eth0 ipv4.dns "10.0.0.2"), restart systemd-resolved if it's the one failing, or open UDP/TCP 53 egress.
Prevent โ Two resolvers in config; monitor DNS resolution from hosts.
Q129 dig api.internal works, but the application and curl fail with Could not resolve host: api.internal.
Intermediate
dig api.internal works, but the application and curl fail with Could not resolve host: api.internal.Likely causes โ dig queries DNS directly and skips NSS; apps use getaddrinfo() which follows /etc/nsswitch.conf, /etc/hosts and search domains. A bad hosts: line, or a .local/mDNS rule, or the app running in a different network namespace, can differ.
Diagnose โ
getent hosts api.internal # uses the same path as apps
grep '^hosts' /etc/nsswitch.conf
cat /etc/resolv.conf # search, options ndotsFix โ Fix nsswitch (hosts: files dns), add the correct search domain, or fix the container's DNS config.
Prevent โ Test with getent hosts, not dig, when debugging application resolution.
Q130 /etc/resolv.conf changes you made disappear after a reboot or a few minutes.
Beginner
/etc/resolv.conf changes you made disappear after a reboot or a few minutes.Likely causes โ The file is managed by NetworkManager, systemd-resolved (symlink to /run/systemd/resolve/stub-resolv.conf), netplan or DHCP client.
Diagnose โ
ls -l /etc/resolv.conf
head -5 /etc/resolv.conf # "Generated by NetworkManager" etc.Fix โ Configure DNS in the owning tool: nmcli con mod, netplan nameservers:, or /etc/systemd/resolved.conf DNS=. Then reapply.
Prevent โ Never hand-edit a generated resolv.conf.
Q131 DNS lookups take exactly 5 seconds before succeeding.
Intermediate
Likely causes โ The first nameserver in resolv.conf is dead and the resolver times out (default 5 s) before trying the next. Also common: parallel A/AAAA queries dropped by a firewall/conntrack race.
Diagnose โ
cat /etc/resolv.conf
for ns in $(awk '/^nameserver/{print $2}' /etc/resolv.conf); do dig +time=2 +tries=1 example.com @$ns | grep -E 'status|Query time'; doneFix โ Remove the dead nameserver; add options timeout:1 attempts:2 rotate, or single-request-reopen for the A/AAAA issue.
Prevent โ Monitor each resolver; run a local caching resolver (systemd-resolved, dnsmasq, unbound).
Q132 Short names like db01 don't resolve, but db01.corp.example.com does.
Beginner
db01 don't resolve, but db01.corp.example.com does.Likely causes โ Missing or wrong search domain.
Diagnose โ
grep -E '^(search|domain)' /etc/resolv.conf
resolvectl domainFix โ Set the search domain in the network config: nmcli con mod eth0 ipv4.dns-search corp.example.com && nmcli con up eth0.
Prevent โ Prefer FQDNs in application configs anyway.
Q133 A host can reach servers in its own subnet but nothing beyond: connect: Network is unreachable.
Beginner
connect: Network is unreachable.Likely causes โ No default route (missing gateway, DHCP failure, misconfigured static config).
Diagnose โ
ip route
ip -4 addr
nmcli dev show eth0 | grep -i gatewayFix โ Add it now: sudo ip route add default via 10.0.1.1 dev eth0, then persist in NetworkManager/netplan (ipv4.gateway).
Prevent โ Validate network config with netplan try or a test after changes.
Q134 An application gets connect: No route to host to a server that is up and responds to ping from elsewhere.
Intermediate
connect: No route to host to a server that is up and responds to ping from elsewhere.Likely causes โ The target's firewall rejects with icmp-host-prohibited (firewalld/iptables default REJECT), or ARP fails on the local segment.
Diagnose โ
ip neigh show 10.0.1.20 # FAILED/INCOMPLETE = ARP problem
sudo tcpdump -ni eth0 'icmp or arp'
# on target
sudo firewall-cmd --list-allFix โ Open the port on the target (firewall-cmd --add-port=8080/tcp --permanent && firewall-cmd --reload), or fix the L2 issue (VLAN, IP conflict).
Prevent โ Remember: firewalld's reject message looks like a routing error.
Q135 ss -tlnp shows the app listening on 127.0.0.1:5432, and remote clients can't connect.
Beginner
ss -tlnp shows the app listening on 127.0.0.1:5432, and remote clients can't connect.Likely causes โ The service is bound to loopback only (PostgreSQL's default listen_addresses = 'localhost').
Diagnose โ
sudo ss -tlnp | grep 5432
grep listen_addresses /var/lib/pgsql/data/postgresql.confFix โ Set listen_addresses = '10.0.1.20' (or '*' with firewall restrictions), allow clients in pg_hba.conf, restart PostgreSQL, open the firewall.
Prevent โ Bind to specific private IPs, not 0.0.0.0, and firewall the port.
Q136 After adding firewalld rules, they work until the next reboot and then disappear.
Beginner
Likely causes โ Rules were added at runtime without --permanent.
Diagnose โ
sudo firewall-cmd --list-all
sudo firewall-cmd --permanent --list-allFix โ sudo firewall-cmd --runtime-to-permanent, or add rules with --permanent then --reload.
Prevent โ Manage firewall rules with config management (Ansible firewalld module with permanent: true, immediate: true).
Q137 dmesg is flooded with nf_conntrack: table full, dropping packet and new connections randomly fail.
Advanced
dmesg is flooded with nf_conntrack: table full, dropping packet and new connections randomly fail.Likely causes โ The connection tracking table is full: high connection rates on a NAT gateway, load balancer or busy host with stateful firewall rules.
Diagnose โ
sysctl net.netfilter.nf_conntrack_count net.netfilter.nf_conntrack_max
sudo conntrack -S | head
sudo conntrack -L 2>/dev/null | awk '{print $1, $4}' | sort | uniq -c | sort -rn | headFix โ Raise the limit: sysctl -w net.netfilter.nf_conntrack_max=1048576 (and nf_conntrack_buckets via module options), shorten timeouts (nf_conntrack_tcp_timeout_time_wait), or exempt high-volume traffic with notrack rules.
Prevent โ Alert at 80% of nf_conntrack_max; size for peak.
Q138 A server shows packet loss and the interface counters keep rising: ip -s link shows RX dropped increasing.
Advanced
ip -s link shows RX dropped increasing.Likely causes โ The NIC ring buffer or kernel backlog overflows under bursts, CPU can't keep up with softirqs, or packets for unknown protocols/VLANs are discarded.
Diagnose โ
ip -s link show eth0
ethtool -S eth0 | grep -Ei 'drop|miss|fifo|no_buff'
ethtool -g eth0 # ring sizes
cat /proc/net/softnet_stat # 2nd column = backlog dropsFix โ Increase ring buffers (ethtool -G eth0 rx 4096), raise net.core.netdev_max_backlog, spread IRQs/queues across CPUs.
Prevent โ Graph NIC drop counters; tune before peak traffic.
Q139 Two servers have the same IP and connections randomly reset; logs show IPv4: martian source or ARP flapping.
Intermediate
IPv4: martian source or ARP flapping.Likely causes โ IP address conflict on the segment.
Diagnose โ
sudo arping -D -I eth0 -c 3 10.0.1.25 # duplicate detection; replies = conflict
ip neigh show 10.0.1.25
journalctl -k | grep -i 'duplicate\|martian'Fix โ Find the other MAC owner (switch tables, DHCP leases, cloud console) and re-address one host.
Prevent โ IPAM/DHCP reservations instead of hand-assigned addresses.
Q140 Traffic arrives on the second NIC of a multi-homed server but replies leave through the first NIC and get dropped.
Advanced
Likely causes โ Asymmetric routing: the single default route sends replies out the wrong interface; rp_filter or upstream firewalls drop them.
Diagnose โ
ip route; ip rule
sudo tcpdump -ni eth1 port 443 &
sudo tcpdump -ni eth0 port 443
sysctl net.ipv4.conf.all.rp_filterFix โ Policy routing so replies from eth1's IP use eth1's gateway:
ip route add default via 10.0.2.1 dev eth1 table 100
ip rule add from 10.0.2.15 table 100Persist via NetworkManager (ipv4.routing-rules) or netplan routing-policy. Set rp_filter=2 (loose) if needed.
Prevent โ Document every multi-homed host's routing design.
Q141 curl https://api.example.com fails with curl: (60) SSL certificate problem: unable to get local issuer certificate.
Intermediate
curl https://api.example.com fails with curl: (60) SSL certificate problem: unable to get local issuer certificate.Likely causes โ The server doesn't send the intermediate certificate, the host's CA bundle is outdated, or a corporate TLS-inspecting proxy uses an internal CA not trusted by the host.
Diagnose โ
openssl s_client -connect api.example.com:443 -servername api.example.com -showcerts </dev/null | grep -E 's:|i:'
rpm -q ca-certificates || dpkg -l ca-certificatesFix โ Fix the server's chain (send full chain). For an internal CA: copy it to /etc/pki/ca-trust/source/anchors/ and update-ca-trust (RHEL) or /usr/local/share/ca-certificates/ and update-ca-certificates (Debian). Never use curl -k as the fix.
Prevent โ Keep ca-certificates updated; check chains in monitoring.
Q142 TLS connections fail with certificate is not yet valid or certificate has expired while the certificate is fine on other hosts.
Intermediate
certificate is not yet valid or certificate has expired while the certificate is fine on other hosts.Likely causes โ The host's clock is wrong.
Diagnose โ
date -u
timedatectl
chronyc trackingFix โ Fix time sync (see chrony), then retry. A big jump may need chronyc makestep.
Prevent โ Monitor clock offset; it breaks TLS, Kerberos and token validation.
Q143 A newly added iptables rule to allow port 8080 has no effect.
Intermediate
Likely causes โ Rule order: it was appended (-A) after a catch-all REJECT/DROP; or firewalld/nftables manage the real ruleset and your iptables rule went to a different table (iptables-nft vs legacy).
Diagnose โ
sudo iptables -L INPUT -n --line-numbers -v
sudo nft list ruleset | less
systemctl is-active firewalld nftables ufwFix โ Insert before the reject: iptables -I INPUT 5 -p tcp --dport 8080 -j ACCEPT, or better, use the active manager (firewall-cmd, ufw, nft config).
Prevent โ Use one firewall manager per host; never mix them.
Q144 Docker containers lose network access after you restart firewalld or flush iptables.
Advanced
Likely causes โ Docker inserts its own NAT and FORWARD rules; flushing or reloading the firewall wipes them.
Diagnose โ
sudo iptables -t nat -L DOCKER -n
sudo nft list ruleset | grep -i dockerFix โ sudo systemctl restart docker to recreate its rules. Put custom rules in the DOCKER-USER chain so Docker leaves them alone.
Prevent โ Avoid iptables -F on container hosts; manage rules in DOCKER-USER.
Q145 ssh and curl to a remote host work, but git clone over HTTPS hangs on large repos only.
Advanced
ssh and curl to a remote host work, but git clone over HTTPS hangs on large repos only.Likely causes โ A proxy or middlebox timing out long transfers, a broken HTTP proxy setting in git, or a stateful firewall killing long-lived connections.
Diagnose โ
git config --show-origin --get-regexp 'http.*proxy'
env | grep -i proxy
GIT_TRACE=1 GIT_CURL_VERBOSE=1 git clone https://... 2>&1 | tail -40Fix โ Correct or remove proxy settings, set NO_PROXY for internal hosts, use shallow clones (--depth 1) or SSH transport, and raise idle timeouts on the middlebox.
Prevent โ Central, documented proxy config (/etc/environment, systemd Environment=).
Q146 A service can't connect to an external API only from inside a systemd unit, but works from your shell.
Intermediate
Likely causes โ Proxy variables exist in your shell profile but not in the unit; or IPAddressDeny=/RestrictAddressFamilies=/PrivateNetwork= in the unit blocks it.
Diagnose โ
env | grep -i proxy
systemctl show myapp -p Environment -p IPAddressDeny -p PrivateNetwork -p RestrictAddressFamiliesFix โ Add Environment=HTTPS_PROXY=http://proxy:3128 NO_PROXY=.internal to the unit, or relax the sandbox option.
Prevent โ Define required environment in units explicitly; never rely on login profiles.
Q147 After switching an interface to a static IP with nmcli, the IP is set but the old DHCP address still appears too.
Intermediate
nmcli, the IP is set but the old DHCP address still appears too.Likely causes โ Two connection profiles are active for the device, or ipv4.method is still auto with the static address added as extra.
Diagnose โ
nmcli con show
nmcli -f ipv4.method,ipv4.addresses con show "System eth0"
ip addr show eth0Fix โ nmcli con mod "System eth0" ipv4.method manual and delete the duplicate profile (nmcli con delete <name>), then nmcli con up "System eth0".
Prevent โ One profile per interface, managed by automation.
Q148 Clients get ERR_CONNECTION_RESET intermittently to a web server; nstat shows TcpExtListenOverflows rising.
Advanced
ERR_CONNECTION_RESET intermittently to a web server; nstat shows TcpExtListenOverflows rising.Likely causes โ The listen (accept) queue overflows during bursts because the app accepts too slowly or the backlog is too small.
Diagnose โ
nstat -az TcpExtListenOverflows TcpExtListenDrops
ss -ltn 'sport = :443' # Recv-Q vs Send-Q (backlog)
sysctl net.core.somaxconnFix โ Raise net.core.somaxconn and the app's listen backlog (nginx listen 443 backlog=4096), add workers so accept keeps up.
Prevent โ Graph listen overflows; load test with realistic bursts.
Q149 A host can resolve and ping IPv4 but apps hang for a long time before connecting; getent ahosts shows IPv6 addresses first.
Intermediate
getent ahosts shows IPv6 addresses first.Likely causes โ AAAA records are returned and the client tries IPv6 first, but there is no working IPv6 route, so it waits for timeout before falling back.
Diagnose โ
getent ahosts api.example.com
ip -6 route
curl -6 -v https://api.example.com --max-time 5Fix โ Fix IPv6 connectivity, or prefer IPv4 in /etc/gai.conf (precedence ::ffff:0:0/96 100), or disable IPv6 on that interface if it's not used.
Prevent โ Either support IPv6 properly or disable it consistently.
Q150 systemd-resolved is running but lookups fail with resolve call failed: All attempts to contact name servers or networks failed.
Intermediate
systemd-resolved is running but lookups fail with resolve call failed: All attempts to contact name servers or networks failed.Likely causes โ resolved has no upstream DNS servers configured for any link, or DNSSEC/DoT settings fail with the upstream.
Diagnose โ
resolvectl status
resolvectl query example.com
grep -Ev '^#|^$' /etc/systemd/resolved.confFix โ Set upstream servers per link (via NetworkManager/netplan) or globally (DNS=10.0.0.2 in resolved.conf), set DNSSEC=no or allow-downgrade if upstream doesn't support it, and systemctl restart systemd-resolved. Flush with resolvectl flush-caches.
Prevent โ Include DNS checks in host monitoring.
SSH, sudo and authentication
๐ฅ Learn this hands-on with DevOps Shack โ YouTube @devopsshack ยท Hindi @shackverse ยท Courses at devopsshack.com
Q151 ssh deploy@server01 fails with deploy@server01: Permission denied (publickey).
Beginner
ssh deploy@server01 fails with deploy@server01: Permission denied (publickey).Likely causes โ The client offers the wrong key, the public key isn't in the right authorized_keys, or permissions on ~, ~/.ssh or authorized_keys are too open so sshd ignores them.
Diagnose โ
ssh -v deploy@server01 2>&1 | grep -E 'Offering|Authentications|identity file'
# on the server (console or another account)
sudo ls -ld /home/deploy /home/deploy/.ssh /home/deploy/.ssh/authorized_keys
sudo journalctl -u sshd -n 30 | grep -i deployFix โ
sudo chmod go-w /home/deploy
sudo chmod 700 /home/deploy/.ssh
sudo chmod 600 /home/deploy/.ssh/authorized_keys
sudo chown -R deploy:deploy /home/deploy/.sshUse the correct key: ssh -i ~/.ssh/deploy_ed25519 deploy@server01.
Prevent โ Create keys with automation (Ansible authorized_key) which sets modes correctly.
Q152 Permissions on ~/.ssh are correct, but you still get Permission denied (publickey) and the server log says Authentication refused: bad ownership or modes for directory /home/deploy.
Intermediate
~/.ssh are correct, but you still get Permission denied (publickey) and the server log says Authentication refused: bad ownership or modes for directory /home/deploy.Likely causes โ The home directory itself is group- or world-writable (StrictModes yes checks every path component).
Diagnose โ
sudo journalctl -u sshd | grep -i 'bad ownership'
namei -l /home/deploy/.ssh/authorized_keysFix โ sudo chmod 755 /home/deploy (or 750), owned by the user.
Prevent โ Don't chmod 777 home directories to "fix" sharing; use groups.
Q153 Key auth fails only on RHEL with SELinux enforcing; the server logs show nothing unusual about modes.
Intermediate
Likely causes โ authorized_keys has the wrong SELinux context (copied or created in an unusual way, or the home directory is in a non-standard path like /data/home).
Diagnose โ
ls -Z /home/deploy/.ssh/authorized_keys # expect ssh_home_t
sudo ausearch -m AVC -c sshd -ts recentFix โ sudo restorecon -Rv /home/deploy/.ssh. For a custom home root: semanage fcontext -a -e /home /data/home && restorecon -Rv /data/home.
Prevent โ Use standard home locations or register equivalence rules.
Q154 After upgrading the client to a new OpenSSH, connections to an old appliance fail with no matching host key type found. Their offer: ssh-rsa,ssh-dss.
Intermediate
no matching host key type found. Their offer: ssh-rsa,ssh-dss.Likely causes โ New OpenSSH (8.8+) disables ssh-rsa signatures (SHA-1) by default; the old server only offers those.
Diagnose โ
ssh -vvv admin@appliance 2>&1 | grep -i 'host key'
ssh -Q keyFix โ Enable it only for that host in ~/.ssh/config:
Host appliance
HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsaPlan to upgrade the appliance.
Prevent โ Scope legacy exceptions to specific hosts, never Host *.
Q155 A user's RSA key stopped working against a new server: the server log says userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms.
Intermediate
userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms.Likely causes โ The client signs with the deprecated ssh-rsa (SHA-1) algorithm (old client), or the server's crypto policy disallows it.
Diagnose โ
ssh -V
ssh -v user@server 2>&1 | grep -i 'signature\|rsa'
update-crypto-policies --show # RHEL serverFix โ Upgrade the client so it uses rsa-sha2-256/512, or better, generate an Ed25519 key: ssh-keygen -t ed25519.
Prevent โ Standardise on Ed25519 keys.
Q156 SSH login takes 20โ30 seconds before the password or key prompt appears.
Intermediate
Likely causes โ sshd does a reverse DNS lookup of the client (UseDNS yes) and DNS times out, or GSSAPI authentication attempts time out.
Diagnose โ
ssh -vvv user@server 2>&1 | grep -E 'debug1:.*(GSSAPI|Authentications)'
grep -Ei 'UseDNS|GSSAPIAuthentication' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*Fix โ Set UseDNS no and GSSAPIAuthentication no (if not using Kerberos) on the server; on the client GSSAPIAuthentication no. Fix DNS if it's broken generally.
Prevent โ Keep sshd baseline config consistent.
Q157 SSH fails immediately with kex_exchange_identification: read: Connection reset by peer.
Advanced
kex_exchange_identification: read: Connection reset by peer.Likely causes โ The server closes the connection before the SSH banner: TCP wrappers/hosts.deny, fail2ban or a firewall resetting, MaxStartups exceeded (many unauthenticated connections), or sshd crashing per-connection.
Diagnose โ
# server side
sudo journalctl -u sshd -n 50
sudo fail2ban-client status sshd 2>/dev/null
grep -i maxstartups /etc/ssh/sshd_config
cat /etc/hosts.deny 2>/dev/nullFix โ Unban the client IP (fail2ban-client set sshd unbanip 1.2.3.4), raise MaxStartups 30:30:100 if under scanning load, fix the crash shown in logs.
Prevent โ Restrict SSH exposure so scanners can't exhaust MaxStartups.
Q158 ssh reports ssh: connect to host server01 port 22: Connection refused after you edited sshd_config.
Beginner
ssh reports ssh: connect to host server01 port 22: Connection refused after you edited sshd_config.Likely causes โ sshd failed to restart because of a config syntax error, or it now listens on a different port.
Diagnose โ (via console)
sudo sshd -t
systemctl status sshd
sudo ss -tlnp | grep sshdFix โ Correct the reported line, sshd -t, then systemctl restart sshd.
Prevent โ Always run sshd -t before restart and keep an open session while testing.
Q159 An SSH key with a passphrase works interactively, but scripts fail with Enter passphrase for key prompts or Permission denied in automation.
Beginner
Enter passphrase for key prompts or Permission denied in automation.Likely causes โ No ssh-agent available in the non-interactive context.
Diagnose โ
echo $SSH_AUTH_SOCK
ssh-add -lFix โ For automation, use a dedicated passphrase-less key restricted on the server (from=, command=), or a CI secret loaded into an agent at job start (eval $(ssh-agent) && ssh-add - <<< "$KEY").
Prevent โ Separate human and machine keys.
Q160 Agent forwarding (ssh -A) works to the bastion, but git pull on the next host says Permission denied (publickey).
Intermediate
ssh -A) works to the bastion, but git pull on the next host says Permission denied (publickey).Likely causes โ Forwarding is disabled on the target (AllowAgentForwarding no), you used sudo (which drops SSH_AUTH_SOCK), or forwarding wasn't requested on the second hop.
Diagnose โ
echo $SSH_AUTH_SOCK; ssh-add -l # on the inner host
sudo -E env | grep SSH_AUTH_SOCKFix โ Use ProxyJump so keys never leave your laptop, and connect to the final host directly: ssh -J bastion app01. For git on the server, use deploy keys instead.
Prevent โ Prefer ProxyJump over -A; forwarded agents can be abused by root on intermediate hosts.
Q161 SSH certificate login fails with error: Certificate invalid: name is not a listed principal.
Advanced
error: Certificate invalid: name is not a listed principal.Likely causes โ The certificate's principals don't include the target username or any principal in AuthorizedPrincipalsFile.
Diagnose โ
ssh-keygen -L -f ~/.ssh/id_ed25519-cert.pub # Principals, Valid
grep -E 'TrustedUserCAKeys|AuthorizedPrincipals' /etc/ssh/sshd_config
cat /etc/ssh/auth_principals/deploy 2>/dev/nullFix โ Reissue the certificate with the right principal (ssh-keygen -s ca -I alice -n deploy,alice -V +8h key.pub) or add the principal to the server's principals file.
Prevent โ Map principals to roles centrally and test cert issuance in CI.
Q162 SSH certificate login fails with Certificate invalid: expired, even though it was issued an hour ago with 8h validity.
Advanced
Certificate invalid: expired, even though it was issued an hour ago with 8h validity.Likely causes โ Clock skew on the server (or CA) makes the cert look expired or not yet valid.
Diagnose โ
ssh-keygen -L -f ~/.ssh/id_ed25519-cert.pub | grep Valid
ssh server date -u 2>/dev/null; date -u
chronyc trackingFix โ Fix time sync on the server/CA. Issue certs with a small backdated start (-V -5m:+8h) to tolerate minor skew.
Prevent โ Monitor NTP offset on every host.
Q163 sudo says alice is not in the sudoers file. This incident will be reported.
Beginner
sudo says alice is not in the sudoers file. This incident will be reported.Likely causes โ The user isn't in the admin group (wheel on RHEL, sudo on Debian/Ubuntu) and has no sudoers rule, or the session predates the group addition.
Diagnose โ
id alice
sudo -l -U alice # as an admin
grep -E '^%(wheel|sudo)' /etc/sudoersFix โ usermod -aG wheel alice (or sudo), then have them log in again; or add a specific rule in /etc/sudoers.d/.
Prevent โ Manage sudo via groups from central identity.
Q164 sudo hangs for several seconds and prints sudo: unable to resolve host app01: Name or service not known.
Beginner
sudo hangs for several seconds and prints sudo: unable to resolve host app01: Name or service not known.Likely causes โ The hostname was changed but isn't resolvable (missing from /etc/hosts and DNS).
Diagnose โ
hostname
getent hosts "$(hostname)"
cat /etc/hostsFix โ Add 127.0.1.1 app01 (Debian style) or the host's IP and FQDN to /etc/hosts, or fix DNS.
Prevent โ Update /etc/hosts whenever the hostname changes (cloud-init manage_etc_hosts: true).
Q165 After editing /etc/sudoers with a text editor, every sudo command fails with sudo: parse error in /etc/sudoers near line 31 and nobody can become root.
Intermediate
/etc/sudoers with a text editor, every sudo command fails with sudo: parse error in /etc/sudoers near line 31 and nobody can become root.Likely causes โ Syntax error in sudoers; sudo refuses to run with a broken policy.
Diagnose โ
pkexec visudo -c 2>/dev/null # if polkit is availableFix โ Use pkexec visudo if polkit works; otherwise log in as root on the console, or reboot into rescue mode (rd.break / init=/bin/bash), remount rw and fix the line with visudo -c -f /sysroot/etc/sudoers.
Prevent โ Only edit with visudo (it validates), and use drop-ins in /etc/sudoers.d/ deployed with validation.
Q166 A user's password login fails with Your account has expired; please contact your system administrator.
Beginner
Your account has expired; please contact your system administrator.Likely causes โ The account expiry date (chage -E) has passed, set by policy or offboarding.
Diagnose โ
sudo chage -l aliceFix โ If access is approved: sudo chage -E -1 alice (remove expiry) or set a new date.
Prevent โ Notify users and managers before account expiry; tie expiry to HR data.
Q167 A user gets You are required to change your password immediately (administrator enforced) and the change fails over SSH with Authentication token manipulation error.
Intermediate
You are required to change your password immediately (administrator enforced) and the change fails over SSH with Authentication token manipulation error.Likely causes โ The password is forced to change (chage -d 0), and the update fails because /etc/shadow is not writable (read-only root, wrong SELinux label, immutable attribute) or pwquality rejects it.
Diagnose โ
sudo chage -l alice
lsattr /etc/shadow; ls -lZ /etc/shadow
findmnt -no OPTIONS /
sudo journalctl -t passwd -n 20Fix โ Fix the shadow file issue (chattr -i, restorecon, remount rw), or set a password as root: passwd alice.
Prevent โ Avoid immutable flags on auth files; monitor for read-only root.
Q168 Users get locked out after a few wrong passwords and the lock persists: pam_faillock(sshd:auth): Consecutive login failures for user alice account temporarily locked.
Intermediate
pam_faillock(sshd:auth): Consecutive login failures for user alice account temporarily locked.Likely causes โ pam_faillock (RHEL 8/9, newer Ubuntu) locking after N failures; automated scripts with an old password can trigger it repeatedly.
Diagnose โ
sudo faillock --user alice
grep -Ev '^#|^$' /etc/security/faillock.confFix โ sudo faillock --user alice --reset. Find and fix the source of failures (a script, a mounted share using old credentials).
Prevent โ Set reasonable deny and unlock_time in faillock.conf; use keys for automation.
Q169 LDAP/AD users can't log in: id aduser returns no such user, but local users are fine.
Intermediate
id aduser returns no such user, but local users are fine.Likely causes โ SSSD down or offline, DNS can't find domain controllers, Kerberos clock skew, or the computer account in AD is broken.
Diagnose โ
systemctl status sssd
sudo sssctl domain-status corp.example.com
dig -t SRV _ldap._tcp.corp.example.com
chronyc tracking
sudo journalctl -u sssd -n 50Fix โ Restart SSSD after fixing DNS/time; clear the cache (sss_cache -E); rejoin the domain if the machine account is broken (realm leave / realm join).
Prevent โ Monitor SSSD domain status and time sync; keep a local break-glass admin.
Q170 Kerberos-based SSH login fails with Clock skew too great in the logs.
Intermediate
Clock skew too great in the logs.Likely causes โ Server or client clock differs from the KDC by more than 5 minutes (the default).
Diagnose โ
date -u; chronyc tracking
klistFix โ Fix NTP sync on the affected host (chronyc makestep), then re-acquire tickets (kinit).
Prevent โ Point all domain members at the domain controllers or the same NTP source.
Q171 su - appuser returns This account is currently not available.
Beginner
su - appuser returns This account is currently not available.Likely causes โ The account's shell is /sbin/nologin, by design for service accounts.
Diagnose โ
getent passwd appuserFix โ Run commands as the user without changing their shell: sudo -u appuser -s /bin/bash or sudo -u appuser <command>. Only change the shell if there's a real need.
Prevent โ Document how admins should act as service accounts.
Q172 SFTP users in a chroot get disconnected immediately; the server log says fatal: bad ownership or modes for chroot directory "/sftp/partner1".
Advanced
fatal: bad ownership or modes for chroot directory "/sftp/partner1".Likely causes โ The chroot directory and every parent must be owned by root and not writable by group/others.
Diagnose โ
namei -l /sftp/partner1
sudo journalctl -u sshd | grep -i chrootFix โ
sudo chown root:root /sftp /sftp/partner1
sudo chmod 755 /sftp /sftp/partner1
sudo mkdir -p /sftp/partner1/upload && sudo chown partner1: /sftp/partner1/uploadPrevent โ Template the chroot creation; users write only to subdirectories.
Q173 SSH port forwarding fails with channel 3: open failed: administratively prohibited: open failed.
Intermediate
channel 3: open failed: administratively prohibited: open failed.Likely causes โ The server disallows TCP forwarding (AllowTcpForwarding no, PermitOpen restrictions), or the key has no-port-forwarding / restrict options in authorized_keys.
Diagnose โ
sudo sshd -T | grep -Ei 'allowtcpforwarding|permitopen'
grep -n 'no-port-forwarding\|restrict' ~/.ssh/authorized_keysFix โ If approved, enable forwarding for that user/group via Match blocks, or add a PermitOpen host:port allowlist.
Prevent โ Document which roles may tunnel; forwarding is often deliberately disabled.
Q174 ssh with a FIDO2 key fails: Confirm user presence for key ED25519-SK never appears and you get sign_and_send_pubkey: signing failed for ED25519-SK.
Advanced
ssh with a FIDO2 key fails: Confirm user presence for key ED25519-SK never appears and you get sign_and_send_pubkey: signing failed for ED25519-SK.Likely causes โ The security key isn't detected (USB/udev permissions), missing libfido2/middleware, or the key requires a PIN (verify-required) that wasn't supplied.
Diagnose โ
ssh -vvv host 2>&1 | grep -iE 'sk|fido'
fido2-token -L 2>/dev/null
ls -l /dev/hidraw*Fix โ Install libfido2, fix udev rules so the user can access the hidraw device, touch the key when prompted, or enter the PIN.
Prevent โ Document FIDO2 setup per OS; keep a backup key enrolled.
Q175 Logins over SSH succeed, but the user lands in / with Could not chdir to home directory /home/bob: No such file or directory.
Beginner
/ with Could not chdir to home directory /home/bob: No such file or directory.Likely causes โ The home directory wasn't created (user added without -m, or a directory-service user with no mkhomedir), or an NFS/autofs home share isn't mounted.
Diagnose โ
getent passwd bob
ls -ld /home/bob
findmnt /homeFix โ Create it: sudo mkhomedir_helper bob or install -d -m 700 -o bob -g bob /home/bob. For directory users, enable pam_mkhomedir (authselect enable-feature with-mkhomedir, plus oddjobd).
Prevent โ Use useradd -m, or enable mkhomedir for central accounts.
Boot, time, cron and kernel
๐ฅ Learn this hands-on with DevOps Shack โ YouTube @devopsshack ยท Hindi @shackverse ยท Courses at devopsshack.com
Q176 After a reboot the server drops to You are in emergency mode. After logging in, type "journalctl -xb" to view system logs.
Intermediate
You are in emergency mode. After logging in, type "journalctl -xb" to view system logs.Likely causes โ A required mount in /etc/fstab failed (wrong UUID, removed disk, typo, filesystem errors), so local-fs.target couldn't be reached.
Diagnose โ
journalctl -xb | grep -Ei 'failed|dependency|mount'
systemctl --failed
cat /etc/fstab; lsblk -fFix โ Fix or comment out the bad fstab line (mount -o remount,rw / first if root is read-only), run systemctl daemon-reload && mount -a to confirm, then systemctl default or reboot. If the filesystem is damaged, run fsck/xfs_repair on it.
Prevent โ Use nofail for non-critical mounts and always run mount -a after editing fstab.
Q177 Boot stops at dracut-initqueue: Warning: dracut-initqueue timeout - starting timeout scripts and then a dracut:/# shell.
Advanced
dracut-initqueue: Warning: dracut-initqueue timeout - starting timeout scripts and then a dracut:/# shell.Likely causes โ The initramfs can't find the root device: wrong root= UUID on the kernel command line, missing storage driver in initramfs, LVM VG renamed, or a LUKS device not unlocked.
Diagnose โ In the dracut shell:
cat /proc/cmdline
blkid
lvm vgscan; lvm lvs
ls /dev/mapperFix โ If LVM is inactive: lvm vgchange -ay then exit to continue. Permanently: boot rescue media, chroot, fix root=/rd.lvm.lv= with grubby, and rebuild initramfs with dracut -f --kver <version>.
Prevent โ Rebuild initramfs after storage changes and test reboots in a window.
Q178 A server shows a grub> prompt instead of booting.
Advanced
grub> prompt instead of booting.Likely causes โ GRUB can't find its config (grub.cfg missing or wrong partition), often after disk changes, a failed update or a resized/moved /boot.
Diagnose โ At the prompt:
grub> ls
grub> ls (hd0,gpt2)/Find the partition with /boot/vmlinuz-* or /grub2/grub.cfg.
Fix โ Boot manually:
grub> set root=(hd0,gpt2)
grub> linux /vmlinuz-<ver> root=/dev/mapper/vg0-root ro
grub> initrd /initramfs-<ver>.img
grub> bootThen regenerate: grub2-mkconfig -o /boot/grub2/grub.cfg (BIOS) or the EFI path, and reinstall GRUB if needed (grub2-install /dev/sda on BIOS).
Prevent โ Keep a tested rescue procedure and don't touch /boot layout without a snapshot.
Q179 The kernel panics at boot: Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0).
Advanced
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0).Likely causes โ Missing or broken initramfs for that kernel (an interrupted update, /boot full during install), so the kernel has no drivers to find root.
Diagnose โ Boot an older kernel from the GRUB menu, then:
ls -l /boot/initramfs-* /boot/initrd.img-*
df -h /boot
rpm -q kernel || dpkg -l 'linux-image*'Fix โ Free space in /boot, then rebuild: dracut -f --kver <newver> (RHEL) or update-initramfs -c -k <newver> (Debian), or reinstall the kernel package.
Prevent โ Keep /boot usage low (installonly_limit), and alert on it.
Q180 Boot hangs for 90 seconds with A start job is running for dev-disk-by\x2duuid-...device (1min 30s).
Intermediate
A start job is running for dev-disk-by\x2duuid-...device (1min 30s).Likely causes โ An fstab or crypttab entry (often swap or a data disk) references a device that no longer exists.
Diagnose โ
journalctl -b | grep -i 'timed out waiting for device'
systemd-escape -u 'dev-disk-by\x2duuid-...'
blkid; cat /etc/fstabFix โ Correct the UUID or remove the entry, add nofail (and x-systemd.device-timeout=10s) for optional devices.
Prevent โ Update fstab whenever disks are replaced or reformatted.
Q181 Logs from different servers are out of order and timedatectl shows System clock synchronized: no and NTP service: inactive.
Beginner
timedatectl shows System clock synchronized: no and NTP service: inactive.Likely causes โ No time sync daemon running (chrony not installed/enabled, or conflicting ntpd and chronyd).
Diagnose โ
timedatectl
systemctl status chronyd ntpd systemd-timesyncd 2>/dev/null | grep -E 'Loaded|Active'Fix โ sudo dnf install -y chrony && sudo systemctl enable --now chronyd (or systemctl enable --now systemd-timesyncd on minimal Ubuntu), then timedatectl set-ntp true. Run only one sync daemon.
Prevent โ Include chrony in the base image and alert on unsynchronised hosts.
Q182 chronyc sources shows all servers with ? or ^? and the clock is drifting.
Intermediate
chronyc sources shows all servers with ? or ^? and the clock is drifting.Likely causes โ NTP servers unreachable: UDP 123 blocked by a firewall/security group, wrong server names, or DNS failing for pool names.
Diagnose โ
chronyc sources -v
chronyc activity
getent hosts 2.pool.ntp.org
sudo tcpdump -ni any udp port 123 -c 10Fix โ Allow outbound UDP 123, or use an internal/cloud time source (169.254.169.123 on AWS, metadata.google.internal on GCP). Restart chronyd.
Prevent โ Use the cloud provider's local time service; monitor chronyc tracking offset.
Q183 The clock is 10 minutes off and chrony is running, but it corrects only very slowly.
Intermediate
Likely causes โ chrony slews (gradually adjusts) the clock after startup, and only steps it during the first updates if makestep allows. Large offsets later take a long time to slew away.
Diagnose โ
chronyc tracking # System time offset
grep makestep /etc/chrony.confFix โ Step it now: sudo chronyc makestep. Keep makestep 1.0 3 in chrony.conf so large offsets at boot get stepped.
Prevent โ Investigate why it drifted (VM pause/resume, wrong clocksource, NTP blocked).
Q184 A cron job hasn't run for days; nothing in its log, no errors.
Beginner
Likely causes โ The cron daemon isn't running or isn't enabled, the crontab file is invalid, or the job's own log is just not being written.
Diagnose โ
systemctl status crond 2>/dev/null || systemctl status cron
journalctl -u crond -u cron --since "2 days ago" | tail
sudo crontab -l -u app
grep CRON /var/log/syslog 2>/dev/null | tail # Debian/UbuntuFix โ sudo systemctl enable --now crond (RHEL) or cron (Debian). Fix crontab syntax errors reported in the journal.
Prevent โ Use a dead-man's switch so missed runs alert, and include the cron service in health checks.
Q185 A file you dropped into /etc/cron.d/ is ignored. The cron log shows nothing about it.
Intermediate
/etc/cron.d/ is ignored. The cron log shows nothing about it.Likely causes โ On Debian/Ubuntu, run-parts naming rules: filenames with dots (e.g. backup.cron) are skipped. Also: missing user field, group/world-writable file, or not owned by root.
Diagnose โ
ls -l /etc/cron.d/
cat /etc/cron.d/backup.cron
journalctl -u cron | grep -i 'bad\|insecure\|wrong'Fix โ Rename to backup (letters, digits, -, _ only), chmod 644, chown root:root, and include the user column: 30 2 * * * root /usr/local/bin/backup.sh.
Prevent โ Lint cron files in config management.
Q186 A crontab entry's last line never runs, but all other lines do.
Intermediate
Likely causes โ The file doesn't end with a newline; cron ignores an unterminated final line (common with files deployed by tools or edited by hand).
Diagnose โ
tail -c1 /etc/cron.d/jobs | xxd # should be 0aFix โ Add a trailing newline: echo >> /etc/cron.d/jobs.
Prevent โ Use templates that end with a newline; crontab -e usually handles this.
Q187 A cron job runs at the wrong hour: scheduled for 02:00 but runs at 07:30.
Intermediate
Likely causes โ The system timezone differs from what you assumed (server in UTC, you expected IST), or the timezone was changed and cron wasn't restarted.
Diagnose โ
timedatectl | grep 'Time zone'
date; date -u
systemctl show crond -p ActiveEnterTimestamp 2>/dev/nullFix โ Write schedules in the server's timezone (UTC recommended), or set CRON_TZ=Asia/Kolkata at the top of the crontab where supported (cronie). Restart cron after timezone changes.
Prevent โ Keep servers on UTC and document job times in UTC.
Q188 A systemd timer is enabled but systemctl list-timers shows n/a for NEXT and it never fires.
Intermediate
systemctl list-timers shows n/a for NEXT and it never fires.Likely causes โ The timer was enabled but not started, the OnCalendar= expression is invalid, or the matching .service doesn't exist.
Diagnose โ
systemctl status backup.timer
systemd-analyze calendar 'Mon..Fri *-*-* 02:00:00'
systemctl cat backup.serviceFix โ Correct the expression, daemon-reload, then systemctl enable --now backup.timer.
Prevent โ Validate calendar expressions with systemd-analyze calendar before deploying.
Q189 A daily cron job worked for months but now fails with /bin/sh: 1: /opt/tools/report.sh: not found, although the file exists.
Advanced
/bin/sh: 1: /opt/tools/report.sh: not found, although the file exists.Likely causes โ The script's shebang points to an interpreter that's gone (e.g. #!/usr/bin/python after Python 2 removal), or it's a binary for another architecture or missing its dynamic loader. The "not found" refers to the interpreter, not the script.
Diagnose โ
head -1 /opt/tools/report.sh
file /opt/tools/report.sh
ls -l "$(head -1 /opt/tools/report.sh | sed 's/^#!//; s/ .*//')"Fix โ Update the shebang (#!/usr/bin/env python3), install the interpreter, or rebuild the binary for this architecture.
Prevent โ Use env-based shebangs and test scripts after OS upgrades.
Q190 dmesg shows INFO: task mysqld:2231 blocked for more than 120 seconds.
Advanced
dmesg shows INFO: task mysqld:2231 blocked for more than 120 seconds.Likely causes โ The hung task detector fired: a process stuck in D state for 2+ minutes, usually storage stalls (overloaded or failing disk, unresponsive SAN/EBS, NFS) or huge dirty page writeback.
Diagnose โ
dmesg -T | grep -A 20 'blocked for more than' # kernel stack shows where it waits
iostat -xz 1 5
cat /proc/pressure/io
grep -E 'Dirty|Writeback' /proc/meminfoFix โ Resolve the storage bottleneck (faster volume, fix the failing device), tune dirty page limits, or fix the network storage.
Prevent โ Alert on hung task messages and disk latency; don't run databases on network storage without performance guarantees.
Q191 A server rebooted unexpectedly overnight. How do you find out why?
Intermediate
Likely causes โ Kernel panic, OOM-induced watchdog, hardware fault, power loss, a scheduled automatic update reboot, or someone ran reboot.
Diagnose โ
last -x | grep -E 'reboot|shutdown' | head
journalctl --list-boots
journalctl -b -1 -e # end of the previous boot
journalctl -b -1 | grep -Ei 'panic|watchdog|oom|reboot|shutdown'
ls /var/crash/ 2>/dev/nullCheck the cloud provider's events and hardware logs (ipmitool sel list).
Fix โ Depends on the cause found: clean shutdown messages point to a person or automation; an abrupt end of logs points to panic, power or hardware.
Prevent โ Persistent journal, kdump, and monitoring of hardware events.
Q192 dmesg shows watchdog: BUG: soft lockup - CPU#3 stuck for 23s! on a VM.
Advanced
dmesg shows watchdog: BUG: soft lockup - CPU#3 stuck for 23s! on a VM.Likely causes โ The CPU didn't schedule for a long time: on VMs usually hypervisor contention (vCPU not run, host overloaded, live migration); on bare metal, a kernel or driver bug.
Diagnose โ
dmesg -T | grep -A 30 'soft lockup' # stack trace of what was running
mpstat 1 5 # %steal
uname -rCheck hypervisor/cloud events for host maintenance.
Fix โ For steal/hypervisor issues, move the VM or resize the host. For driver bugs, update the kernel/driver indicated in the stack.
Prevent โ Avoid overcommitted hosts for latency-sensitive VMs; keep kernels current.
Q193 modprobe fails with modprobe: ERROR: could not insert 'vboxdrv': Key was rejected by service.
Intermediate
modprobe fails with modprobe: ERROR: could not insert 'vboxdrv': Key was rejected by service.Likely causes โ Secure Boot is enabled and the module isn't signed with a trusted key.
Diagnose โ
mokutil --sb-state
modinfo vboxdrv | grep -i sig
dmesg | grep -i 'lockdown\|signature'Fix โ Sign the module and enroll the key with mokutil --import, or use the distro's signed module packages.
Prevent โ Use DKMS with automatic signing configured for third-party modules.
Q194 After a kernel update, an out-of-tree driver (e.g. NVIDIA or a storage driver) doesn't load: modprobe: FATAL: Module nvidia not found in directory /lib/modules/6.x....
Intermediate
modprobe: FATAL: Module nvidia not found in directory /lib/modules/6.x....Likely causes โ The module was built for the previous kernel and hasn't been rebuilt (DKMS not installed, build failed, or missing kernel headers).
Diagnose โ
uname -r
dkms status
rpm -q kernel-devel-$(uname -r) || dpkg -l linux-headers-$(uname -r)Fix โ Install matching headers and rebuild: dkms autoinstall -k $(uname -r), or boot the previous kernel until the vendor package supports the new one.
Prevent โ Use DKMS or kmod packages, and lock kernel versions on hosts with critical out-of-tree drivers.
Q195 A server suddenly remounts root read-only during the day and apps start failing with Read-only file system. The disk is an EBS/cloud volume.
Advanced
Read-only file system. The disk is an EBS/cloud volume.Likely causes โ The block device returned I/O errors or timed out (cloud volume impairment, NVMe timeouts), and ext4 with errors=remount-ro protected itself.
Diagnose โ
dmesg -T | grep -Ei 'nvme|I/O error|EXT4-fs error|Remounting'
cat /sys/module/nvme_core/parameters/io_timeoutCheck the cloud console for volume status checks.
Fix โ Schedule a reboot, which runs fsck on the next mount; if the volume is impaired, restore from snapshot. Make sure the NVMe I/O timeout follows the cloud's guidance (e.g. a high nvme_core.io_timeout on AWS).
Prevent โ Volume health alarms, snapshots, and redundant architecture so one volume isn't critical.
Q196 journalctl -b -1 says Specifying boot ID or boot offset has no effect, no persistent journal was found.
Beginner
journalctl -b -1 says Specifying boot ID or boot offset has no effect, no persistent journal was found.Likely causes โ journald is in volatile mode (no /var/log/journal), so previous boots weren't saved.
Diagnose โ
ls -ld /var/log/journal
grep -i '^Storage' /etc/systemd/journald.confFix โ For this incident, check /var/log/messages or syslog if rsyslog runs, or central logs. Then enable persistence: mkdir -p /var/log/journal && systemctl restart systemd-journald.
Prevent โ Persistent journal in the base image.
Q197 A VM boots very slowly, and systemd-analyze blame shows NetworkManager-wait-online.service taking 1m30s.
Intermediate
systemd-analyze blame shows NetworkManager-wait-online.service taking 1m30s.Likely causes โ An interface configured for DHCP never gets a lease (an unused NIC), so wait-online waits for its timeout.
Diagnose โ
systemd-analyze critical-chain
nmcli dev status
journalctl -b -u NetworkManager | grep -i dhcpFix โ Disable autoconnect on unused interfaces (nmcli con mod <name> connection.autoconnect no), or mark them not required. Disable wait-online only if no service needs network-online.target.
Prevent โ Keep network profiles in images minimal and accurate.
Q198 After a power outage, the server boots but /var is mounted read-only and dmesg shows EXT4-fs (dm-2): warning: mounting fs with errors, running e2fsck is recommended.
Advanced
/var is mounted read-only and dmesg shows EXT4-fs (dm-2): warning: mounting fs with errors, running e2fsck is recommended.Likely causes โ Unclean shutdown left inconsistencies the journal couldn't resolve; ext4 detected errors.
Diagnose โ
sudo tune2fs -l /dev/mapper/vg0-var | grep -Ei 'state|errors'
findmnt /var
dmesg -T | grep EXT4Fix โ Boot into rescue or emergency mode so /var isn't in use (systemctl rescue), unmount it, run e2fsck -f /dev/mapper/vg0-var, then reboot. Take a snapshot first if the data matters.
Prevent โ UPS, storage with battery-backed cache, and monitoring of filesystem error state.
Q199 systemctl reports System has not been booted with systemd as init system (PID 1). Can't operate.
Intermediate
systemctl reports System has not been booted with systemd as init system (PID 1). Can't operate.Likely causes โ You're inside a container, a chroot or WSL instance without systemd, where PID 1 is something else.
Diagnose โ
ps -p 1 -o comm=
cat /proc/1/cgroup | head -3Fix โ In containers, run processes directly or use the image's entrypoint. In a chroot (rescue), use systemctl --root=/mnt/sysroot enable foo for offline changes. On WSL, enable systemd in /etc/wsl.conf ([boot] systemd=true).
Prevent โ Don't rely on systemd in container images.
Q200 The kernel logs TCP: out of memory -- consider tuning tcp_mem and network connections start failing on a busy proxy.
Advanced
TCP: out of memory -- consider tuning tcp_mem and network connections start failing on a busy proxy.Likely causes โ Total TCP buffer memory reached the net.ipv4.tcp_mem pressure/max limits (many connections with large buffers or slow clients), or orphaned sockets are piling up.
Diagnose โ
cat /proc/net/sockstat # TCP: inuse, orphan, mem (in pages)
sysctl net.ipv4.tcp_mem net.ipv4.tcp_max_orphans
ss -sFix โ Raise net.ipv4.tcp_mem (in pages) in line with RAM, reduce per-socket buffer maximums if they are oversized, and set timeouts so slow or idle clients get closed.
Prevent โ Graph sockstat memory and orphans; size proxies for peak connection counts.