Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to free up Ubuntu disk space

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will give you a detailed explanation on how to free Ubuntu disk space. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

First, remove packages that are no longer needed

If you know the detailed usage of the apt-get or apt command, you should know the autoremove option. This option removes dependent libraries and packages that are automatically installed when you install a package, which are usually useless in the system and only waste disk space. Of course, the autoremove option can also automatically delete old and useless Linux kernels that have been replaced during a system upgrade.

This is an automated stupid command that you can use to free up some free hard disk space for your Ubuntu system from time to time:

Sudo apt autoremove

As shown in the following figure, China Merchants Bank can release 315MB disk space for my system after this order.

Therefore, it is a good habit to clear the thumbnail cache every few months or so.

Second, the quickest way is to use terminal commands:

Rm-rf ~ / .cache/thumbnails/*

As shown in the following figure, China Merchants Bank can release 315MB disk space for my system after this order.

3. Clean the APT cache in Ubuntu

Ubuntu uses APT (the Advanced package tool) to install, remove, and manage software on the system, and it retains the cache of previously downloaded and installed packages after the software is uninstalled.

The APT package management system caches the downloaded DEB package in the / var/cache/apt/archives file, and over time, all the software in this article can be found in the textbook "this is how Linux should learn". This cache directory can grow considerably because of a large number of unwanted packages.

You can view the size of this cache using the following command:

Sudo du-sh / var/cache/apt

As you can see, I have more cache stores than 90MB. When you have almost no disk space left, this 90MB space can be released to save the emergency.

We have two options for cleaning the APT cache, one is to delete only outdated packages: sudo apt autoclean the other is to clean up the entire cache (freeing up more disk space): sudo apt clean

4. Clean up thumbnails

To make it easier for users to preview pictures, Ubuntu automatically creates a thumbnail for the image file to view in the file manager, and these thumbnails are actually hidden in the file form and stored in the ~ /. Cache/thumbnails directory of the user's account.

If you are a photography enthusiast or a picture collector, the number of thumbnails will increase greatly over time. It is particularly important to note that if you delete some photos or pictures, the automatically generated thumbnail cache will still exist on disk and will not be automatically erased.

You can check the size of the thumbnail cache using the following command:

Du-sh ~ / .cache/thumbnails

Therefore, it is a good habit to clear the thumbnail cache every few months or so. The quickest way is to use the terminal command: rm-rf ~ / .cache/thumbnails/*

Delete the old Linux kernel manually (professional)

In the previous introduction to method 1, it was mentioned that you can automatically delete old and useless Linux Kernel, but if you have manually installed the kernel in Ubuntu, the apt autoremove command option is not applicable. However, deleting older kernels that are not in use does save a lot of disk space, so you can manually uninstall Ubuntu kernels that are manually installed.

First, use the following command to list all installed Linux Kernel in the current Ubuntu:

Sudo dpkg-- list 'linux-image*'*

Deleting an older kernel is the same as deleting any other software package:

Sudo apt remove linux-image-VERSION

Please replace the above VERSION with the kernel version to be cleared. The system geek recommends keeping at least two or three of the latest kernel versions, so that there are at least a few alternative emergencies if the latest kernel cannot be used to boot the system.

6. Uninstall unnecessary applications

It is believed that everyone has one and several games or applications that are rarely used in the system. Don't believe it? Go to your Ubuntu system and check the software list. In fact, I don't need to say much about this, if you need more disk space, it's always a good idea to delete applications that are never used or rarely used. To delete software, you can use "Ubuntu Software" or direct terminal command: sudo apt remove package name

Use GUI tools to free up Ubuntu space

If you really find the content of this article too troublesome and don't like to use these commands and tools, then I recommend a gadget that centrally cleans up the Ubuntu system, through which you can learn how to use the Stacer cleanup tool in Ubuntu.

This is the end of this article on "how to free Ubuntu disk space". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report