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/

12 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
Leave a Comment