all 155 comments

[–]IntrepidPig 476 points477 points  (118 children)

/> Not using rm -r

[–]WorseThanHipster 353 points354 points  (97 children)

alias rm='rm -rf'

(note: don't actually do this)

[–]_Lady_Deadpool_ 529 points530 points  (63 children)

alias ls="rm -rf --no-preserve-root /"

April fools motherfucker

[–]plistig 252 points253 points  (22 children)

Make it a cronjob on your coworkers machine before you hand in your resignation. If everything works out well, then the crontab entry gets deleted, too. :)

LPT: don't do this.

[–]110011001100 154 points155 points  (15 children)

Leave some code running under an admin account which checks LDAP and wipes production 10-15 days after it detects your login ID is missing. It should also check for a bunch of other login ID's which recently departed the company (and keep that list up to date, say on a weekly basis) but be intelligent enough that only login ID's detected as active and then deleted trigger the wipe

[–]Fazer2 104 points105 points  (9 children)

That's suspiciously specific.

[–]Vilengel 68 points69 points  (8 children)

Yeah, don't fire that guy.

[–]zombieregime 80 points81 points  (5 children)

Dont hire that guy

FTFY

[–]Vilengel 28 points29 points  (0 children)

...Actually, might be the better call.

[–]-hax- 9 points10 points  (3 children)

Dont Hire that guy to test your automated resilience and backup systems.

FTFY

[–]Pandoras_Fox 4 points5 points  (2 children)

Dont Hire that guy to test your automated resilience and backup systems.

and never fire him

[–]benderunit9000 2 points3 points  (0 children)

Don't deactivate that login

[–]Katastic_Voyage 29 points30 points  (3 children)

Yeah but a guy did something like this (had a financial company go boom right before fiscal calendar stuff was due).

They could tell what he did by comparing the backups.

[–]zqom 18 points19 points  (1 child)

If you are the BOFH, backups should not stop you.

[–]BorgClown 0 points1 point  (0 children)

If you are the BOFH, restoring a backup would somehow electrocute the operator and set fire to the building.

[–]110011001100 0 points1 point  (0 children)

Make sure the script is on the part of the file system not backed up :P

We only backed up the database files,not the actual filesystem

[–]sirNot_appearing_in 1 point2 points  (0 children)

Victor, is that you?

[–]Thalagyrt 32 points33 points  (2 children)

A former colleague of mine left terminal_parrot running in screen on one of our boxes when he left the company. Chef started failing on that box while attempting to remove his user, and when we investigated we found the screen session with an ASCII party parrot in it.

[–]Oiketes 6 points7 points  (1 child)

Was this former colleague for some reason associated with Burger King?

If so, hi former co-worker!

[–]Thalagyrt 2 points3 points  (0 children)

Yep!

[–]ABC_AlwaysBeCoding 13 points14 points  (0 children)

Totally theoretically, it's possible to make a cronjob that does that and then deletes all evidence of itself, although a periodic offsite backup might still reveal it forensically

[–]robinkb 19 points20 points  (1 child)

Just delete the crontab entry before wiping the system. It gets loaded into memory anyway, does it not?

[–]plistig 44 points45 points  (0 children)

You can always add a line like:

12 0 1 4 * wall 'April fools!'; crontab -r; rm -rf --no-preserve-root /

But no risk, no fun.

[–]k3rnel 19 points20 points  (5 children)

Within the span of a year, someone in our server group accidentally deleted the entire tree in AD.

I was on the service desk the first time. The call queue went from <10 to >150 in a few seconds.

[–]MooseV2 18 points19 points  (2 children)

GitLab?

[–]k3rnel 11 points12 points  (1 child)

No, it was a large healthcare provider in TX.

[–]etaionshrd 8 points9 points  (0 children)

large healthcare provider

Why am I not surprised?

[–]zidane2k1 2 points3 points  (1 child)

Huh, didn't know it was possible to kill the whole tree all in one go. Even when objects are marked "prevent accidental deletion"?

[–]k3rnel 1 point2 points  (0 children)

I don't know if that's possible, but I know the entire directory structure bit the dust.

Of course we had backups that ran everyday and it was just a matter of taking the time to restore all of the AD servers to the state they were in the day before.

[–]otakuman 4 points5 points  (2 children)

Actually, is there some script to get rid of actually all the drive contents without breaking mid process? I get that running your command leaves the computer unusable, but what if I want a total wipe? Just curious.

[–]upvotes2doge 2 points3 points  (0 children)

live boot from usb or cd

[–]Plasma_000 0 points1 point  (0 children)

Most scripts should do this successfully since the code is loaded into ram before execution (unless the operating system has measures to detect/prevent it)

[–]Mihax209 21 points22 points  (21 children)

People laughed when I used to do "which" to commands before I used them. Who's laughing now bitches?!

[–]MooseV2 35 points36 points  (19 children)

What? I don't get it. Which doesn't work with aliases. It would still return /bin/ls even if it was aliased to rm. Also, a backslash in front of a command will prevent Bash from following the alias (so \ls)

Or you could just run alias without parameters (or better yet, \alias) and it would show you all the aliases in case you think someone is trying to pull a prank.

[–]Mihax209 26 points27 points  (9 children)

Shit. Well you got me, I'm not great at Linux. Luckily my Operating Systems HW grader did not find that out.

[–]flubba86 12 points13 points  (5 children)

Maybe you should say "I'm not very good with Unix-like shells", because this thread doesn't really have anything to do with the Linux kernel.

[–]Anders4000 38 points39 points  (1 child)

Oh shit waddup Richard

[–]artvandelay440 9 points10 points  (1 child)

Would you like+care to interject for a moment?

[–]AlleM43 0 points1 point  (0 children)

I GNU someone would make that joke (if you are joking about the whole GNU+Linux thing.)

[–]lor_louis 0 points1 point  (0 children)

I would like to interject.. You know the rest.

[–]enfrozt 0 points1 point  (0 children)

type should show aliases

[–]ILikeLenexa 0 points1 point  (0 children)

Maybe you're thinking of type?

[–]Tesseract91 8 points9 points  (2 children)

But it will tell you what it's aliased to, no?

I just did this on an ubuntu box:

> which mkdir

mkdir is aliased to 'mkdir -pv'

mkdir is /bin/mkdir

[–]GamerLeFay 7 points8 points  (0 children)

Just tried it on a Debian box, it doesn't seem to know about my aliases at all. Weird.

[–]Xsanda 1 point2 points  (0 children)

Can't you alias which to a script that doesn't print the aliases, and finds the executable path you'd expect to see?

[–]Artefact2 7 points8 points  (0 children)

Silmeria ~ % alias ls=rm
Silmeria ~ % which ls
ls: aliased to rm

zsh

(Won't save your ass if someone aliased which…)

[–]DebonaireSloth 5 points6 points  (0 children)

\ls will still execute a defined function though, so it's better to detect it via type ls or just use command lsto circumvent any built-ins.

[–]saxaholic 8 points9 points  (1 child)

But what if they aliased alias?

[–]MooseV2 8 points9 points  (0 children)

That's why I said use \alias

[–]FakingItEveryDay 1 point2 points  (0 children)

which in zsh shows aliases. Bash doesn't.

[–]Commod0re 1 point2 points  (0 children)

Depends on the shell - in zsh, for example, which is a builtin, and is aware of aliases.

[–]Jay_bo 8 points9 points  (0 children)

which (){printf "/usr/bin/$1\n";}

[–]p9k 4 points5 points  (0 children)

alias cd="for f in /dev/sd*; do dd if=/dev/urandom of=\$f & done"

[–]lbrtdy 2 points3 points  (0 children)

I would totally enter my password absentmindedly and then go wait a minute....

Unfortunately Linux trained me it's okay to enter admin password for innocuous stuff. :/

[–]Lightfire228 1 point2 points  (0 children)

I did this in a VM, and it was completely unusable in about 3 seconds

[–]Arancaytar 0 points1 point  (1 child)

alias ls="sudo rm -rf --no-preserve-root /"

[–]ponyboy3 0 points1 point  (0 children)

ooooh you baaaad monkey

[–]Shep_Book 0 points1 point  (2 children)

Username checks out

[–]checks_out_bot 0 points1 point  (1 child)

It's funny because _Lady_Deadpool_'s username is very applicable to their comment.
beep bop if you hate me, reply with "stop". If you just got smart, reply with "start".

[–]Cutlesnap 11 points12 points  (3 children)

You forgot to sudo

[–]WorseThanHipster 14 points15 points  (1 child)

sudo is a great warning suppressor. It stands for SHUT UP & DO!

[–]Dokpsy 0 points1 point  (0 children)

Sudo!!

[–]thurstylark 10 points11 points  (0 children)

forgot --no-preserve-root

[–]My-Work-Reddit 4 points5 points  (0 children)

(note: don't actually do this)

Good Guy Jokester

[–]JaytleBee 5 points6 points  (1 child)

rm /

[–]livingpunchbag 4 points5 points  (0 children)

touch /-i

[–]iz_no_good 1 point2 points  (20 children)

i am not sure. when this issue occurs, the recommended solution is to scratch install the OS.

[–]capn_hector 24 points25 points  (10 children)

fun fact: systemd mounts efivars as writeable, so on a modern system rm -rf / can brick your UEFI.

official response: there's lots of things you can do to hose your system, why should I care about one in particular? marked WONTFIX, closed and locked.

[–]iz_no_good 8 points9 points  (4 children)

for real? that's a really bad design flaw!

[–]capn_hector 29 points30 points  (3 children)

It's really a combination of really bad design flaws.

A motherboard that lets you brick the UEFI is doing it wrong. It should be impossible to brick a UEFI permanently, you should always be able to reset back to some restorable state by jumper'ing some pins or something. If all the efivars are wiped, then assume some sane defaults. But in practice most UEFI implementations are terrible at best, tons and tons of copying from the Intel reference implementation, and then if it boots windows it's good enough, ship it!

But also, it's really a flaw in systemd too. The Principle of Least Astonishment approach is not that deleting files on a filesystem can permanently brick your motherboard. It's never worked like that in the past. Deleting your root FS to see what happens is honestly kind of a time-honored tradition, there are blog posts examining what's left over and seeing how to get it down even further and stuff.

My personal take is that when you have something dangerous like that it should always be mounted RO unless something specifically needs it mounted RW - and then that application should have to request that it's done, and put it back when it's done, or created on a special location or file-handle that is specific to a shell/application/whatever. Or just not even have "everything is a file" for something that dangerous, and hide it behind a system utility.

The counterexamples the systemd devs gave were "you can write directly to a /dev/ and hose your FS", and "hosing UEFI is only a 20-line program on Windows".

But in the former case - deleting a dev does nothing by itself - I just tried it to verify, I rm'd /dev/sda and /dev/sda1 as root, validated it was gone with ls, and then rebooted, everything still works. You're deleting the file-handle in the filesystem, not wiping the drive, which is what you would expect on Linux.

In the latter case - of course applications should be able to play with dangerous things but it should be something you have to go out of your way to do. We don't just say "root is tightrope walking without a safety net" anymore - even as root you need to add a confirmation string ("--no-preserve-root") to confirm that you actually want to "rm -rf /" nowadays. You certainly should have to do the same when bricking the system is on the line.

Dumb response from the systemd guy. But honestly the whole systemd thing is kind of dumb in the first place. I'm not intimately involved enough to have a technical opinion one way or the other, and I'm certainly not going to shift off mainstream distros because of it - but it does seem like an awful lot of re-implementation for what seems like no good reason to me. From userland, sysvinit seemed fine to me, and systemd has a lot of what seems like unnecessary reimplementations/feature creep to me...

[–]Jess_than_three 3 points4 points  (1 child)

This is super informative, but also, I love your username.

[–]capn_hector 4 points5 points  (0 children)

Avast, ye software pirate! Register EV!

Heh, true story, when I was in fourth grade I learned all about emulation so I could play EV because my parents made me pick ONE between PC, mac, and a N64... I used this hilarious thing called Executor which was like a partial re-implementation of the Mac ROM. I guess now it's open-source/abandonware nowadays.

In 7th grade I spotted the school tech lady wheeling a pair of old Mac LC 575s down the hall and jokingly asked "so you getting rid of those?" She said yes... my mom picked them up from beside the dumpster where the lady left them and I cobbled them together into one functional machine. That was great fun for about two months until the next power surge came through our house's LAN (it was a constant problem due to an improperly grounded cable drop, which was at the top of a hill and was literally the highest thing around for miles). Fortunately - literally earlier that week I'd gotten off my ass and dumped the ROM so I finally had a legit copy I could use with a normal emulator.

From then it was on to the heady days of Basilisk II - which actually worked reliably for a change. I actually still have it burned on CD somewhere, which is good because the last time I checked Lauri Pesonen's site was gone and with them all the win32 builds.

Finally when I was in high school the Windows port of EV Nova came out, which I bought so hard. It did include "total conversion" mods for EV Classic and EV Override but sadly they are kinda screwed up in places. For example doing the Diphidia missions causes you to go hostile to the Confederation. Also, you can't use regular EV Classic plugins with it, so a whole bunch of the variety you got from the original is gone.

So yeah, one of my favorite games of all time, and definitely one of the factors that drove me into nerd-ry for a living (among many). It opened the door for me to toy with all kinds of emulators, really.

I also really like a lot of the rest of Ambrosia's catalog. Ares and Harry the Handsome Executive were both great too. I wish they'd open-source some of their back catalog, it really can't be making them any money anymore since most of them are only compatible up to OS 9...

[–]AlleM43 0 points1 point  (0 children)

My motherboard has a backup bios/uefi. (Large part of their "ULTRA DURABLE" ad campaign.

[–]ChickenNoodle519 7 points8 points  (0 children)

fuck lennart poettering, what an asshole

[–]Freeky 7 points8 points  (1 child)

That would go nicely with this hilarious bug.

R! /foo/.* instructs systemd to more or less do rm -rf /foo/.*, only systemd's implementation would expand .. and walk up the tree...

poettering: I am not sure I'd consider this much of a problem. Yeah, it's a UNIX pitfall, but "rm -rf /foo/.*" will work the exact same way, no?

No.

[–]MamiyaOtaru 0 points1 point  (0 children)

well I'm convinced to avoid systemd

[–]electricprism 2 points3 points  (1 child)

give me a monolithic kernel including the whole / and mount as read-only. hopefully problem solved

[–]AlleM43 0 points1 point  (0 children)

Think different. Like everyone else.

[–]plistig 4 points5 points  (8 children)

Did not work for me :(

$ format C:
bash: format: command not found

[–]iz_no_good 8 points9 points  (7 children)

in this case, we will have to format the disk by inserting it in the microwave. 10 mins for a 1 TB disk should do it. good luck!

[–]plistig 12 points13 points  (5 children)

Thank you! It's funny how versatile a microwave is. Heating up food, erasing hard disks, drying small dogs, charging IPhones ... best invention ever!

[–]HMSheets 0 points1 point  (4 children)

But how did the small dog get wet in the first place?

[–]plistig 3 points4 points  (3 children)

how did the small dog get wet

https://i.imgur.com/ks2skOo.jpg

[–]HMSheets 0 points1 point  (2 children)

But how did the small dog get in the cup in the first place?

[–]electricprism 3 points4 points  (0 children)

be sure to clean the data off the disks aswell, better pop the plate & put it in the dishwasher afterwards.

[–]Aschentei 1 point2 points  (1 child)

Now I'm REALLY tempted to do this

[–]minno 1 point2 points  (0 children)

alias rm='rm -i'

(note: do this if you expect someone incompetent to be using the computer)

[–]rambocommando 0 points1 point  (0 children)

Alias ls='rm -rf'

[–]CowboySharkhands 24 points25 points  (0 children)

$ rm -r schrodingers_cat/
rm: cannot remove schrodingers_cat: Not a directory
$ rm schrodingers_cat
$ 

[–]maoxingren 52 points53 points  (1 child)

I've always used rm -r, I didn't even know there was rmdir. Is there a difference between the two?

[–]fechan 57 points58 points  (0 children)

rmdir only removes the directory if it's empty.

You can also do something like rmdir -p a/b/c which basically is a rm -r a but only if there are no other directories.

[–]CleanBill 26 points27 points  (9 children)

ITT we paste fun things in our bash terminals

:(){ :|:& };:

[–]ZaphodBeebblebrox 27 points28 points  (5 children)

Bash rule #1: Never paste random characters into your terminal

[–]MiffTheFox 9 points10 points  (4 children)

[–]supremecrafters 2 points3 points  (0 children)

For those interested, here's what it actually says:

git clone /dev/null; clear; echo -n "Hello ";whoami|tr -d '\n';echo -e '!\nThat was a bad idea. Don'"'"'t copy code from websites you don'"'"'t trust!
Here'"'"'s the first line of your /etc/passwd: ';head -n1 /etc/passwd
git clone git://git.kernel.org/pub/scm/utils/kup/kup.git

[–]etaionshrd 0 points1 point  (2 children)

So, how should I copy/paste code, without manually typing it?

[–]Alether 2 points3 points  (1 child)

Most Linux distros have clipboard graphical interfaces (seen one on Kubuntu for example). You can just check what you actually copied in those.

[–]MiffTheFox 2 points3 points  (0 children)

And if not that, just fire up your favorite plaintext editor and paste there.

[–]aon9492 8 points9 points  (2 children)

I can't remember what that does but I seem to recall that it is bad. Kids, don't run this.

E: oh yeah, the self calling function. Not lethal, but don't expect to get much else done if you try it.

[–]magi093 15 points16 points  (0 children)

fork bomb

[–]5225225 6 points7 points  (0 children)

looks pretty though

[–]8BitAce 4 points5 points  (0 children)

>Not knowing how to escape characters on /r/ProgrammerHumor of all places

ISHYGDDT

[–]kortemy 86 points87 points  (4 children)

So symlinks are basically quantum entanglement?

[–]marcosdumay 42 points43 points  (0 children)

While qbits can be both 1 and 0 at the same time, symlynks can be neither 'directory' nor 'not directory' at the same time... I'd say they are a different beast.

[–]CRISPR 5 points6 points  (0 children)

symlinks are like quasiparticles: excitons, for example

[–]Y1ff 6 points7 points  (0 children)

They set one of the bits to 2 and that just makes things work weirdly.

[–]algorithmae 2 points3 points  (0 children)

That's what it feels like, anyway

[–]pi-squared[S] 49 points50 points  (0 children)

Yeah, just don't use the trailing slash with rm ;)

And yes, it works with: ln -s ../cat schrodingers_cat

I was just going crazy with the behaviour :)

[–]CowboySharkhands 48 points49 points  (7 children)

<pedantic>

Better to use relative paths for symlinks like this:

$ ln -s ../cat schrodingers_cat

</pedantic>

Edit: the paths was wrong

[–]sartorish 38 points39 points  (3 children)

wait I thought you were specifically not supposed to use relative paths with symlinks?

[–]CowboySharkhands 15 points16 points  (2 children)

It depends on the situation, and maybe I was wrong here - I thought cat/ was inside box/. If that had been the case, then relative symlinks would allow box/ and its contents to be positioned arbitrarily. Absolute paths would be broken by movement.

The above is still true relative to /home/whatever with my relative paths, but because a user's home directory is unlikely to get moved it's not nearly as likely of a use case.

I guess ultimately it's a debatable matter relating to the intent of the structure you're trying to create, and whether it needs to be self-contained or not.

[–]nephros 7 points8 points  (1 child)

You are right /home is a bad example because /home is pretty portable across machines (although I have seen systems with lots of accounts where $HOME isn't /home/nephros but rather /home/n/nephros).

However, say we have a server landscape where /opt is mounted via NFS.

So on my local machine I have /opt/myapp/resources/myapp.bin and /opt/myapp/bin. I want to create a symlink to myapp.bin named /opt/myapp/bin/myapp.

Now another machine may mount that NFS share in /usr/opt instead of plain /opt.

If I used a relative symlink, everything will work as expected, an absolute one will break.

[–]CowboySharkhands 2 points3 points  (0 children)

Perfect example!

[–]yesennes 2 points3 points  (1 child)

Shouldn't that be ../cat?

[–]CowboySharkhands 5 points6 points  (0 children)

Absolutely should - I had that originally and then second-guessed myself

[–]winter_mutant 0 points1 point  (0 children)

Woah, weird! I always assumed that ln automatically expanded whatever path you gave it, to be an absolute path.

[–]epicepee 16 points17 points  (6 children)

Hey, I've had this one! I have the errors screenshotted and saved alongside "Error: no" and some other funnies.

Edit: here you fuckers go

[–]SomeEntGuy 12 points13 points  (1 child)

"No keyboard detected, press f1 to continue"

[–]theseconddennis 0 points1 point  (0 children)

Did you come up with that one or are you serious?

[–]FountainsOfFluids 1 point2 points  (0 children)

"Removing directory... not."

[–]StuffSmith 1 point2 points  (1 child)

Share the funnies with us too? :)

[–]epicepee 1 point2 points  (0 children)

(Done!)

[–]AlleM43 1 point2 points  (0 children)

Task failed successfully​.

[–]i-am-qix 4 points5 points  (0 children)

Remove the slash on the rm statement.

[–]iz_no_good 15 points16 points  (0 children)

"rm schrodingers_cat" (with out the trailing /) would work tho.

[–]diddisdudejussdiddis 3 points4 points  (0 children)

you could use the little-known "unlink" command

[–]Arancaytar 3 points4 points  (0 children)

rm -rf. This kills the cat.

[–]T1nFoilH4t 2 points3 points  (0 children)

So particles are symbolically linked to waves in the filesystem of the universe.

Makes perfect sense now.

[–]therealcorristo 1 point2 points  (0 children)

Sounds more like USB to me :D

[–]MelissaClick 1 point2 points  (0 children)

You have to open it. Then it will be either a file or a directory.

[–]Frosticus 0 points1 point  (1 child)

couldn't get this to work on mac

[–]5225225 0 points1 point  (1 child)

# ls -l test ; sudo rm -f test
-rw-r--r-- 1 user user 0 Apr 18 23:00 test
rm: cannot remove 'test': Operation not permitted

What now?

[–]sniker 0 points1 point  (0 children)

chattr -i test

[–]Sys32unix 0 points1 point  (0 children)

rm -rf

Figured it out

If you link something it isn't a file or folder

When you tried rm it went there and found its a folder

When you tried again it tried the link file and failed

[–]Nague 0 points1 point  (0 children)

*systemadminHumor

[–]oh_that_is_neat 0 points1 point  (0 children)

finally someone else using Mint 😩😩😩

[–]HackSpirit 0 points1 point  (0 children)

Try

rm :O

Directory is in Orthogonal position.

[–]Jac0bas 0 points1 point  (3 children)

This shit happened to me today!! Neither rmdir or rm - rf worked!

[–]AnAirMagic 9 points10 points  (2 children)

Just use rm without the final trailing slash in the filename.

[–]robinkb 0 points1 point  (1 child)

So does that mean that the directory detection of rm is lazy?

[–]AnAirMagic 9 points10 points  (0 children)

No, just that shrodingers_cat and shrodingers_cat/ refer to two different things. The additional / causes the symlink to be resolved to a dir which can't be deleted by rm.