Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
The same question for Debian… – user7610 Nov 27 '15 at 18:01
up vote 20 down vote accepted

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
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/man/* /usr/share/groff/* /usr/share/info/*
rm -rf /usr/share/lintian/* /usr/share/linda/* /var/cache/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.

share|improve this answer
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
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
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 Jul 18 at 19:10

This should remove the documentation for latex-related packages:

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

It does save a few hundred MB.

share|improve this answer
This seems to remove my texlive-full package too. – joar Aug 8 '13 at 18:03

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
share|improve this answer

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.

share|improve this answer
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

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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