HDFS Delete Directories: hadoop fs -rmdir

The hadoop fs -rmdir command is used to delete a directory in Hadoop Distributed File System (HDFS).

In this blog post, we will explore the hadoop fs -rmdir command’s usage and its most commonly used flags with examples to help you become proficient in deleting directories in HDFS.

Another command, hadoop fs -rm, provides an extended range of capabilities and serves as a versatile option for deleting both files and directories. For a comprehensive understanding of the hadoop fs -rm command, you can refer to the content covered in this blog post.

Command Syntax:

hadoop fs -rmdir [options] <path>
  • path: The path to the directory to be deleted.
  • options: The following options are available:
    • -f: Force the deletion, even if the directory is not empty.
      • Example: hadoop fs -rmdir -f /user/hadoop/mydir

Remove Empty Directory

This basic usage of the command removes the specified empty directory from HDFS.

hadoop fs -rmdir <path>

Example:

In this example, the command removes the empty directory named empty_dir from the /user/hadoop/ directory in HDFS.

hadoop fs -rmdir /user/hadoop/empty_dir/

Forceful Removal (-f)

The -f flag allows you to forcefully remove the directory, even if it’s not empty.

hadoop fs -rmdir -f <path>

Example:

By using the -f flag, the command forcefully removes the directory non_empty_dir even though it contains files.

hadoop fs -rmdir -f /user/hadoop/non_empty_dir/

352 Comments

  • Hi there, I believe your website may be having browser compatibility
    issues. Whenever I take a look at your web site in Safari,
    it looks fine however, when opening in Internet Explorer, it’s got some overlapping issues.
    I simply wanted to give you a quick heads up! Other than that, great site!

    Reply
  • It’s actually very complex in this active life to listen news
    on TV, therefore I simply use world wide web for that purpose,
    and take the latest information.

    Reply
  • You actually make it seem so easy with your presentation but I find this matter to be actually something that I
    think I would never understand. It seems too complex and extremely broad for
    me. I’m looking forward for your next post, I will try to get the hang of it!

    Reply
  • I was recommended this blog by way of my cousin.
    I am not certain whether this put up is written through him as nobody else recognize such precise about my difficulty.
    You are amazing! Thank you!

    Reply
  • Your style is very unique compared to other people I have read stuff
    from. Thank you for posting when you have the opportunity, Guess
    I will just bookmark this site.

    Reply
  • I like the valuable info you supply to your articles. I’ll bookmark your blog and take a look at again right here frequently.

    I’m reasonably certain I will be told many new stuff proper here!
    Best of luck for the next!

    Reply
  • I’m not sure where you are getting your information, but great topic.
    I needs to spend some time learning much more or understanding more.

    Thanks for wonderful information I was looking for this information for
    my mission.

    Reply
  • Hello There. I discovered your weblog the usage of msn. That is a really smartly written article.
    I’ll be sure to bookmark it and return to read extra of your helpful information. Thanks for the post.
    I’ll certainly comeback.

    Reply
  • Hi there, yes this piece of writing is in fact nice and I have learned lot of things
    from it on the topic of blogging. thanks.

    Reply
  • Please let me know if you’re looking for a author
    for your site. You have some really good posts and I believe I would
    be a good asset. If you ever want to take some of the load off, I’d love to write some
    content for your blog in exchange for a link back to mine.
    Please shoot me an e-mail if interested. Cheers!

    Reply
  • Having read this I thought it was rather informative. I appreciate you taking the time and effort to put this information together. I once again find myself spending a lot of time both reading and commenting. But so what, it was still worthwhile!

    Reply
  • Great post. I was checking constantly this blog and I
    am impressed! Very helpful info particularly
    the last part 🙂 I care for such information a lot.

    I was seeking this particular information for a very long time.

    Thank you and best of luck.

    Reply
  • Hello very nice site!! Man .. Beautiful .. Superb ..
    I will bookmark your web site and take the feeds additionally?
    I am glad to search out so many helpful information right here within the submit, we’d
    like work out more strategies in this regard, thank you for sharing.
    . . . . .

    Reply
  • Great blog here! Also your web site rather a lot up fast!
    What web host are you the usage of? Can I get your associate hyperlink on your host?
    I wish my website loaded up as quickly as yours lol

    Reply
  • What’s up it’s me, I am also visiting this website daily, this
    web site is genuinely good and the viewers are truly sharing fastidious thoughts.

    Reply
  • I was pretty pleased to find this web site. I wanted to thank you
    for ones time for this particularly fantastic
    read!! I definitely appreciated every part of it and i also have you book marked to look
    at new stuff on your site.

    Reply
  • Heya superb blog! Does running a blog similar to this take a massive
    amount work? I have no expertise in programming however I had been hoping to start
    my own blog soon. Anyways, if you have any
    recommendations or tips for new blog owners please share.
    I know this is off topic nevertheless I just wanted to ask.
    Appreciate it!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *