How To Clean Up Space In Centos 7
If you've stumbled upon this post, it most likely means that y'all're looking for a style to free some reasonable corporeality of disk infinite on a CentOS 7 machine.
In this commodity I'll try to summarize some easy techniques that can be easily pulled off using the command-line / terminal to fullfill such task; each command has been tested on a CentOS vii automobile, but about of them volition as well work on any other Linux environment.
Testify complimentary disk space
The first matter to do is to check how much free disk space nosotros practice have on our CentOS drive. There are a lot of useful tools that can do that, the best one of them arguably being gt5 - a freeware terminal utility that shows the available disk infinite using a neat colored interface:
If you want to use gt5, y'all can download it from hither.
If you don't want to install an boosted package, you lot tin can also use the born df system utility - which is already included in CentOS - and obtain a similar result using the following control:
Which should return the post-obit info:
Now nosotros know how much disk space we do have: in the in a higher place screenshot, we can run into how the situation is quite troublesome, since we do have only 4.3 free MB left.
Install yum-utils
The next affair to practice is to install the yum-utils package using the post-obit control:
This package consists of a collection of utilities that integrate with yum to extend its native features in several ways, thus making it more powerful and easier to utilize.
In the unlikely example nosotros do not have the required amount of disk infinite to perform the install of yum-utils, the best thing nosotros tin can do is to manually delete some log file from the /var/log binder: luckily enough the package is quite small, therefore a couple log files (for a total amount of ~1-2 MB) should do the trick.
Trim log files
At present we can offset to clean upwards our arrangement. Let'due south first with the post-obit command, that will truncate all the log files on the /var/ folder that are either older than 7 days and greater than 50M or older than xxx days.
| observe / var - name "*.log" \ ( \ ( - size + 50M - mtime + 7 \ ) - o - mtime + 30 \ ) - exec truncate { } -- size 0 \ ; |
Correct after doing that, information technology could be useful to repeat the gt5 or df -h command to see how much disk space we've recovered.
Clean up YUM cache
The adjacent thing we should do is to cleanup our YUM cache with the following command:
Unfortunately, the above command don't always remove everything, therefore it can exist useful to also perform a direct cleanup of the main YUM cache binder:
And also the YUM user-enshroud binder:
Again, once we've done that, we should repeat the gt5 or df -h command to meet how much disk infinite we've recovered.
Remove orphan packages
The adjacent thing to do is to bank check the installed orphan packages to see if nosotros tin can safely remove them; by orphaned packages we mean all packages which no longer serve a purpose of package dependencies.
Let'south attempt to explain this concept with a quick case: package A is depended on package B, thus, in order to install bundle A the package B must also be installed. Once the package A is removed the parcel B might still exist installed, hence the bundle B is now orphaned package.
Hither's how we can safely see the orphan packages we do have on our organization:
| package - cleanup -- quiet -- leaves -- exclude - bin |
And here'south how we tin delete them:
| bundle - cleanup -- quiet -- leaves -- exclude - bin | xargs yum remove - y |
The to a higher place commands should be launched multiple times, because the packages deleted with the first batch could create boosted orphan packages, and so on: be sure to perform these tasks until no orphan packages appear anymore afterwards the offset package-cleanup command.
Remove WP CLI buried WordPress downloads
If the CentOS machine you're cleaning is a Web Server hosting one or more WordPress instances, you might want to clean the WordPress CLI cache besides. WordPress CLI saves WordPress archives every fourth dimension yous setup a new WordPress website: these athenaeum can exist removed with the following commands:
| rm - rf / root / .wp - cli / cache / * rm - rf / home / * / .wp - cli / cache / * |
Remove former kernels
Whenever you update your CentOS kernel, the former kernel gets backupped past the system for prophylactic reasons: however, you rarely demand all of them. Hither's a useful control that can exist used to only keep the 2 latest kernels installed, thus removing the previous ones:
| package - cleanup -- oldkernels -- count = 2 |
This control should hopefully recover a good amount of deejay space, equally shown in the following screenshot.
Remove Composer cache
Once again, if your CentOS machine is a spider web server, it could be useful to cleanup the Composer cache. Composer is an awarding-level package manager for the PHP programming language that provides a standard format for managing dependencies of PHP software and required libraries; every time nosotros utilize information technology, it creates a enshroud of previous packages that can be safely removed to free upwards some disk space with the following commands:
| rm - rf / root / .composer / enshroud rm - rf / home / * / .composer / cache |
Conclusions
That's it: I sincerely hope that the above commands will help you to cleanup your CentOS drive and complimentary some disk space. If you take additional general-purpose suggestions that can be used fo fullfill such task, experience free to describe them in the comments section: we'll be happy to add them to this mail!
Source: https://www.ryadel.com/en/clear-free-disk-space-centos-7-linux/
Posted by: gonzalezpurping.blogspot.com

0 Response to "How To Clean Up Space In Centos 7"
Post a Comment