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.


6 Answers 6


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, 2015 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, 2015 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, 2015 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. Jul 18, 2016 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, 2016 at 15:49

This should remove the documentation for latex-related packages:

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

It does save a few hundred MB.

  • 10
    This seems to remove my texlive-full package too.
    – joar
    Aug 8, 2013 at 18:03
  • 6
    @joar That's intended. texlive-full is a metapackage that pulls all the dependencies, including the documentation
    – nealmcb
    Feb 26, 2017 at 17:13
  • 4
    @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, 2019 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, 2019 at 16:07

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

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. May 2, 2012 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 /
    – user520257
    Aug 18, 2016 at 9:31

A small modification to mopagemo's answer. If LaTeX was originally installed via texlive-full, then removing that metapackage will lead to all of its dependencies being added to the autoremove queue. To fix this, we need to flag the packages as manually installed.

Here's a list of the steps I took to remove the docs and remove the desired packages from the autoremove queue:

  1. sudo apt-get --purge remove tex.\*-doc$
  2. Copy the packages that appear between "The following packages were automatically installed and are no longer required" and "Use 'sudo apt autoremove' to remove them." into a text editor, and remove all the new lines.
  3. Try to sudo apt-get install all of these packages.
  4. You will probably get a series of "Unable to locate package" messages. Remove these ghost packages from the list in your text editor.
  5. Try sudo apt-get install again on the smaller list. This should flag all of the packages as manually installed.
  6. You may get another "no longer required" message. If so, repeat steps 2--5.

It doesn't take long to do this, and the benefit is that you aren't breaking any existing packages or dependencies. You could even reinstall texlive-full over the top. You might want to keep a list of the flagged packages if you intend to uninstall completely at some point.

This freed up just over 1000 MB on my system.

  • This command finds all dependencies of texlive-full that are not -doc. So you can take the list of pacakges and give it to apt install to mark all of them as manually installed. LANG=C apt show texlive-full | grep Depends | sed 's/^Depends: //' | tr ',' "\n" | sed 's/ (.*$//' | grep -v -- '-doc$' | tr -d "\n" Mar 25, 2023 at 16:10

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .