Linux Delete Folder

by Vivek Gite on January 28, 2009 · 2 comments

How do I delete folders under Linux operating systems?

You can the folder or directory, if they are empty using the following rmdir command.

Syntax

 
rmdir foldername
rmdir dirname
rmdir /path/to/folder
rmdir /path/to/directory
 

Example

In this example, delete the directory called /tmp/letters

 
rmdir /tmp/letters
 

Task: Remove DIRECTORY and Its Ancestors

The -p option can delete directory and its subdirectories:

 
rmdir -p dir1/dir2/dir3
 

Task: Delete All Files and Folders Including Subdirectories

Use the following syntax:

 
rm -rf /path/to/dir
 

For example, delete /home/vivek/docs and all its subdirectories including file, enter:

 
rm -rf /home/vivek/docs
ls -l /home/vivek/docs
 

GUI File Manager

The Nautilus file manager (GNOME desktop) provides a simple and integrated way to manage your files and applications. Just open it from Places menu and select folder and hit delete key.

Fig.01: Gnome File Browser

Fig.01: Gnome File Browser

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

{ 2 comments… read them below or add one }

1 Philippe Petrinko November 16, 2010

Look out Vivek,

You have just invented 2 new commands : “mdir” and “m”
(instead of “mkdir” (3 times) and “rm” (2 times).

Philippe

Reply

2 Vivek Gite November 16, 2010

Philippe,

There is a bug in WP plugin that displays bash script and commands; it eats ‘r’ character when enclosed in formatting tags as follows:

<pre lang="bash">rmdir foldername</pre>

Which renders it as

mdir foldername

To avoid this I need to add an extra newline to command:

<pre lang="bash">
rmdir foldername
</pre>

This one renders correctly:

rmdir foldername

The plugin author stopped updating plugin and I’m not able to find out the bug on my own :( so some time we get this kind of weird problems. I’d like to thank you for pointing out this and while fixing this I found another bug because of your comment too. It was related to image display. I’ll buy you beer and pizza!

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 4 + 13 ?
Please leave these two fields as-is:
Solve the simple math so we know that you are a human and not a bot.




Previous post:

Next post: