Troubleshooting Common Issues
1. Diagnosing Boot Failures
| Issue | Description | Solution |
|---|---|---|
| Black screen after boot | System starts but displays only a black screen | Check hardware connections, try nomodeset in GRUB, or boot into recovery mode |
| Stuck at "Starting kernel..." | Boot process halts during kernel initialization | Boot into recovery mode or single-user mode to check logs in /var/log |
| GRUB menu not appearing | System boots directly to OS without showing GRUB menu | Reinstall GRUB using grub-install or edit /etc/default/grub |
| Filesystem errors during boot | Boot fails due to filesystem corruption or mount issues | Use fsck to repair filesystem or boot from live USB |
Note: Use
journalctl -b to view logs from the last boot session.Warning: Avoid modifying
/boot or /etc/fstab without a backup.Boot Failure Troubleshooting Steps
- Reboot and enter GRUB menu (usually by pressing
ShiftorEsc) - Select "Advanced options for Ubuntu" and try a previous kernel version
- Boot into recovery mode using
rootorsinglein kernel parameters - Run
fsckon the root filesystem if prompted or accessible - Check
/var/log/syslogand/var/log/kern.logfor error messages
2. Recovering from Kernel Panics
| Recovery Method | Description | Notes |
|---|---|---|
| Emergency Boot | Reboot system with emergency or single mode |
Accesses single-user shell; useful for filesystem repairs |
| Kernel Logs | Check /var/log/kern.log or dmesg |
Identifies root cause of panic (e.g., hardware failure, driver issues) |
| Systemd Recovery | Use systemctl rescue or systemctl emergency |
Enters rescue mode to fix critical issues without full reboot |
| GRUB Recovery | Access GRUB menu and select recovery kernel or options | Allows booting with different kernel parameters or modules disabled |
Example: Emergency Boot via GRUB
Press 'e' during boot to edit GRUB entry
Add 'init=/bin/bash' or 'single' to kernel line
Press Ctrl+X or F10 to boot
Note: Kernel panics often indicate hardware or driver issues. Ensure backups are in place before attempting recovery.
Warning: Using
init=/bin/bash gives root access but may leave system in an inconsistent state.
Recovery Steps Summary
- Identify panic logs using
dmesgor/var/log/kern.log - Reboot into single-user or emergency mode
- Run filesystem checks (
fsck) if needed - Reinstall or update problematic drivers
- Check hardware for faults (RAM, CPU, disk)
3. Fixing File System Errors
| Command | Description | Usage |
|---|---|---|
| fsck | File system checker and repair tool | sudo fsck /dev/sda1 |
| dmesg | Display or control the kernel ring buffer | dmesg | grep -i error |
| journalctl | Control the systemd journal | journalctl -b | grep -i error |
Note: Always backup critical data before running fsck.
Warning: Running fsck on a mounted filesystem can cause data loss.
| Error Type | Description | Solution |
|---|---|---|
| No space left on device | File system is full | df -h to check space, remove unnecessary files |
| Permission denied | Insufficient permissions to access file | sudo chmod or sudo chown |
| Corrupted file system | File system structure is damaged | fsck to repair |
4. Resolving Network Connectivity Issues
| Issue | Symptoms | Command/Tool | Solution |
|---|---|---|---|
| No Internet Access | Cannot ping external IPs or resolve domain names | ping 8.8.8.8 |
Check physical connection, verify network interface is up |
| DNS Resolution Failure | Cannot resolve hostnames (e.g., ping google.com fails) |
nslookup google.com |
Check /etc/resolv.conf, test with dig google.com |
| Firewall Blocking | Connection times out or gets reset | iptables -L |
Allow traffic on required ports (e.g., iptables -A INPUT -p tcp --dport 80 -j ACCEPT) |
| Incorrect Gateway | Local network works but no external access | ip route |
Verify default gateway IP in output; update if needed via ip route add default via <gateway> |
Note: Ensure that
firewalld or ufw is not blocking essential services like SSH or HTTP.
Warning: Modifying firewall rules without knowing the impact can lock you out of your system.
5. Debugging Service Failures
| Command | Description | Usage |
|---|---|---|
systemctl status service-name |
Check the status of a specific service | systemctl status nginx |
journalctl -u service-name |
View logs for a specific service | journalctl -u nginx.service |
journalctl -u service-name --since "1 hour ago" |
View logs for a specific service within a time range | journalctl -u nginx.service --since "1 hour ago" |
systemctl restart service-name |
Restart a service | systemctl restart nginx |
systemctl start service-name |
Start a service | systemctl start nginx |
systemctl stop service-name |
Stop a service | systemctl stop nginx |
Example: Check service status and logs
systemctl status nginx
journalctl -u nginx.service --since "1 hour ago"
Note: If the service is not starting, check its configuration file for syntax errors.
Warning: Ensure you have sufficient permissions to restart services.
Common Service Issues and Solutions
- Service not starting: Check logs using
journalctl - Service crashes: Review logs for error messages or stack traces
- Permission denied: Ensure proper user permissions for service files
6. Investigating High CPU Usage
| Command | Description | Usage |
|---|---|---|
| top | Real-time system monitor showing processes | top - shows processes sorted by CPU usage |
| htop | Enhanced version of top with better UI | htop - interactive process viewer |
| ps aux | Report process status with full details | ps aux | sort -nrk 3,3 - sort by CPU usage |
| pidstat | Per-process CPU statistics | pidstat -u 1 5 - report every second for 5 times |
Note: Use
top or htop for real-time monitoring. The -u flag in pidstat shows CPU usage statistics.
| Tool | Functionality | Best For |
|---|---|---|
top |
Live process list sorted by resource usage | Quick real-time checks |
htop |
Enhanced top with color and navigation |
Interactive process management |
ps aux |
Full process listing with detailed stats | Scripting and automation |
pidstat |
Per-process CPU and I/O statistics | Detailed performance analysis |
7. Diagnosing Memory Issues
| Command | Description | Usage |
|---|---|---|
| free -h | Displays memory usage in human-readable format | free -h |
| top | Real-time view of system processes and memory usage | top |
| htop | Enhanced version of top with better UI and features | htop |
| vmstat | Reports virtual memory statistics | vmstat 1 5 |
| ps aux | Lists all running processes with memory usage | ps aux | grep -E 'MEM|PID' |
Example: Check memory usage with free
free -h
total used free shared buff/cache available
Mem: 7.7G 2.1G 3.2G 156M 2.4G 5.2G
Swap: 2.0G 0B 2.0G
Example: Identify memory-hungry processes with ps
ps aux --sort=-%mem | head -n 5
USER PID %MEM VSZ RSS TTY STAT START TIME COMMAND
user 1234 15.2 200000 1500000 ? Sl 12:34 0:05 firefox
user 5678 8.3 120000 800000 ? Sl 12:35 0:03 chrome
Note: RSS (Resident Set Size) indicates physical memory currently used by a process. VSZ (Virtual Size) includes all memory including swapped and shared pages.
Memory Diagnosis Workflow
- Run
free -hto check overall memory and swap usage. - Use
toporhtopto identify processes consuming high memory. - Filter output with
ps aux --sort=-%memto list top memory consumers. - Check for memory leaks or inefficient applications.
8. Resolving Disk Space Issues
| Command | Description | Usage |
|---|---|---|
| df -h | Display disk space usage in human-readable format | df -h |
| du -sh * | Check disk usage of files and directories in current folder | du -sh * |
| ls -l /var/log | List log files to identify large logs | ls -l /var/log |
| find / -type f -size +100M | Find files larger than 100MB | find / -type f -size +100M |
Example: Cleaning up old logs
# Clear old logs to free space
sudo journalctl --vacuum-size=100M
sudo find /var/log -name "*.log" -mtime +30 -delete
Example: Identifying large directories
# Show top 10 largest directories
du -sh /* | sort -hr | head -n 10
Note: Always double-check before deleting files or directories to avoid data loss.
Warning: Be cautious when deleting system logs or files in use.
9. Fixing Permission Problems
| Problem | Solution | Notes |
|---|---|---|
Permission denied (e.g., Permission denied: '/usr/local/bin') |
sudo chown -R $USER:$USER /usr/local/bin |
Use chown to change ownership of files or directories |
| Read-only filesystem error | sudo mount -o remount,rw / |
Remount root filesystem as read-write if needed |
| File or directory not accessible due to permissions | ls -l filename |
Check file permissions using ls -l |
Note: Use
chmod to set file permissions. Common values: 755 (rwxr-xr-x), 644 (rw-r--r--).
Warning: Be cautious when using
sudo chown -R on system directories like /usr/local/bin. It can cause unexpected behavior or break applications.
10. Debugging DNS Issues
| Command | Description | Usage Example |
|---|---|---|
| nslookup | Query DNS to find IP addresses or hostnames | nslookup example.com |
| dig | Advanced DNS lookup tool with detailed output | dig example.com |
| host | Simple DNS lookup utility | host example.com |
| ping | Test network connectivity and DNS resolution | ping example.com |
Note: If
dig or nslookup return NXDOMAIN, the domain does not exist.
Warning: Ensure your DNS server is correctly configured in
/etc/resolv.conf.
| Problem | Possible Cause | Solution |
|---|---|---|
| DNS resolution fails | Incorrect DNS server config | Check /etc/resolv.conf |
| DNS resolution slow | Network issues or DNS server overload | Use dig +trace to trace resolution path |
| Host not found | Domain does not exist or typo in name | Verify domain name and check DNS records |
11. Troubleshooting SSH Access
| Issue | Possible Cause | Solution |
|---|---|---|
| Connection times out | Firewall blocking port 22, SSH service not running, incorrect host | Check ufw status or iptables -L, ensure sshd is running with systemctl status sshd |
| Permission denied (publickey) | Incorrect key, wrong user, permissions on keys | Verify ~/.ssh/id_rsa exists and has correct permissions (600), check ssh-add -l, ensure user matches server config |
| Host key verification failed | Host key changed or unknown host in ~/.ssh/known_hosts |
Remove line from known_hosts or run ssh-keygen -R [hostname] |
| Too many authentication failures | Too many keys loaded in SSH agent | Run ssh-add -D to clear all keys, then re-add only needed ones |
Note: Ensure the SSH daemon (
sshd) is enabled and running on the target machine.
Warning: Do not disable SSH access without another way to manage the system (e.g., console or KVM).