0

I can't remove files in the printer spool for some reason:

$ sudo ls /var/spool/cups

lists a bunch of files like 'c00083' etc.

$ sudo rm /var/spool/cups/*
rm: cannot remove '/var/spool/cups/*': No such file or directory

What am I doing wrong?

5

You don't have permissions as a regular user to view the contents of the /var/spool/cups directory; sudo ls gave ls the permissions to view the contents, but your regular-user shell failed to read it when it tried to expand the /var/spool/cups/* wildcard, so it passed that string through verbatim to rm, which complained about that lack of a file named (precisely) /var/spool/cups/*.

Gather the actual filename(s) first, then pass them to sudo rm.

  • Ok, so how do I do that? – Tyler Durden Mar 20 at 16:49
  • 3
    sudo ls /var/spool/cups | sudo xargs rm, but personally I prefer sudo bash -c "rm /var/spool/cups/*". – Weijun Zhou Mar 20 at 16:56
  • Or use native lp commands such as lprm - ("to cancel all jobs") – Jeff Schaller Mar 20 at 16:57
  • @JeffSchaller That does not remove the files in the spool – Tyler Durden Mar 20 at 17:00
  • Then I'd recommend Weijun Zhou's sudo bash -c "rm /var/spool/cups/*" alternative, or sudo -s; rm /var/spool/cups/*; exit – Jeff Schaller Mar 20 at 17:03

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.