Delete useless cache and junk files in Ubuntu [Transfer]

Linux and Windows systems are different. Linux will not generate useless junk files, but in the upgrade cache, Linux will not automatically delete these files, which still take up a lot of hard disk space!

1. Delete cache

1. Very useful cleaning commands: These three commands mainly clean the upgrade cache and useless packages.

sudo apt-get autoclean              # 清理旧版本的软件缓存
sudo apt-get clean                  # 清理所有软件缓存
sudo apt-get autoremove             # 删除系统不再使用的孤立软件

2. Clean the cache files of opera firefox:

ls ~/.opera/cache4
ls ~/.mozilla/firefox/*.default/Cache

3. Clean up orphaned packages under Linux:

sudo apt-get install deborphan -y

4. Uninstall: tracker

This thing is usually the first thing I delete when installing Ubuntu. It will not only generate a large number of cache files but also affect the boot speed. So just delete it in Xindeli.

Appendix:
Temporary file directory for package management:
Software package: /var/cache/apt/archives
Undownloaded software package: /var/cache/apt/archives/partial

2. Delete software

sudo apt-get remove --purge 软件名
sudo apt-get autoremove                                   # 删除系统不再使用的孤立软件
sudo apt-get autoclean                                    # 清理旧版本的软件缓存
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P    # 清除残余的配置文件

3. Delete redundant kernels

1. Check the kernel used by the current Ubuntu system

uname -a

2. View all cores

dpkg --get-selections|grep linux

3. Delete the lower version of the kernel (my kernel is 5.15.0-30)

sudo apt-get remove linux-image-5.15.0-25-generic
sudo apt-get remove linux-image-unsigned-5.15.0-25-generic
sudo apt-get remove linux-headers-5.15.0-25
sudo apt-get remove linux-headers-5.15.0-25-generic
sudo apt-get remove linux-modules-5.15.0-25-generic
sudo apt-get remove linux-modules-extra-5.15.0-25-generic

After deletion, use the uname -a command to check again. It is found that there are still some deinstalled kernels. Use the following command to clean up those deinstalled kernels.

dpkg --get-selections | grep deinstall | sed 's/deinstall/\lpurge/' | sudo dpkg --set-selections                    # 删除标注为“purge”的软件
sudo dpkg -Pa

Original address: https://www.iteye.com/blog/fox-leon-1305501

Original address: Linux deletes redundant kernels and displays deinstall software_I’m just a porter’s blog-CSDN blog_deinstall linux

Guess you like

Origin blog.csdn.net/ynstxx/article/details/124932071