Deleting a LINUX Directory with rmdir

To delete an empty directory named subdir2, use the following command:

I check first the directory, delete the directory when confirmed and verify the directory is deleted.

You can remove a directory in a different location by changing what is after rmdir. To remove a directory in /home/hadi/Music, if you already in your /home directory, you can use the following:

Or from anywhere using an absolute path, you can use this:

Or from anywhere using a path shortcut, you can use the following command:

The directory must be empty to be removed using rmdir. However, you can remove a directory with its contents by using rm.

Note: Anything that has been deleted using rmdir cannot easily recovery, so proceed carefully.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s