this post was submitted on 11 Aug 2025
986 points (98.8% liked)

linuxmemes

26744 readers
1955 users here now

Hint: :q!


Sister communities:


Community rules (click to expand)

1. Follow the site-wide rules

2. Be civil
  • Understand the difference between a joke and an insult.
  • Do not harrass or attack users for any reason. This includes using blanket terms, like "every user of thing".
  • Don't get baited into back-and-forth insults. We are not animals.
  • Leave remarks of "peasantry" to the PCMR community. If you dislike an OS/service/application, attack the thing you dislike, not the individuals who use it. Some people may not have a choice.
  • Bigotry will not be tolerated.
  • 3. Post Linux-related content
  • Including Unix and BSD.
  • Non-Linux content is acceptable as long as it makes a reference to Linux. For example, the poorly made mockery of sudo in Windows.
  • No porn, no politics, no trolling or ragebaiting.
  • 4. No recent reposts
  • Everybody uses Arch btw, can't quit Vim, <loves/tolerates/hates> systemd, and wants to interject for a moment. You can stop now.
  • 5. πŸ‡¬πŸ‡§ Language/язык/Sprache
  • This is primarily an English-speaking community. πŸ‡¬πŸ‡§πŸ‡¦πŸ‡ΊπŸ‡ΊπŸ‡Έ
  • Comments written in other languages are allowed.
  • The substance of a post should be comprehensible for people who only speak English.
  • Titles and post bodies written in other languages will be allowed, but only as long as the above rule is observed.
  • 6. (NEW!) Regarding public figuresWe all have our opinions, and certain public figures can be divisive. Keep in mind that this is a community for memes and light-hearted fun, not for airing grievances or leveling accusations.
  • Keep discussions polite and free of disparagement.
  • We are never in possession of all of the facts. Defamatory comments will not be tolerated.
  • Discussions that get too heated will be locked and offending comments removed.
  • Β 

    Please report posts and comments that break these rules!


    Important: never execute code or follow advice that you don't understand or can't verify, especially here. The word of the day is credibility. This is a meme community -- even the most helpful comments might just be shitposts that can damage your system. Be aware, be smart, don't remove France.

    founded 2 years ago
    MODERATORS
     
    you are viewing a single comment's thread
    view the rest of the comments
    [–] Emerald@lemmy.world 18 points 4 days ago (3 children)

    I alias rm to rm -r for easy folder deleting

    [–] captain_aggravated@sh.itjust.works 23 points 3 days ago (3 children)

    UGH that shit.

    rm deletes a file. It can't delete a directory, you have to use

    rmdir to delete a directory...as long as there's nothing in that directory. If there's anything in the directory, you have to know to use

    rm -r to delete a directory and its contents, and no

    rmdir -r isn't right somehow!

    [–] Matriks404@lemmy.world 3 points 3 days ago* (last edited 3 days ago)

    I don't think there's any reason to use rmdir unless you write (Ba)sh scripts, and you want to make sure that the directory is indeed empty. Just use rm -r.

    Also note that you can use rmdir -p this/is/some/path to remove all nested directories including the parent (this here). But this will only work if there's exactly one directory per parent directory, and the last directory doesn't have any files (including directories). This might be helpful for some scripts.

    rmdir -r isn't a thing, because that would invalidate the reason this command exists.

    [–] Opisek@lemmy.world 3 points 3 days ago

    Reminds me of a little annoyance I have with cat and ls. Yeah they technically do different things, one is for files and one is for directories. But so often I just find myself wishing I could use one command for both. Like making cat directory act as ls. Maybe I'm the only one who feels that way.

    [–] setsubyou@lemmy.world 2 points 3 days ago (1 children)

    On Linux, rm can delete empty directories with -d too, not just with -r.

    rmdir is the counterpart to mkdir, which creates empty directories, so of course it can only remove empty directories. After all mkdir can’t create full directories either. There however is rmdir -p as a counterpart to mkdir -p, so if there is something in the directory, you can use that, as long as the something is an empty directory.

    [–] captain_aggravated@sh.itjust.works 4 points 3 days ago* (last edited 3 days ago) (1 children)

    Yeah it still has a certain "AAAAH! You didn't say simon says" feel to it when you're actually trying to get things done. Like imagine if you had to choose a different option from a context menu to delete a folder in a GUI. If there was an option for Remove File and another one placed a little elsewhere in the menu that says Remove Directory.

    I'm still gonna call it an unsanded corner.

    [–] Ephera@lemmy.ml 1 points 2 days ago (1 children)

    I feel like the main reason the distinction exists, is because deleting a whole directory can be potentially catastrophic.

    I looked at Trashy yesterday, which gives you a command trash my_file that just moves the file into the trashcan folder. Well, and that decided to make no distinction between files and directories, which does make sense to me, since you can just restore a deleted directory.

    [–] captain_aggravated@sh.itjust.works 1 points 2 days ago (1 children)

    My solution: rm will remove an empty directory, while a full directory will throw either an "are you sure? y/N" or require you to use rm -r. Why have a command whose only job is to remove an empty directory?

    [–] Ephera@lemmy.ml 1 points 1 day ago

    Yeah, I feel like a big part of the reason it was designed like that, is because it was designed in the 70s, where you couldn't really throw up interactive prompts. But interactive prompts are also somewhat tricky for scripting, as it's difficult to detect whether a user could respond to the prompt, meaning the script might just hang there forever.

    That's kind of the problem. You almost need separate tools for scripting and interactive use, but having separate tools is also not great, since people will inherently try to use the tool they know for everything...

    [–] Atomic@sh.itjust.works 8 points 3 days ago (1 children)

    Would "Danger" happen to be your middle name by any chance?

    [–] LeFantome@programming.dev 1 points 3 days ago

    It is not like he put the f on it :)

    [–] Matriks404@lemmy.world 2 points 3 days ago

    That works, unless you mistype the file name, and delete some unrelated directory by mistake.