58

I like to create a rather small Ubuntu installation in a Virtual Box machine. It should basically just provide TeX Live and related tools. I figured now that I have almost 1GB of data under /usr/share/doc. I don't need this documentation in this case, just the LaTeX related man pages, which are not located there.

Is there a way to uninstall all these documentation files using apt-get?
Alternatively, is it reasonably save to just delete the content of /usr/share/doc?
I like to share the Virtual Box machine with others, which shouldn't run in trouble.

36

According to the Ubuntu wiki, you can instruct dpkg not to install any documentation. This should prevent any documentation (except copyright info) from being installed by apt.

Create a file /etc/dpkg/dpkg.cfg.d/01_nodoc which specifies the desired filters. Example:

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/*

Then you can manually remove any documentation already installed:

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/*

If you also want to remove the man pages do:

rm -rf /usr/share/man/*

The example is written for OEMs, but it worked just as well for me. Took my /usr/share/doc/ directory down from ~150MB to ~20MB.

  • I had to recreate one of those folders to get @denilson-sá purge recommendation to work. Specifically: mkdir /usr/share/info. – A T Jan 10 '15 at 6:31
  • 3
    On a local machine, you could also delete the copyright files, which will save another ~50MB. Comment this line like: # path-include /usr/share/doc/*/copyright – rubo77 Jan 28 '15 at 13:53
  • 1
    The first line (plus deleting copyright) left me with 37MB on 13.04. There are lots of symlinked files that are missed by the find. This helps by 5MB: find /usr/share/doc | egrep "\.gz" | xargs rm. This drops the size down to 26 MB: find /usr/share/doc | egrep "\.pdf$" | xargs rm. Down to 21 MB: find /usr/share/doc | egrep "\.tex$" | xargs rm. There are loads more files left behind though. – ahcox Feb 14 '15 at 22:12
  • @AT, the commands in my answer don't remove /usr/share/info; just its contents. The directory should still be there after running them. – Andrew Ensley Jul 18 '16 at 19:10
  • 1
    I don't recommend this step for a few MBs. I did and my system got broken. For instance, Virtualbox checks for installation by checking if a directory /usr/share/doc/virtualbox exists..Created the directory and all worked well. Took me around 2 days to figure that out. Talk about space-time trade-off! – Jus12 Dec 19 '16 at 15:49
31

This should remove the documentation for latex-related packages:

sudo apt-get --purge remove tex.\*-doc$

It does save a few hundred MB.

  • 8
    This seems to remove my texlive-full package too. – joar Aug 8 '13 at 18:03
  • 5
    @joar That's intended. texlive-full is a metapackage that pulls all the dependencies, including the documentation – nealmcb Feb 26 '17 at 17:13
  • 1
    @nealmcb, But then autoremove will remove all your tex packages. In more detail: if you had installed tex through texlive-full, and then remove the doc packages, then texlive-full will be gone. Then next time you run apt-get autoremove, all your tex packages will be gone as well, because the only reason they were there is because they depended on texlive-full, which is not there any more. – isarandi Aug 22 at 13:28
  • @isarandi If you used texlive-full for installation, that sounds like a good point. Some more refs: 2017 proposal to split out the docs: bugs.debian.org/cgi-bin/bugreport.cgi?bug=877862 and more data on sizes: reddit.com/r/LaTeX/comments/2naxke/why_is_texlive_so_large – nealmcb Aug 23 at 16:07
14

Quick-and-dirty way to find the installed texlive packages (I'm 100% sure there are other ways):

dpkg -l | grep '^ii.*texlive.*doc'

And removing them:

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
  • 3
    This also removes texlive-full on Ubuntu 16.04. – Jus12 Dec 18 '16 at 16:42
  • 6
    texlive-full is a metapackage that pulls all the dependencies, including the documentation. – Denilson Sá Maia Dec 19 '16 at 18:39
  • This is the best and the most no-fuss answer. – shivams Aug 24 at 9:42
3

Do you know what is taking up all of that space? My /usr/share/doc is only ~50MB. If not, use the Disk Analyzer application or go to the terminal and run cd /usr/share/doc; then run du -h -d 1 to find out what is using all of that space. Once you know which program or program are the problem then you can decide if you should remove the directories in /usr/share/doc or not.

  • I was not aware that the directory names under /usr/share/doc are the packages names. At least of some this seems to be true. I used du -sc * | sort -n in /usr/share/doc. Most space was taken from the TeX Live 2009 documentation files which I don't want anyway, because I have the manually installed TL 2011 ones. Thanks, while I still like to see if there is a way to tell apt-get to get ride of most documentation, this solution worked out fine for this case. – Martin Scharrer May 2 '12 at 16:27
  • 1
    And for those who aren't comfortable with du: you can use Baobab to analyze disk usage. Though one does need to run it as root (sudo baobab) to index the contents of / – Vistaus Aug 18 '16 at 9:31
0

is it reasonably sa[f]e to just delete the content of /usr/share/doc?

If you do that, the files will get reinstalled when any of the packages get upgraded. You should instead remove the relevant documentation packages, which often (but not always) end in -doc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.