什么是“sudo apt-get clean”?

什么是“sudo apt-get clean”?

当我收到软件更新消息并单击安装时,我收到一条消息“空间不足”,告诉我清空垃圾箱并删除临时文件sudo apt-get clean。我清空了垃圾箱,但我仍然收到相同的消息,不知道要删除哪些临时文件或是什么sudo apt-get clean

答案1

sudo apt-get clean清除本地存储库中检索到的包文件。它会删除除锁定文件之外的所有内容/var/cache/apt/archives//var/cache/apt/archives/partial/.

来源 :man apt-get

查看使用该命令时发生的情况的另一种可能性sudo apt-get clean是使用 -option 模拟执行-s

~$ apt-get -s clean
NOTE: This is only a simulation!
      apt-get needs root privileges for real execution.
      Keep also in mind that locking is deactivated,
      so don't depend on the relevance to the real current situation!
Del /var/cache/apt/archives/* /var/cache/apt/archives/partial/*
Del /var/lib/apt/lists/partial/*
Del /var/cache/apt/pkgcache.bin /var/cache/apt/srcpkgcache.bin
~$ sudo apt-get -s clean
[sudo] password for mook: 
Del /var/cache/apt/archives/* /var/cache/apt/archives/partial/*
Del /var/lib/apt/lists/partial/*
Del /var/cache/apt/pkgcache.bin /var/cache/apt/srcpkgcache.bin

感谢@jarno 的建议。

答案2

如果收到消息“空间不足”并且命令sudo apt-get clean不足,请尝试以下操作:

打开终端,

Ctrl++AltT

运行:

sudo -i   # (Allows you to execute commands with the privileges of the superuser.)       

KERNELCUR=$(uname -r | sed 's/-*[a-z]//g' | sed 's/-386//g')
PKGLINUX="linux-(image|headers|ubuntu-modules|restricted-modules)"
METAPKGLINUX="linux-(image|headers|restricted-modules)-(generic|i386|server|common|rt|xen)"
KERNELSOLD=$(dpkg -l | awk '{print $2}' | grep -E "$PKGLINUX" | grep -vE "$METAPKGLINUX" | grep -v "$KERNELCUR")

apt-get purge "$KERNELSOLD"   # (Remove old kernels.)

CONFOLD=$(dpkg -l | grep '^rc' | awk '{print $2}')  

apt-get purge "$CONFOLD"   # (Removes configuration files from deb packages that have been uninstalled.)
apt-get autoremove   # (Deletes orphaned packages, or dependencies that remain installed after you have installed an application and then deleted it.)
apt-get clean   # (Removes all packets from the cache.)
rm -rf /home/*/.local/share/Trash/*/** &> /dev/null   # (Empty the trash from all users.)
rm -rf /root/.local/share/Trash/*/** &> /dev/null   # (Empty the trash from root.)

相关内容