Removing files & directories

I want to remove all the files and subdirectories of a temporary directory var/lib/apt/lists.backup but don’t want to delete every file individually as there are too many!
I am not familiar with “recursive” when used in the context of directories but, after browsing the manual, am hoping that the command
rm -v -r var/lib/apt/lists.backup
will do the trick.
Your advice would be appreciated before I screw up everything.

You could use:

sudo rm -rf var/lib/apt/lists.backup

Both of your commands will work … BUT … you both missed out the / at the beginning of the path.

-r (recursive) means “including sub directories/sub files” … in other word, delete it even if it contains stuff.

combining the -v (verbose) the -r (recursive) and -f (force) =

sudo rm -vrf /var/lib/apt/lists.backup

@ SeZo

That will teach you to copy/paste :wink:

The lack of / was a typo but even cut/pasting your command had no effect - at first - but worked after a few tries. Finger trouble I expect.
Thank you for the explanation: I didn’t realise one could concatenate the options like that, and I can see that one has to be really careful when using terminal commands. They might indeed become terminal!
Thanks, Gents. :slight_smile:

Yes you can concatenate the short options, as in -v -r -f can become -vrf … but you CANNOT concatenate long options as in --verbose --recursive etc.

and yes, be VERY careful … specially with rm -rf :slight_smile:

I may be missing a point here but as a lazy GUi man I use Bleachbit (as root as well). Select boxes to clean or go to file, delete.

Bleachbit will shred files and folders but you must ‘tick’ which ones then select them.

This was more of a how do I do it from the command line question … I think.

Otherwise I’d have said just start nautilus with gksudo.

But yeh, bleachbit is good for secure deletion (shred) … not necessary here though.

I would be interested to know more about Bleachbit (from the Ubuntu Software Centre?) and Nautilus if you gents would care to enlighten me.
Is Nautilus the default file-listing/manipulating s/w on Ubuntu?

OK, bleachbit (yes from the software repositories) is a GUI tool that allows you to clean certain things on your PC, such as the Firefox cache, Chrome cache, package cache (apt-get clean), etc. … it also allows you to “shred” files and directories … shred = secure deletion, where the parts of the HDD that contain the files/directories are overwritten multiple times.

The “nautilus” trick I mentioned …

If you open the nautilus file manager “as root” with:

gksudo nautius /

You’ll now be able to do things outside your “Home” directory … like delete files/directories, rename files/directories, create files/directories, etc. … indeed all the things you can normally only do in your Home directory.

BE AWARE … use that with caution … and ONLY where necessary … DO NOT create/edit things in your “Home” directory from nautilus as root (unless you know what you’re doing) … the files/directories you create/edit will be owned by root, not by your user.

Bleachbit sounds useful although, for routine things, I would like to become more proficient via the Terminal in order to get to know Linux better.
“Root” appears to be “God’s space”, as it were, in which “Home” resides. So anything God operates on then belongs to Root even if it’s still in Home. How am I doing?
Do all the Root files appear in the “File System” that is listed along with “Home”?
Do I remember correctly that Nautilus is the file-listing s/w that I use every day?
Thanks for being so patient.

Yes, if you operate on a file “as root” … the file will become owned by root.

Yes, root is God, and can operate on anything … users are limited to only being able to create/edit/delete/etc. things in THEIR “Home” directory … so if my username is mark, MY “Home” directory is /home/mark

The ONLY directory (and contents) a regular user owns (by default) is /home/<their_user_name> … everything else needs elevated privileges.

Yes, (in Ubuntu/Mint/pretty much any Gnome desktop environment) “Nautilus” is your file manager … akin to Windows Explorer … the thing that opens if you click “Home” :slight_smile: … or run:

nautilus

One other thing … if opening a “graphical” (GUI) application with elevated privileges (as root) … try not to use sudo, use gksudo instead.

in other words …
gksudo nautilus
NOT
sudo nautilus

Thanks, Mark - I’m getting the hang of it, slowly.
I was trying to avoid the use of the Windows word in deference to the Forum’s title!
I doubt that I’ll be doing anything as Root without explicit directions from your good self as I have screwed up soooooo many times!

You’re welcome … if you ever have any other questions, that’s what we’re here for :slight_smile:

Screwing up is all part of the learning curve … and part of the fun … we’ve all done it, and here’s a confidence inspiring thought for you … I occasionally still do :slight_smile: