How do you delete whole directories in the root

Asked by Manmetal

I copied an extra xampp directory in the /opt/xampp.

I have tried to delete it using the sudo rmdir command but it still tell me to remove the files within the directory.

Is there a wildcard or global delete that allow you to delete whole directories with files still in them?

Thanks,
Jerry

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Manmetal
Solved:
Last query:
Last reply:
Revision history for this message
Simos Xenitellis  (simosx) said :
#1

"rmdir" deletes directories that are empty.
If you want to delete whole directories, you need to use "rm", with the flag for recursive deletion.

Thus, you would need to type

sudo rm -r /opt/xampp

If you are prompted to confirm the deletion for each of the files, you can also add the -f parameter, that forces deletion. Therefore,

sudo rm -fr /opt/xampp

The last command is quite ruthless; you should be very careful when you run it, because it can wipe out your system for small mistakes.

A common mistake is to type

sudo rm -fr / opt/xampp

There is a typo above, there is a space between "/" and "opt/xampp". What this means is that "rm" is gonna erase all your hard disk, directory "/", then erase "opt/xampp", if it still exists (it will not).

An alternative to using the command line utilities is to run "nautilus", the file manager as root.
You can do this by running

sudo nautilus --no-desktop

Then, you can erase directories by moving them to the Wastebasket, then empty the wastebasket.
When you use nautilus as root, it is good to change the default background (Edit/Backgrounds and Emblems) of the main Nautilus window, so that it stands as from normal Nautilus windows. Just drag and drop one of the nice patterns on the root Nautilus window and you are done.

If you want to make a menu item for the Root Nautilus (i.e. add an entry under System/Administration/), use

gksudo nautilus --no-desktop

In this way you avoid the Terminal window altogether.

Revision history for this message
Manmetal (jerthornton) said :
#2

Hi Simon,
Thanks so much that worked but I had to use the shell....

I do not understand how to us 'nautilus'. How do you load it then start it up...
I followed your instructions below but got lost...

Thanks,
Jerry

An alternative to using the command line utilities is to run "nautilus", the file manager as root.
You can do this by running

sudo nautilus --no-desktop

Then, you can erase directories by moving them to the Wastebasket, then empty the wastebasket.
When you use nautilus as root, it is good to change the default background (Edit/Backgrounds and Emblems) of the main Nautilus window, so that it stands as from normal Nautilus windows. Just drag and drop one of the nice patterns on the root Nautilus window and you are done.

If you want to make a menu item for the Root Nautilus (i.e. add an entry
under System/Administration/), use

gksudo nautilus --no-desktop

In this way you avoid the Terminal window altogether.

Revision history for this message
Simos Xenitellis  (simosx) said :
#3

"nautilus" is the project name for the file manager of GNOME and Ubuntu. You get "nautilus" links (such as "Hom Folder") when you click on Places at the top menu of your screen, or when you double-click on the drive icons on your desktop.

Of course, it's not important to use nautilus as long as you can do the work with the command line.

Revision history for this message
Manmetal (jerthornton) said :
#4

Thanks again and that solved it..
I found you cannot use nautilus to move any files in the /root. I can only move them with the command line..

Thanks again...