2

I'm having space problems in the root folder and one of the folders that contains many files is /usr/share/doc/texlive-doc, I would like to know, there is a way for me to use a command that goes through the entire folder and deletes only file with .pdf extension?

This is on Ubuntu 16.04.

Eliah Kagan
  • 119,640

4 Answers4

7

I would not recommend manually deleting from the root directory as it could cause programs to break, and they will just be replaced next time you update.

I would try to find entire packages you no longer need before resorting to this. there are many ways to do this, on Ubuntu I would first run sudo apt-get autoremove. This will find packages which were installed as dependencies for programs, but are no longer needed by anything.

It might be a good idea to look in the Ubuntu Software Centre to get a list of all the programs you have installed. If you're like me, you'll have installed loads of programs you no longer use, or maybe intended to use and never did.

5

I guess the correct way is to tell dpkg you don't want to install documentation. See Ubuntu Wiki.

Is this so much space? Check with:

find /usr/share/doc/texlive-doc/ -iname '*.pdf' | xargs du -sch

If you really wish to do the wrong way, you may as well remove them with the following command:

sudo find /usr/share/doc/texlive-doc/ -iname '*.pdf' -exec rm {} \;

but I guess they will be added again on update.

terdon
  • 104,119
LEo
  • 499
4

The files in /usr/share/doc/texlive are all documentation for texlive - a popular TeX distribution for Linux - and were installed when you installed texlive, and its related packages. For files installed by system packages, it's generally better to just uninstall the packages, rather than to attempt to delete the files, since this may cause issues, and the files may be recreated if the package is updated.

If you do still want texlive, but don't want the documentation any more, you can do:

sudo apt remove 'texlive-*-doc'

to remove all documentation-related packages - although some texlive components may not have split documentation into separate packages, so some documentation may remain. If, on the other hand, you simply don't want texlive any more, you can do:

sudo apt purge texlive 'texlive-*'

which will remove all texlive related packages from your system, and all files related to them.

I would also add that whilst texlive is one of the bigger packages, it's unlikely that it's the biggest contributor to your space issues. Ubuntu has a tool "Disk Usage Analyser" that can tell you what is actually taking up space.

James_pic
  • 439
  • 3
  • 7
0

Use crontab .I have done this in ubuntu 18.04

verify with

dpkg -l cron

then

crontab -e

add the line like

@reboot rm /folder/folder/*.pdf

this will remove pdf at time of restarting the system. You can also schedule cronjob which I have not done.

For base start

https://www.liquidweb.com/kb/create-a-cron-task-in-ubuntu-16-04/

https://www.alibabacloud.com/blog/how-to-automate-and-schedule-tasks-with-crontab-on-ubuntu-16-04_594117

Gopipuli
  • 143