Special offer
+370 5 205 5502 sales@monovm.com

Disk Cleanup Methods in CentOS

The safety and security of your personal computer, MacBook, and smartphone is everyone's top priority and concern. When we are in the middle of a critical task, and the Desktop suddenly shows an error or randomly blinks and does something unexpected, we all become extremely frustrated and restless. Most of the error messages show that the personal computer needs a restart or has to complete troubleshooting that takes a decent amount of time. These obstacles or hurdles are caused by the system's faulty hardware or software that can occur due to many different predictable and unpredictable reasons.

25 Apr, 19 by Susith Nonis 14 min Read

Clear Disk Space on CentOS 6, 7, 8

There are solutions to the problem- some expensive and time-consuming while others are efficient. You can either opt to buy a new storage device or memory, but these will cost you far more than doing a simple and inexpensive disk cleanup on the system.

What is a Disk Cleanup, and Why Is It Done on the System?

Disk cleanup refers to a software utility or program developed by the Microsoft Corporation and is available for free for all the people using Windows Operating System on their Desktop. The intention and usage of the feature or tool are to eliminate unwanted files and folders that you may not need in the long run. It scans and locates all these files that are no longer needed, takes up a large amount of space on the disk, and gets rid of them by permanently removing them from the disk and the Desktop.

There are a large number of different file types that disk cleanup identifies and proceeds to remove. Some of them are listed below:

  • Temporary Windows Files 

These are the files created temporarily by the system to achieve a task. All these files end with the extension "temp" and can generally be created and located in the same folder or directory as the original file. The purpose of these files is to store data temporarily, and once the task is accomplished, all these files take up unnecessary space and require to be deleted. Hence are targeted by disk cleanup. It is generally completely safe to delete these files, and most of these files are created again when the same software program or task is to be run that created the earlier version.

  • Setup Logs and Files

These are the system files when a software program or setup is first launched. Log files keep records of the process and can be utilized later to identify any setup issues. The files can also be immediately referred to when a setup interrupts unexpectedly and needs repair. Once the setup is done, these log files become unnecessary and require deleting from the system, exactly what disk cleanup does.

  • Temporary Internet Files and Cached Offline Web Pages 

The windows operating system and browser Stores some temporary information about the web pages a person visited and the content available on certain websites and pages to quickly access and view them in the future. This enables the web browser such as Google Chrome to check for important information in these files and load the content as quickly as possible; the next time a person views the same page. Users at many times do not wish that such data is stored on the system and the browser and hence can use disk cleanup to remove them apart from directly deleting them from the browser settings.

  • Downloaded Program Files

These are software applications temporarily stored under a folder having the same name. These files usually have an extension of ".exe" or can be stored in the form of archived files or ZIPs. These files are downloaded from the internet automatically while using a browser such as Internet Explorer and can contain potentially harmful malware and be cleaned if such is the case.

Apart from working on these types of files, applications, or software programs, disk cleanup also targets different windows categories, including windows components, the famous "Recycle Bin", remote system files, and many others.

Each time a user works with removing such files using disk cleanup, it shows all the information associated with these files, such as the name of the file, storage location and path, and the amount of space they take up in the system. These pieces of details can be beneficial to assist in targeting what to get rid of and where to find these files.

The disk cleanup utility also comes with additional benefits, such as compressing files that will take up way less space than earlier. A file with a small size ensures a faster read and writing time for the computer, and opening and accessing it takes less time.

Disk cleanup gives its users the ability and option to handpick what to remove and what not to, instead of deleting everything it analyzes to be of no use. Apart from using disk cleanup, users can also use other similar windows tools and features that essentially achieve the same thing disk cleanup does.

How to Perform a Simple Disk Cleanup on your System?

Disk cleanup is fairly easy to perform on your Windows personal computer. To do that, all you need to do is access the utility on the system and follow the given steps.

  • Step 1: Open up the search bar and look for disk cleanup by typing the same in the bar. You can also locate disk cleanup by going to the "C" Drive in the My Computer, right-click on the drive icon, and select properties. Another way to open the disk cleanup dialogue box is by using the run bar. Press the "run" option available under the windows button menu. All you have to do now is type the "cleanmgr" word in the run bar and hit enter key on the keyboard. The disk cleanup dialogue box or windows prompt (depending on the Windows version) will open up on the screen.
  • Step 2: Now, you can choose from the list of all available files and options that disk cleanup provides for you to remove by selecting the small checkboxes beside the left-side options.
  • Step 3: From under the "Files to Delete" Option, after choosing the type of files to get rid of, click OK. A confirmation window prompt will be shown to ensure that you want to perform the task. If you want to delete these files permanently, click "OK" again on the prompt.
  • Step 4: Once you are finished with a particular file type, you can also free up much more space on the system using the "Clean Up System Files" option available under Disk cleanup, which gets rid of the unwanted system files as well.
  • Step 5: Once again, select all the types of files you want to remove by clicking on the checkbox and click on "OK". 
  • Step 6: This completes your cleanup of unimportant files and frees up space on your computer. You can look under the drive storage and properties option to verify the same. Note-When you delete some system update files or other types of downloaded programs and applications, you may have to restart your personal computer in these cases. Also, run disk cleanup as administrator whenever it causes issues or shows a blank screen.

Cleaning Up Copies of System Updates Files

To answer how and why we need to remove these files, we first need to know and understand system updates and files. These are programs and codes that provide users access to newer versions and features of the operating system on a personal computer device. In today's technologically advanced environment, the frequency at which the companies and OS providers roll these updates out is very high. Whenever a new version or update is launched, all the old system files are not always deleted automatically and require you to manually. These files can stay on your personal computer for hours, days, months, and even years, and you might not even have any knowledge about them.

It is when disk cleanup comes in handy. Using the cleanup system files option from the dialogue box, you can choose to delete the old copies of these system update files that will most likely be never needed again. The option can also be located under the "More Options" drop-down if it is not directly visible and is collapsed.

The more options button also provides access to all the related files and components that disk cleanup targets and analyses. In cases where you cannot locate an option, you can always look under this tab or button.

When a user wants to schedule the disk cleanup process automatically, he can easily do so easily with a fairly newer disk cleanup utility function called Storage Sense. All you have to do is set the automatically deleted unwanted files option to the "On" position. You can choose how and what is deleted by clicking on that option. Storage sense usually deletes all those files that have not been in use or are sitting in the recycling bin for at least 30 days. You can even change the behaviour and how frequently storage sense will work by looking into more options available under the windows prompt.

Benefits of Using Disk Cleanup and Storage Sense

One of the most important features and advantages of using Disk cleanup and Storage Sense is the amount of time a person can save by automatically setting up how and when all the unnecessary files will be deleted. Instead of manually locating all the files in all possible directories on your system, all you need to do is use disk cleanup. You can even compress old files that take up quite a lot of space but need not be deleted from the computer. Removing unwanted files and files such as downloaded programs can ensure that your system runs and new and prevents malware risks. Apart from the direct utility, the flexibility, and control over storage space and the system make it extremely useful to opt for start using disk cleanup and storage sense.

By clearing a lot of space from the computer storage and memory, you can ensure faster speeds and much less access time for these files. This greatly increases the system's performance and functionality while requiring very little effort and zero additional cost. A person can even run disk cleanup while their personal computer is operating in "safe mode". The disk cleanup utility is highly usable and secure to use and requires no prior knowledge about system files or categories. The large number of benefits that disk cleanup provides makes it worthwhile to try out. 

Can Disk Cleanup Ensure No Viruses and Remove Them?

Disk cleanup can remove unwanted files automatically downloaded from the internet and web browsers such as Internet Explorer and Google Chrome. These files may or may not contain threats such as malware and viruses, making their way into the system when they are run or opened.

Disk cleanup can get rid of all these files and provide a temporary way to solve the issue. But it does not mean that disk cleanup is a complete alternative to the existing antivirus and malware software. Disk cleanup will occasionally find and remove these files. At the same time, antivirus software constantly detects and removes threats as they are designed to do so. 

For putting it simply, disk cleanup can remove some files containing threats and be effective till viruses are already not in the system and start acting. Rather, disk cleanup provides a complementary way to target this issue while working alongside antivirus software such as Quick Heal, specifically designed to accomplish this task.

Disk cleanup in CentOS 6, 7, 8

In this article, we will go through some quick commands to clear disk space from your CentOS server. Before we go further, we will need to install the yum-utils package.

yum -y install yum-utils

Cleanup YUM cache

yum clean all

This is an easy command to cleanup the yum caches but this may not remove everything concerning yum.

In order to free more space by orphaned data from removed or disabled repositories we will use the subsequent command:

rm -rf /var/cache/yum

In order to get rid of the user-cache which is made when the yum command is run through a regular user (without sudo) then we use this command:

rm -rf /var/tmp/yum-*

Removing old kernels

The following command keeps just the latest 2 kernels installed.

package-cleanup --oldkernels --count=2

Trim log files

The following code will shorten *.log files in the volume /var that are greater than 50M and older than 7 days or older than 30 days.

find /var -name "*.log" \( \( -size +50M -mtime +7 \) -o -mtime +30 \) -exec truncate {} --size 0 \;

Remove orphan packages

First, check the existing orphan packages on your server.

package-cleanup --quiet --leaves --exclude-bin

If you are satisfied with the results the continue in removing the orphan packages by running the subsequent command.

package-cleanup --quiet --leaves --exclude-bin | xargs yum remove -y

Remove Node.js caches

rm -rf /root/.npm /home/*/.npm /root/.node-gyp /home/*/.node-gyp /tmp/npm-*

Remove composer cache

rm -rf /root/.composer/cache

rm -rf /home/*/.composer/cache

Remove core dumps

If you encountered severe failures with PHP which caused it to segfault and core dumps were enabled, then there is a high possibility that there are a few of those in your server. They are no longer needed after you debug the problem, so the following command will remove the files:

find -regex ".*/core\.[0-9]+$" -delete


Disk cleanup, a well-known and free utility part parcel of the Windows Operating System, acts as a handy tool to accomplish various tasks. Apart from deleting different types of files and programs that the disk cleanup utility tool targets, it can compress old files and prevent viruses and malware attacks in its way. This, in turn, increases system performance, speed, memory usage and provides greater reliability, flexibility, and control over everything stored on a desktop. 

To access disk cleanup, all you have to do is use the run or search bar and look for suitable options and commands. Managing everything on the computer is made effortless thanks to the use of disk cleanup and storage sense.

It is not recommended to use disk cleanup as a tool to get rid of viruses by itself. Even though you can remove files containing malware, viruses, and other threats, disk cleanup is not meant and designed to accomplish this task like other antivirus software and applications. Nevertheless, disk cleanup's utility and usability make it a must-try that ensures a better working environment for your personal computer and higher productivity in life.

Susith Nonis

I'm fascinated by the IT world and how the 1's and 0's work. While I veture into the world of Technology I try to share what I know in the simplest way possible. Not a fan of coffee, a sweet addict and a self accredited 'master chef'. 

user monovm


2019, Sep, 19

Nice article, thanks

user monovm

eShopping Nepal

2020, Oct, 20

Thank you for your blog post. I got about 1GB space from my server. Thanks

user monovm

susith nonis

2020, Oct, 20

We're glad it helped you ;)