
The solution is, first you need to verify that the package is installed or not.
mount -o remount,rw /
passwd root
To identify the most resource-intensive processes, run:
echo b > /proc/sysrq-trigger
mount -o remount,rw /sysroot
chroot /sysroot
passwd root
sudo apt install testdisk # Debian-based
sudo yum install testdisk # RHEL-based
df -h
Step 2: Find and Delete Large Files
You accidentally deleted an important file using the rm command, and now you need to recover it. Unlike Windows and macOS, Linux does not have a built-in “Recycle Bin” for files deleted from the terminal.
You can reset the root password by booting into recovery mode or modifying the GRUB bootloader.
You installed a package, but it says “command not found
” when you try to run it, which usually happens when the binary isn’t in your system’s PATH, the package isn’t installed correctly, or there’s a missing dependency.
-
- Use trash-cli: Instead of
rm
, usetrash-cli
to send files to a recoverable trash bin.
- Use trash-cli: Instead of
Over time, old logs may no longer be needed, making them prime candidates for cleanup.
Once logged in, check the system’s load and resource usage, which will show the system’s load averages over 1, 5, and 15 minutes. A load value higher than the number of CPU cores indicates high demand.
Using Recovery Mode (Ubuntu/Debian)
sudo testdisk
To restore control, follow these troubleshooting steps.
Your system displays a “No space left on device” error, preventing software updates, logging, and normal operations.
dpkg -l | grep package-name # Debian-based
rpm -qa | grep package-name # RHEL-based
ps aux –sort=-%cpu | head
uptime
sudo extundelete /dev/sdX –restore-all
For XFS, Btrfs, or NTFS Filesystems
This situation can be caused by various issues, including:
sudo umount /dev/sdX
sudo apt install extundelete # Debian-based
sudo yum install extundelete # RHEL-based
Use extundelete, which is an open-source utility designed to recover deleted files from ext3 and ext4 filesystems in Linux.
Removing them is a safe and effective way to free up space without affecting your system’s functionality.
- Restart the terminal or run
hash -r
after installing new packages. - Use package managers like Snap or Flatpak, which handle dependencies better.
Scenario 4: Your System is Running Out of Disk Space
However, the old kernels are not automatically removed and over time, these old kernels can accumulate and take up a significant amount of disk space.
sudo apt install trash-cli
trash-put myfile.txt
- Enable regular backups: Set up rsync or Timeshift to automatically back up important files.
Scenario 2: Recovering a Forgotten Root Password
sudo apt install package-name
sudo yum install package-name
Linux is a powerful and reliable operating system, but even seasoned users encounter unexpected problems. Whether it’s a deleted file, a forgotten root password, or a sluggish system, knowing how to troubleshoot efficiently is key to becoming a true Linux expert.
sudo journalctl –vacuum-time=2d # Deletes logs older than 2 days
sudo apt autoclean # Removes outdated package files
Step 4: Remove Old Kernels (Ubuntu/Debian)
export PATH=$PATH:/usr/local/bin
First, reboot your system and hold Shift
during startup to access the GRUB menu, then select “Advanced options” → “Recovery mode” and choose “Drop to root shell prompt“.
Here, remount the root filesystem as writable and reset the root password.
This guide presents real-world Linux problem-solving scenarios along with step-by-step solutions, which are common among system administrators, developers, and everyday Linux users.
Do you have your own troubleshooting tips? Share them in the comments! Let’s build a helpful Linux community together.
- Set Up Log Rotation: Use logrotate to automatically manage log file sizes and retention periods.
- Monitor Disk Usage: Install tools like ncdu to track disk usage and identify space hogs.
- Regular Cleanups: Schedule periodic cleanups to remove temporary files, caches, and unused packages.
Scenario 5: Your Server is Suddenly Unresponsive
Here’s how to reclaim disk space and keep your system running smoothly.
If the system is completely frozen, use the SysRq key combination to reboot safely:
- High CPU or memory usage due to runaway processes.
- Disk I/O bottlenecks, where the system is overloaded with read/write operations.
- Kernel panics or system crashes.
- Network failures, preventing remote access.
sudo tail -f /var/log/syslog
Or
sudo dmesg | tail
exit
reboot
kill -9 PID
If the system is still responsive, check logs for errors:
du -ah / | sort -rh | head -10
Step 3: Remove Unnecessary Logs
reboot
Using rd.break (RHEL/CentOS/Fedora)
top
Or
htop
Your recovery options depend on the filesystem in use.
Step 4: Check System Logs
sudo apt autoremove –purge
which package-name
echo $PATH
The solution is, first you need to check how much space is used on each partition on your system using the df command.
Next, mount the root filesystem and reset the root password.
Conclusion
Troubleshooting is an essential skill for every Linux user. Whether it’s recovering deleted files, resetting passwords, or fixing system errors, knowing the right commands can save time and frustration.
You are managing a Linux server, and suddenly, it stops responding and you try connecting via SSH, but the connection times out or refuses to establish. You might even notice that the server is still powered on, but it doesn’t react to any commands.