删除文档以节省硬盘空间

Mar*_*rer 62 uninstall documentation

我喜欢在 Virtual Box 机器中创建一个相当小的 Ubuntu 安装。它应该基本上只提供 TeX Live 和相关工具。我现在想我在/usr/share/doc. 在这种情况下,我不需要这个文档,只需要 LaTeX 相关man页面,它们不在那里。

有没有办法使用 卸载所有这些文档文件apt-get
或者,只是删除内容是否合理保存/usr/share/doc
我喜欢与其他人共享 Virtual Box 机器,这应该不会出现问题。

And*_*ley 43

根据Ubuntu wiki,您可以指示dpkg不要安装任何文档。这应该可以防止 apt 安装任何文档(版权信息除外)。

创建一个/etc/dpkg/dpkg.cfg.d/01_nodoc指定所需过滤器的文件。例子:

path-exclude /usr/share/doc/*
# we need to keep copyright files for legal reasons
path-include /usr/share/doc/*/copyright
# if you also want to remove the man pages uncomment the next line
#path-exclude /usr/share/man/*
path-exclude /usr/share/groff/*
path-exclude /usr/share/info/*
# lintian stuff is small, but really unnecessary
path-exclude /usr/share/lintian/*
path-exclude /usr/share/linda/*
Run Code Online (Sandbox Code Playgroud)

然后您可以手动删除任何已安装的文档:

find /usr/share/doc -depth -type f ! -name copyright|xargs rm || true
find /usr/share/doc -empty|xargs rmdir || true
rm -rf /usr/share/groff/* /usr/share/info/*
rm -rf /usr/share/lintian/* /usr/share/linda/* /var/cache/man/*
Run Code Online (Sandbox Code Playgroud)

如果您还想删除手册页,请执行以下操作:

rm -rf /usr/share/man/*
Run Code Online (Sandbox Code Playgroud)

该示例是为 OEM 编写的,但对我来说也同样有效。将我的/usr/share/doc/目录从 ~150MB 降到 ~20MB。

  • 在本地机器上,您还可以删除版权文件,这将再节省约 50MB。像这样注释这一行:`# path-include /usr/share/doc/*/copyright` (3认同)

小智 34

这应该删除与乳胶相关的软件包的文档:

sudo apt-get --purge remove tex.\*-doc$
Run Code Online (Sandbox Code Playgroud)

它确实节省了几百 MB。

  • 这似乎也删除了我的 `texlive-full` 包。 (9认同)
  • @joar 这是有意的。texlive-full 是一个提取所有依赖项的元包,包括文档 (6认同)
  • @nealmcb,但随后 autoremove 将删除您所有的 tex 包。更详细地说:如果你已经通过 texlive-full 安装了 tex,然后删除了 doc 包,那么 texlive-full 将消失。然后下次你运行 `apt-get autoremove` 时,你所有的 tex 包也会消失,因为它们存在的唯一原因是因为它们依赖于 texlive-full,而 texlive-full 已经不存在了。 (4认同)

Den*_*aia 14

查找已安装的 texlive 软件包的快速而肮脏的方法(我 100% 确定还有其他方法):

dpkg -l | grep '^ii.*texlive.*doc'
Run Code Online (Sandbox Code Playgroud)

并删除它们:

apt-get remove --purge \
  texlive-fonts-recommended-doc texlive-latex-base-doc texlive-latex-extra-doc \
  texlive-latex-recommended-doc texlive-pictures-doc texlive-pstricks-doc
Run Code Online (Sandbox Code Playgroud)

  • `texlive-full` 是一个元包,可以拉取所有依赖项,包括文档。 (8认同)
  • 这也删除了 Ubuntu 16.04 上的 `texlive-full`。 (6认同)