Logo Background RSS

Remove / Delete a Directory Linux Command

  • Delete / Remove a Directory Linux Command

    Q. I am new to Linux and command line. How do I delete or remove a directory?

    A. Use rmdir command. This command remove the DIRECTORY(ies), if they are empty. For example, type the following command to remove /tmp/docs directory:

    $ rmdir /tmp/docs
    If directory is not empty you will get an error:
    $ rmdir letters
    Output:

    rmdir: letters: Directory not empty

    You can change directory to find out files:
    $ cd letters
    $ ls

    Linux remove entire directory

    To remove all directories and subdirectories use rm command. For example remove letters and all subdirectories and files inside this directory, type the following command:
    $ rm -rf letters/

53 Comments
  1. #1 infoproservices.com
    July 14th, 2009 at 10:20 pm

    System administration command. Restore backed up files from a dump archive. Execute this command with one of the following flags.

    Post ReplyPost Reply
  2. #2 infoproservices.com
    September 4th, 2009 at 12:27 am

    In your bashrc or what ever other shell you are using, you can set up the length of your history – I think it defaults to about a thousand lines.

    Post ReplyPost Reply
  3. #3 infoproservices.com
    October 6th, 2009 at 7:30 pm

    Like the shell command, list files in the current working directory, or the specified file or directory name. A * before a name indicates items marked for extraction. In verbose mode, the listing will include each item’s inode.

    Post ReplyPost Reply
  4. There’s a lot of information here. I’ll be back again.

    Post ReplyPost Reply
  5. #5 Cornelius
    October 18th, 2009 at 8:57 pm

    Valuable thoughts and advices. I read your topic with great interest.

    Post ReplyPost Reply
  6. #6 Brown
    October 19th, 2009 at 7:36 pm

    I really like your blog and i respect your work. I’ll be a frequent visitor.

    Post ReplyPost Reply
  7. #7 Peter
    October 22nd, 2009 at 4:58 am

    In truth, immediately i didn’t understand the essence. But after re-reading all at once became clear.

    Post ReplyPost Reply
  8. #8 infoproservices.com
    November 23rd, 2009 at 11:46 pm

    Run the specified script at the beginning of each volume. restore will pass the current device and volume number to the script. The script should return 0 to continue, 1 to prompt for a new tape, or any other exit value to abort the restore.

    Post ReplyPost Reply
  9. #9 infoproservices.com
    December 2nd, 2009 at 2:05 pm

    What commands are to be used to delete all the files in a directory in linux system?

    Post ReplyPost Reply
  10. #10 infoproservices.com
    December 2nd, 2009 at 7:18 pm

    ls -lr gives the long listing which is piped to the wc command ,wc -l counts the number of lines ..hwoever to count the files in the parent directory you have to navigate the parent directory or do something like this

    Post ReplyPost Reply
  11. #11 SEO
    January 29th, 2010 at 11:57 am

    You probably need superuser (administrator) privideges to remove it. Type su, and your root password to get a root prompt.

    Post ReplyPost Reply
  12. #12 SEO
    February 1st, 2010 at 4:05 pm

    It will not show you a file whose name begins with a period without the -a switch. That is non-negotiable. If you are not seeing any other files someone may have planted a rootkit on your machine. Rkhunter and chkrootkit are good programs to have and to run.

    Post ReplyPost Reply
  13. #13 seo
    March 3rd, 2010 at 10:34 am

    For copying and moving directories you can use the cp and mv commands just like you use them with files. Yeah, I know. If you’ve already tried to copy a directory with cp, you’ve probably noticed that cp just complains at you. Probably it says something like cp: omitting directory yadda yadda. You see, the cp command wants you to use the -r option if you want to copy a directory with its contents. The -r means “copy recursively”:

    Post ReplyPost Reply
  14. #14 seo
    April 1st, 2010 at 11:11 am

    Remove file from Clearcase view. First perform a checkout (“ct co”) of the file and directory. Past versions will be available from the archive although not visible in current view. Safer than “ct rmelem” which removes all knowledge of the file old and new.

    Post ReplyPost Reply
  15. #15 seo
    May 4th, 2010 at 8:18 am

    How to remove all the files inside a directory but not remove directory using rm command?

    Post ReplyPost Reply
  16. #16 seo
    June 2nd, 2010 at 8:06 am

    By using the the “/*” at the end, this path expands to “everything in the aryan directory”. Notice that this does not include the aryan directory itself. Therefore, the contents are deleted, but the directory itself is left intact.

    Post ReplyPost Reply
  17. #17 Fethiye
    June 11th, 2010 at 9:03 pm

    You probably need superuser (administrator) privideges to remove it. Type su, and your root password to get a root prompt.

    Post ReplyPost Reply
  18. #18 seo
    June 22nd, 2010 at 6:20 pm

    dial up modem not make connection and not dial the modem

    Post ReplyPost Reply
  19. #19 Yum Berrry Juice
    December 2nd, 2010 at 3:03 pm

    i read Linux in my collage but i don’t take it seriously. so i have a less knowledge about Linux.

    Post ReplyPost Reply
  20. #20 bad car loan
    December 20th, 2010 at 10:31 pm

    Probably if you put the content of the file to the database, then you dont need the original name, and filesystem access.

    Post ReplyPost Reply
  21. #21 cet
    December 26th, 2010 at 11:32 pm

    hello, how can i remove all sub directories in a folder?

    Post ReplyPost Reply
  22. #22 Yum Berrry Juice
    January 3rd, 2011 at 11:13 am

    can i get backup of all delete files?

    Post ReplyPost Reply
  23. #23 Grand Lake condo rental
    January 16th, 2011 at 9:36 pm

    That is great to hear! Thanks for letting us know they were helpful. All the best to you…

    Post ReplyPost Reply
  24. #24 Winfred Vena
    January 18th, 2011 at 11:06 pm

    I am really thankful to this topic because it really gives great information “”,

    Post ReplyPost Reply
  25. #25 Lloyd Burrup
    January 19th, 2011 at 9:54 pm

    I am really thankful to this topic because it really gives great information *’;

    Post ReplyPost Reply
  26. #26 Grand Lake condo rental
    February 1st, 2011 at 7:23 pm

    Decorating your office space is all about personalization. Make sure not to overdo it, though. You will want to keep your space organized and un-cluttered.

    Post ReplyPost Reply
  27. #27 taping tools
    February 10th, 2011 at 3:04 pm

    before a name indicates items marked for extraction. In verbose mode, the listing will include each item’s inode.

    Post ReplyPost Reply
  28. #28 Grand Lake condo rental
    April 2nd, 2011 at 4:36 pm

    If you are at your computer now, you may want to follow along. Open a terminal and then type whoami. (Remember to run all of the words together with no spaces, and press enter.) Here’s what you get..

    Post ReplyPost Reply
  29. #29 Hotel in Thailand
    May 26th, 2011 at 1:04 am

    Excellent post!! I really like your site!!

    Post ReplyPost Reply
  30. #30 Le Beynon
    June 2nd, 2011 at 10:53 am

    Resources like the one you spoken concerning proper here could almost certainly be quite helpful to me! I can submit a hyperlink to it web page on my blog. I am certain my visitors should find that very valuable. Vast many thanks for the useful data i found on Area Details In any case, in my vocabulary, there aren’t significantly excellent provide like this.

    Post ReplyPost Reply
  31. #31 Doloris Engdahl
    June 18th, 2011 at 5:58 am

    Hello, i believe that i saw you visited my site so i came to “return the favor”. I am attempting to obtain things to enhance my web site!I suppose its ok to make use of a few of your ideas!!

    Post ReplyPost Reply
  32. #32 Tung148
    July 13th, 2011 at 2:10 am

    Thx man…

    Post ReplyPost Reply
  33. #33 Denny Ketelaar
    July 18th, 2011 at 6:01 pm

    Youre so cool! I dont suppose Ive learn something like this before. So nice to seek out somebody with some unique thoughts on this subject. realy thanks for beginning this up. this website is something that’s wanted on the web, somebody with a little bit originality. useful job for bringing something new to the internet!

    Post ReplyPost Reply
  34. #34 injection molding
    July 21st, 2011 at 3:08 pm

    I am a relatively new linux user, so I am not familiar w/ the linux lingo, so please answer in detail. I want to change the read,write,execute permissions of all the files w/in a directory named “_spe” so I did chmod 777 _spe.

    Post ReplyPost Reply
  35. #35 injection molding
    August 4th, 2011 at 1:26 pm

    l counts the number of lines ..hwoever to count the files in the parent directory you have to navigate the parent directory or do something like this

    Post ReplyPost Reply
  36. #36 Room in Stockholm
    August 18th, 2011 at 1:49 am

    I really like it. Great post!

    Post ReplyPost Reply
  37. #37 Denmark Green Card
    August 30th, 2011 at 4:29 pm

    I like your post. Good job!

    Post ReplyPost Reply
  38. #38 Sharen Kagy
    August 30th, 2011 at 10:27 pm

    Hi there very nice website!! Guy .. Beautiful .. Wonderful .. I’ll bookmark your web site and take the feeds additionally…I’m glad to seek out numerous helpful info right here in the submit, we’d like develop more techniques in this regard, thanks for sharing. . . . . .

    Post ReplyPost Reply
  39. #39 black ops free
    September 1st, 2011 at 2:31 am

    Great write-up, I’m normal visitor of one’s site, maintain up the nice operate, and It’s going to be a regular visitor for a lengthy time.

    Post ReplyPost Reply
  40. #40 injection molding
    September 3rd, 2011 at 12:26 pm

    The script should return 0 to continue, 1 to prompt for a new tape, or any other exit value to abort the restore,I dont suppose Ive learn something like this before. So nice to seek out somebody with some unique thoughts on this subject. realy thanks for beginning this up.

    Post ReplyPost Reply
  41. #41 professional speaker
    September 22nd, 2011 at 2:22 pm

    It is very difficult to understand the concept of the Linux and there are various commands on which we have to work.

    Post ReplyPost Reply
  42. #42 vanderbilt beach
    September 28th, 2011 at 12:13 pm

    One must take caution when deleting files and directories via the command line. This could be a real time-saver compared to doing it via the GUI. However, if you delete something accidentally, you will not going to be able to retrieve it. It’ll be deleted forever.

    Post ReplyPost Reply
  43. #43 professional speaker
    October 1st, 2011 at 10:52 am

    what is command to restore my abuntu or command recovery
    and is there is any book explanation all linux command ?? plus what is the name

    Post ReplyPost Reply
  44. #44 injection molding
    October 3rd, 2011 at 2:23 pm

    Create a file and insert text into it. Display the starting part of the file.Show the usage of finger command. Create a file “mno” and “def” and compare their contents.

    Post ReplyPost Reply
  45. #45 injection molding
    November 2nd, 2011 at 11:15 am

    In Linux you just type it directly into the shell, you can either open a terminal or you can just hit ctrl+alt+f1 to get a full screen shell.

    Post ReplyPost Reply
  46. #46 injection molding
    November 17th, 2011 at 5:15 pm

    Linux is an interesting Operating System for work..It is more secure and reliable than other operating systems.

    Post ReplyPost Reply
  47. #47 injection molding
    December 12th, 2011 at 3:24 pm

    i am having the knowledge of how to delete a directory but i want to know how to change the permissions for a file and what command is used?

    Post ReplyPost Reply
  48. #48 injection molding
    January 16th, 2012 at 12:23 pm

    The post is very informative and useful for me. Thanks for sharing this post.

    Post ReplyPost Reply
  49. #49 rugged lcd monitors
    January 18th, 2012 at 12:10 pm

    Use rmdir command. This command remove the directory if they are empty. yhanks for the post…

    Post ReplyPost Reply
  50. #50 injection molding
    January 25th, 2012 at 9:52 am

    This is very important information regarding the removing directory with the help of Linux command.This must help to the many of the user and who make career in the field of the linux OS.

    Post ReplyPost Reply
  51. #51 fosamax femur fracture lawsuit
    January 26th, 2012 at 12:14 am

    I’m a Windows user for many years but trying to study Linux. This post comes handy. Thanks.

    Post ReplyPost Reply
  52. #52 injection molding
    February 1st, 2012 at 10:01 am

    The script should return 0 to continue, 1 to prompt for a new tape, or any other exit value to abort the restore.

    Post ReplyPost Reply
  53. #53 vending machine companies
    February 1st, 2012 at 4:07 pm

    I recommended this post to my cousin.He love to read about Linux.He praised the idea to describe command a lot.Great share here.

    Post ReplyPost Reply
Leave a Comment