Best 4 Steps To Clean Up Unnecessary and Junk Files on Ubuntu

Posted on

Best 4 Steps To Clean Up Unnecessary and Junk Files on Ubuntu

Best 4 Steps To Clean Up Unnecessary and Junk Files on Ubuntu

In this guide, you will learn to Clean Up Unnecessary and Junk Files on Ubuntu using the terminal. After some time, you may find out that you are running out of space on your Ubuntu server. So to solve this problem, you should clear your Unnecessary and Junk files. Now you can proceed to the following steps on the Orcacore website to Clean Up Unnecessary and Junk Files on Ubuntu and get more space from the terminal.

To complete this guide, you must have access to your Ubuntu servers such as Ubuntu 22.04 and Ubuntu 20.04 as a root or non-root user with sudo privileges and follow the steps below.

Step 1 – Remove all Unnecessary Apps from Ubuntu

The first step is to delete or remove your unwanted applications, folders, and files from your Ubuntu system. Then, proceed to the next step. This is a crucial initial step to reclaiming disk space when you want to Clean Up Unnecessary and Junk Files on Ubuntu.

Step 2 – Remove Junk Files on Ubuntu

When you remove your unwanted applications, some junk files and data aren’t removed from your server. So you can easily remove these files by using the Ubuntu inbuilt cleaner. To do this, run the command below in your Ubuntu terminal:

apt-get autoremove

This command removes packages that were automatically installed to satisfy dependencies for some package and are no longer needed. It helps significantly in the process to Clean Up Unnecessary and Junk Files on Ubuntu.

Step 3 – Clean up the Thumbnail Cache on Ubuntu

The thumbnail cache stores images that are scaled to a size that was previously requested by a client. Thumbnails are stored in a hidden directory in your user account at the location ~/.cache/thumbnails.

Before deleting the thumbnails cache, you can check the size of them with the command below:

du -sh ~/.cache/thumbnails

This command provides a human-readable summary of the disk space used by the thumbnails directory.

Then, you can easily clean up your thumbnails cache on Ubuntu with the command below:

rm -rf ~/.cache/thumbnails/*

Important Note: Be very careful when using rm -rf. This command forcefully removes the directory and all its contents without prompting for confirmation. Double-check the path before executing. This is a powerful command that contributes to helping you Clean Up Unnecessary and Junk Files on Ubuntu.

Step 4 – How To Clean Ubuntu System from the Terminal?

At this point, you can regularly clean up your Ubuntu server. APT Cache keeps all the files that you have downloaded, installed, or uninstalled on your Ubuntu system. It keeps them in the /var/cache/apt/archives directory.

You can check your APT cache size by using the following command:

du -sh /var/cache/apt

Then, you can easily clean up your Ubuntu system cache by using the command below:

apt-get clean

In order to keep your system clean, you should clear your apt cache regularly. Regular maintenance is key if you want to Clean Up Unnecessary and Junk Files on Ubuntu consistently.

Conclusion

At this point, you have learned to Clean Up Unnecessary and Junk Files on Ubuntu. If you are running out of space, you can easily use these methods to free up your space.

Hope you enjoy it. You may also be interested in these articles:

Netplan Gateway is Deprecated Use Default Routes on Ubuntu

Install CloudPanel on Ubuntu and Debian

Check Connected WiFi Password on Ubuntu Linux

Alternative Solutions for Cleaning Up Unnecessary and Junk Files on Ubuntu

While the terminal commands outlined above are effective for cleaning up your Ubuntu system, here are two alternative methods that provide different approaches and benefits:

1. Using BleachBit for a Comprehensive Clean:

BleachBit is a free and open-source disk space cleaner, privacy manager, and system optimizer. It goes beyond the basic cleaning offered by apt-get and rm, targeting a wider range of junk files and temporary data. It can clean:

  • APT cache
  • Browser history, cookies, and cache (Firefox, Chrome, etc.)
  • System logs
  • Temporary files
  • Thumbnail cache
  • And much more!

BleachBit offers a graphical user interface (GUI), making it more accessible for users who are less comfortable with the command line. It also allows you to preview the files that will be deleted before actually cleaning, reducing the risk of accidentally removing important data.

Installation:

You can install BleachBit from the Ubuntu software center or using the terminal:

sudo apt update
sudo apt install bleachbit

Usage:

  1. Open BleachBit from your applications menu.
  2. Select the categories of files you want to clean (e.g., "APT", "Firefox", "System").
  3. Review the details of what will be cleaned.
  4. Click "Clean" to start the process.

Caution: BleachBit can be powerful, so use it with care. Some options, especially those related to overwriting free space, can take a very long time. Always understand what you’re cleaning before proceeding.

2. Using deborphan to Identify and Remove Orphaned Packages:

deborphan is a command-line tool that helps identify orphaned packages on your system. Orphaned packages are libraries and dependencies that were installed to support other applications but are no longer required because those applications have been removed. These orphaned packages can consume valuable disk space.

Installation:

You can install deborphan using the terminal:

sudo apt update
sudo apt install deborphan

Usage:

  1. Run deborphan to list orphaned packages:
deborphan

This will output a list of package names.

  1. To remove these packages, you can pipe the output of deborphan to apt-get remove:
sudo apt-get remove --purge $(deborphan)

The --purge option ensures that configuration files associated with the packages are also removed.

Important Considerations:

  • Carefully review the list of packages identified by deborphan before removing them. While generally safe, there’s a small chance it might misidentify a package. If you are unsure about a package, research it before removing it.
  • After removing orphaned packages, it’s a good practice to run sudo apt autoremove to clean up any remaining dependencies.

These alternative methods provide different ways to Clean Up Unnecessary and Junk Files on Ubuntu, catering to different user preferences and levels of technical expertise. Combining these approaches with the original terminal commands can help you maintain a clean and efficient Ubuntu system.

Leave a Reply

Your email address will not be published. Required fields are marked *