什么是“sudo apt-get clean”?

Pet*_*ter 18 apt disk-usage

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

moo*_*765 18

sudo apt-get clean清除检索到的包文件的本地存储库。它从/var/cache/apt/archives//var/cache/apt/archives/partial/.

来源 : man apt-get

查看使用该命令时会发生什么的另一种可能性是使用-optionsudo apt-get clean模拟执行-s

mook@MookPC:~$ apt-get -s clean
注意:这只是一个模拟!
      apt-get 需要 root 权限才能真正执行。
      还请记住,锁定已停用,
      所以不要依赖于与真实当前情况的相关性!
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
mook@MookPC:~$ sudo apt-get -s clean
[sudo] 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 的建议。

  • 您可以通过以普通用户身份运行 `apt-get -s clean` 来模拟该命令以显示它会做什么。除了上面提到的文件之外,它似乎还删除了 /var/cache/apt/ 中的几个文件。 (2认同)

kyo*_*ake 4

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

打开终端,

Ctrl+ Alt+T

运行:

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.)
Run Code Online (Sandbox Code Playgroud)


归档时间:

查看次数:

85748 次

最近记录:

5 年,8 月 前