r/linuxquestions • • Mar 22 '22

Absolute most dangerous command in linux?

I am familiar with the

sudo rm -rf /* 

and yes, this is very dangerous. Like I get it. Beyond comprehension. However, I have ran this command and while everything does get removed and the VM won't boot the next time around, my current shell is still intact. For example, I run:

user@vm:/$ echo we still alive out here?
we still alive out here?

Sure `ls might be gone:

user@vm:/$ ls
-bash: /usr/bin/ls: No such file or directory

but it still knows to print that error message. If I ssh, I want the output to be:

...connection lost

Anybody know a command so deadly, that upon running it, the OS will instantly crash to an unrecoverable state and corrupt everything? Could this command even exist? is the linux kernel designed for this?

148 Upvotes

171 comments sorted by

111

u/system_root_420 Mar 22 '22

If you don't know what you're doing or you're not paying attention, it's easily dd

62

u/erasmuswill Mar 22 '22

The one time I was trying to write an ISO to a flash drive. After a while I was suspicious of why the LED on said flash drive was not flashing. Turns out I was in a SSH session

43

u/discoshanktank Mar 22 '22

Fuck dude that ending gave me chills

19

u/KCGD_r Mar 22 '22

I configured my dd to not work unless I get more than 7 hours of sleep

7

u/erasmuswill Mar 22 '22

This should be the default configuration. Less than 7 hours of sleep having a wizard of confirmations

3

u/funbike Mar 22 '22 edited Mar 22 '22

LOL, yeah. I used to copy my dotfiles to servers I had access to. The common PS1 value (shell prompt) really messed with my head.

I changed my .bashrc to set the prompt on ssh sessions to something very different so I would keep where I was straight.

I had the same issues with VMs and containers, but there's less damage possible there. Unfortunately, it's not always possible for my .bashrc to detect when it's in a VM, unless I'm using ssh.

2

u/[deleted] Mar 22 '22

I did that once, but luckily I hadn't gotten too far in deploying anything at the time and it wasn't a big loss :p

2

u/AsleepThought Mar 22 '22

Turns out I was in a SSH session

this is why you always put your HOSTNAME in your shell PS1 prompt message

6

u/Zambito1 Mar 22 '22

Classic disk destroyer

3

u/psmgx Mar 22 '22

Day Destroyer, cuz you do it wrong it ain't just the disk that's ruined

5

u/Capt_Skyhawk Mar 22 '22

I wrecked a luks boot drive doing that ... Embarrassed to say it wasn't that long ago. It only ran for a few seconds but the damage is done.

4

u/[deleted] Mar 22 '22

Yup, you could easily make your whole drive a giant bootable ISO.

0

u/[deleted] Mar 22 '22

[deleted]

12

u/psmgx Mar 22 '22 edited Mar 22 '22

Writes digital data (dd) directly to a location.

Great way to copy, exactly, in like a 1s and 0s sense, a file / partition / disk to another place. Like 100% identical bits. Also a great way of creating blank dummy files, files full of random junk, or a 2GBs of just 0's, etc. -- plenty of use cases.

But do it wrong and it's merciless.

edit: so why is it dangerous? fat finger something or point at the wrong place and it'll annihilate and rewrite whatever you point it at. Also a 1-to-1 copy isn't always great, e.g. when you move a file via cp or mv it changes some of the metadata, pointers, inodes, whatever, but DD won't do that which can cause issues.

1

u/[deleted] Mar 23 '22

Short for disk destroyer. It destroys disks of unsuspecting GNU/Linux users who forget that it is indeed GNU/Linux (or GNU plus Linux). Truely Richard's most innovative and brilliant addition to the GNU operating system.

110

u/LeiterHaus Mar 22 '22

Any incorrect command at all in Suicide Linux

But probably people who use dd without knowledge or care cause the most actual damage.

38

u/Cannotseme Mar 22 '22

Im gonna argue that in some cases rm -rf /* is more dangerous because systemd mounts efi variables. It could brick your motherboard

8

u/Down200 Mar 22 '22

Aren’t most motherboard variables non-writable by default though? I remember seeing somewhere that certain variables aren’t even writable by root, and you need to mount the file or something to change the value

6

u/Cannotseme Mar 22 '22

I just deleted one a couple days ago so I could add a new boot entry, so no.

Edit: they all have the same perms

2

u/Down200 Mar 22 '22

Interesting, when I tried to change my motherboards variables they were read-only and I wasn’t able to change them even as root.

7

u/aioeu Mar 22 '22 edited Mar 22 '22

The kernel has a list of a few EFI variables that are assumed to be safe to be deleted or overwritten. Any variable that isn't in this list starts off with its "immutable" attribute set. A sufficiently determined sysadmin can remove that using chattr.

This isn't reflected in the permissions of the files. File attributes are quite separate from file permissions.

4

u/Cannotseme Mar 22 '22

Come to think of it, I did actually read about that and forgot about it. Either way I’m not taking my chances

3

u/enp2s0 Mar 22 '22

The EFI standard is designed so that even if you nuke efivars you can still recover

Manufacturers are terrible about following the standard.

2

u/funbike Mar 22 '22

"Some"? yes. "All"? no. "Any" is enough to be a huge problem.

1

u/No_Telephone9938 Mar 23 '22

So you mean in those cases you wouldn't be able to boot into your bios? How does that work?

1

u/alheqwuthikkuhaya Mar 22 '22

It used to mount them as write, but I don't think it does anymore thankfully. Terrifying to imagine a time where that wasn't true.

30

u/user1048578 Mar 22 '22

Yep, that's why its nickname is disk destroyer.

4

u/pgbabse Mar 22 '22

I once used dd on the wrong dev/sd*

No error message, no warning, no complains

Pouf, there goes the home partition

Absolute mess

54

u/multi_tasty Mar 22 '22

OP should at least explain who they wanna see crying and why

10

u/AnUncreativeName10 Mar 22 '22

I'm thinking, self destruction button set to certain parameters. E.g. when I log in I gst a banner message telling me to answer a question. If I answer wrong more then 3 times it self destructs.

0

u/Dogzirra Mar 22 '22

I would go to more tries.

This dance has happened more than a couple times. I have thought that I fat-fingered the first, was careful on the second, but a num lock or cap lock burns #2.

Is my password manager correct? Oh no, oh no, oh no, jeeebus... GAH it WORKED, or NOOOOOO! It's gone!!!!

And that is just one app/file.

1

u/images_from_objects Mar 22 '22

Yeah, I'm curious too. I'm thinking kill switch or they really don't like someone.

Regardless, this thread has been a fun read.

-1

u/linuxgeekmama Mar 22 '22

I wonder if they’re Ukrainian and planning to use this on some Russian systems.

94

u/[deleted] Mar 22 '22

chmod -r

chown -r

14

u/lightrush Mar 22 '22

Underrated.

1

u/[deleted] Mar 22 '22

what does chown -r do? I know the chmod -r one removes read perms, but what does the chown one do?

1

u/julioqc Mar 22 '22

remove ownership

1

u/obvithrowaway34434 Mar 23 '22

There is no -r option for chown at least not in the GNU version.

0

u/Zambito1 Mar 22 '22

On what version of chown?

-5

u/[deleted] Mar 22 '22

v69.240

0

u/[deleted] Mar 22 '22

[deleted]

24

u/[deleted] Mar 22 '22

I think its for recurse. Change this permission on all files and subfolders.

Eg: sudo chmod -R +777 /

Thinking about it, it might also be remove read (r) from all files.

Both commands should F up your system anyway :)

13

u/DashJackson Mar 22 '22

Just a couple of weeks ago one of my coworkers did this to the app directory for a reporting server and another coworker thought that just chmod 777 /app would make everything better....thank science for backups...and tar.

8

u/[deleted] Mar 22 '22

Tried chmod 777 -R / on my system once. You would think that it shouldn't cause much trouble, as everyone got rights to everything. Well, the system disagreed and was impossible to fix, at least a lot faster to just reinstall

12

u/Sophira Mar 22 '22

I haven't tried it myself, but I'm almost certain that one of the reason it failed in this case is because doing "chmod 777" doesn't do what you think it does; the actual permission set number can be up to four octal digits, not three. As such, 777 is actually 0777 and it means you'll lose things like the suid bit on executables that need it, such as su and sudo. You also lose the sgid and sticky bits.

That said, you should never put the suid bit on executables that don't need it, because it will mean that the executable runs as the owner of the binary (which in most cases is root) rather than the user calling the executable. These bits also have a different meaning for directories.

That said, if you wanted to try as a test (on a disposable isolated VM only - seriously, do not do this on any system you care about or that is connected to a network), try using 7777 instead of 777.

4

u/[deleted] Mar 22 '22

That sounds correct. I remember getting a lot of errors regarding suid, and so on. Many binaries also complained about having rights for users other than root.

All over a total mess :)

1

u/[deleted] Mar 22 '22

[removed] — view removed comment

2

u/[deleted] Mar 22 '22

As long as you run it on a folder you have control over, and know it contents there is no issue.

The problems start if running it recursive on / or other system folders like sbin, bin, dev and so on

3

u/[deleted] Mar 22 '22

[removed] — view removed comment

2

u/[deleted] Mar 22 '22

Permissions can be quite difficult, depending on your needs ofc.

Just remember to have backups, then messing up your system is just a good learning opportunity :)

1

u/[deleted] Mar 22 '22

[removed] — view removed comment

1

u/DashJackson Mar 22 '22

Asterisk might be the most dangerous key on the keyboard.

→ More replies (0)

1

u/space_wiener Mar 22 '22

What does the first do differently?

→ More replies (0)

10

u/KickMeElmo Mar 22 '22

I hope they were told "you are why backups exist."

1

u/DashJackson Mar 22 '22

The criticality of the server that was broken and how blinded we were by the loss of centralized performance monitoring for the service/application we support really drove the point home. I think the guy was mentally preparing himself to turn in his badge. Most of the rest of my team are far more comfortable in the application UI than the CLI and they were all pretty sympathetic (as well as generally clueless lol). Luckily they have a couple of us underdwellers on staff who know how to extract a directory from a tarball.

2

u/KCGD_r Mar 22 '22

couldn't you just boot a live image, mount the disk and fix the permissions afterwards?

1

u/[deleted] Mar 22 '22

Not in an easy way, because you would never know what the correct permissions are for everything. The best chance would be to try and reinstall all packages, but I still think you be would quite fubar

3

u/rainformpurple Mar 22 '22

I hosed a FreeBSD (or OpenBSD) server quite badly ages ago with chown, thankfully there was a file with a permissions list included in the source tree, along with instructions on how to build the permissions tree and get them all back to how they were supposed to be. Those were a few very stressful hours.

0

u/iamawhale1001 Mar 22 '22

Huh, I did this once in school on one of the lab machines. They had setup that would let you put html files in a certain folder and it would expose them to the internet so we could have static web pages. Pretty sure I used chmod -R to make the whole thing executable. Hopefully I didn't break anything, though it's been years so I assume my account is long gone.

32

u/The_camperdave Mar 22 '22

sudo reboot if you have the windows install media in your DVD.

3

u/Harvey_the_Hodler Mar 22 '22

“Hi, Lisa! Hi, Super Nintendo Chalmers, I’m learneding.”

1

u/rainformpurple Mar 22 '22

Not a problem, it requires the user to press a key to start the installer. If no keys are pressed, the installer is skipped entirely and the boot loader loads the first operating system it finds on the first disk it finds.

21

u/anna_lynn_fection Mar 22 '22

On SSD? blkdiscard. Immediately wipe your ssd in seconds with no reasonable chance at data recovery.

4

u/soggynaan NixOS ❄️ Mar 22 '22

Or memory cell clearing. Done in seconds and it queues the SSD for SECURE ERASE whereas blkdiscard queues for TRIM.

18

u/edman007 Mar 22 '22

Flashing garbage to the bios, or better yet vbios or drive firmware will properly brick a system. As in you likely won't be able to get your system to POST, nevermind reinstall the OS.

However doing it is luckily difficult. Most of the commands to do it don't have options to bypass the checksums and you need to have the firmware uploader to accept garbage first

0

u/DudePotato3 Mar 22 '22

This would only brick the bios though. Replacing it/the motherboard would leave the os and everything else intact

1

u/pearcidar43 Dec 23 '22

blow your fucking computer with a RPG then

13

u/dwhite21787 Mar 22 '22

a fork bomb used to be, any fool could run one. It might not be so bad these days.

18

u/unkilbeeg Mar 22 '22

In the Operating Systems class, students learn about forking processes. Not necessarily deliberately, every semester there would be somebody who let them get out of control.

There's a per-user process limit now. :-)

7

u/[deleted] Mar 22 '22

Can confirm, was trying to test ddos against a server I am setting up and when I ran

ddos command &

it would get shot down in less than 30 seconds. Learning to expand that fixed it though :D

11

u/Sol33t303 Mar 22 '22 edited Mar 22 '22

Thats not "dangerous" though, pretty much just strangles your RAM until either you reboot or OOM gets a handle on the situation.

6

u/michaelpaoli Mar 22 '22

Not RAM, but fills the process table - for user or up to max system limit, depending who runs it and how limits are configured. Burns CPU, and no open slots to create an additional process, but doesn't typically eat up all that much RAM>

2

u/grem75 Mar 22 '22

Rebooting solves that though.

0

u/dwhite21787 Mar 22 '22

true. I was thinking OP was asking for a non-privileged disaster. Because sudo opens the BIG Pandora's box

10

u/dthusian Mar 22 '22

If you want to make any current processes stop functioning, you somehow need to corrupt their memory. The most effective way to do this is to write a kernel module that mucks around with the paging tables, but that is likely to cause a kernel panic and can't be fit in one command.

5

u/zebediah49 Mar 22 '22

You can dd to /dev/mem I believe.

24

u/sabboo Mar 22 '22

Install an arch based distro as dual boot. Wait three months. Do a normal update. No more booting.

8

u/tom_yacht Mar 22 '22

I have been dual booting Arch since before covid and I got no such issue. Care to explain? I'm curious.

5

u/5553331117 Mar 22 '22

Same. Actually just ran pacman -Syu on a win10/arch build that I hadn’t booted since Nov 2020. No issues at all from either OS.

2

u/multi_tasty Mar 22 '22

Care to explain? I was about to do that o___o

0

u/[deleted] Mar 22 '22

[deleted]

4

u/[deleted] Mar 22 '22

If it's downloading you can cancel, if it's installing then don't.

Oh and make sure to update before installing anything if you do cancel the download.

2

u/KCGD_r Mar 23 '22

I've had to cancel updates before and have found that as long as it hasn't finished downloading the packages you can cancel the update. But ONLY if it hasn't finished downloading. Anything else will brick your OS

3

u/[deleted] Mar 22 '22

Doesn't Linux keep old kernels for this exact scenario? From the bootloader I'm sure you can choose to boot the old kernel as it's known-working.

1

u/sabboo Mar 22 '22

Kernel is irrelevant if grub gets f’ed up.

0

u/[deleted] Mar 22 '22

linux is a kernel.

Arch doesn't keep old ones.

1

u/[deleted] Mar 22 '22

This is true of most distros though.

0

u/sabboo Mar 22 '22

I’ve got a Manjaro distro that’s outlived this by being single boot

1

u/ArsenM6331 Mar 22 '22

What you really don't want is to have glibc update and then cancel it right after that. Everything that was not updated after that, including most coreutils, will break. The only way I can think of to fix this is to mount on a live disk and try to manually replace glibc with the older version, then chroot and perform the update completely.

14

u/[deleted] Mar 22 '22

People will say sudo rm -rf /*, but I will take the hot position of anything involving /proc. It is a shitty design and should be removed and replaced with syscalls. It should not be accessible from userland at ALL. Did you know you can cause a kernel panic by running echo c > /proc/sysrq-trigger? Wanna know to disable it? Same way you enable it, by writing to /proc ._. This is a terrible design and should just be removed. I know it gets tiring hearing this, but OpenBSD was right about this from a security perspective and a design perspective. Have you seen the disgusting ways people parse /proc? There aren't even good consistent ways of handling it! It hurts every from users to sysadmin to programmers! Who here has walked the process tree to get a parent process? Did you know it is a literal function on OpenBSD? Standardized, secured, and well written? Why can't we have nice things? WHY!?

6

u/Teh_Jibbler Mar 22 '22

Well that certainly does the job, but requires root access.

1

u/ArsenM6331 Mar 22 '22

Because I refuse to use C libraries to do my programming if I can at all avoid them. Using C libraries makes everything infinitely more complicated when I want to cross-compile or transfer my binary to another system that is completely different from the one compiling, which is quite often in my case.

If this was a function, it would have to be written well in every single non-C language (or at least ones not using libc).

I agree that some of these options need to be removed from /proc, but in my opinion, it is extremely useful and should be kept.

8

u/[deleted] Mar 22 '22

Hmm use dd to write 0s over the root partition?

13

u/[deleted] Mar 22 '22

not a linux command but still dangerous:

light your computer on fire

12

u/haikusbot Mar 22 '22

Not a linux command

But still dangerous: light your

Computer on fire

- festive_x


I detect haikus. And sometimes, successfully. Learn more about me.

Opt out of replies: "haikusbot opt out" | Delete my comment: "haikusbot delete"

8

u/Teh_Jibbler Mar 22 '22

First line has 6 syllables.

3

u/[deleted] Mar 22 '22

shoot

4

u/[deleted] Mar 22 '22

i am a master of haiku now

2

u/[deleted] Mar 22 '22

Haiku, which is funny since the HaikuOS (and its predecessor, BeOS) had is_computer_on_fire() system call.

0

u/techtornado Mar 22 '22

In times past, lp0 is on fire was a real error

10

u/QliXeD Mar 22 '22

Remove the initramfs and kernels, nobody will notice anything until reboot :D

0

u/glp_808 Mar 22 '22

All is well until reboot. Classic!

0

u/QliXeD Mar 22 '22

If you want to make this more annoying, wipe out the EFI partition, but left it marked as EFI.

6

u/uh_no_ Mar 22 '22

I mean, you can load a kernel module that both directly writes 0's to disk and then flashes the BIOS, then disables the write protect flag on the entire RAM space, including the kernel, except for the module itself, and overwrites it before overwriting itself last...

6

u/michaelpaoli Mar 22 '22

is the linux kernel designed for

Linux, rather like UNIX, generally presumes you know what you're doing. It generally attempts to comply with what it's commanded to do ... unlike some other operating systems that more typically make you play Mother May I every step of they way on most anything you might actually want to do even if you dang well know what you're doing and what the command will do.

So ... more dangerous ... and limiting to the host itself:

  • with attached CRT, configure the refresh rate outside of hardware supported range - and you can actually damage hardware. Might need an older CRT and/or graphics card to be able to do this, as non-ancient >=VGA has protocols between monitor and controller on the >=VGA interface to detect monitor's capabilities - and it's possible the graphics card won't drive it outside of the detected parameter range.

  • can use hdparm to do a secure erase on drive - maybe even start multiple simultaneously (might not be a single command, but could be a one-liner)

  • use recursively, e.g. chown, chgrp, chmod

  • dd from /dev/zero to drive(s) or otherwise likewise overwrite them - or really most anything overwriting drive(s).

  • screw over BIOS/CMOS/firmware, seriously screw up EFI data

  • there are almost certainly more (and may variations/extensions of the above), but those are at least some that quickly jump to mind.

Anyway, both instantly crashing and to irrecoverable state are generally at least somewhat at odds with each other. Generally the former targets current running state and/or RAM, and the latter generally persistent storage and/or physical hardware ... though they'll often overlap at some point - notably the latter onto the former.

8

u/regancipher Mar 22 '22

:(){ :|: & };:

7

u/PaddyLandau Mar 22 '22 edited Mar 22 '22

This is a fork bomb, and while it will cause your computer to come to a grinding halt, it will corrupt barely little, if anything. Interestingly, there are steps that you can take to limit the effect.

5

u/WikiSummarizerBot Mar 22 '22

Fork bomb

In computing, a fork bomb (also called rabbit virus or wabbit) is a denial-of-service attack wherein a process continually replicates itself to deplete available system resources, slowing down or crashing the system due to resource starvation.

[ F.A.Q | Opt Out | Opt Out Of Subreddit | GitHub ] Downvote to remove | v1.5

7

u/olystretch Mar 22 '22

dd aka disk destroyer.

6

u/No_Dependent_5066 Mar 22 '22

Full of dangerous commands. Eye opener for me.

Let me add one more command.

"rm -rf /etc/fstab"

4

u/coffee-loop Mar 22 '22

At least this is repairable, you could use a live usb to mount and chroot the root partition, then rebuild the /etc/fstab file. You just need to man fstab to get the parameters you’d need, so no google needed if you’re somewhat comfortable in a Linux environment.

2

u/No_Dependent_5066 Mar 23 '22 edited Mar 23 '22

Thanks for the solution.

5

u/RadioNick Mar 22 '22

I’m surprised no one has mentioned the Magic SysRq key, designed to induce a kernel panic: https://unix.stackexchange.com/questions/66197/how-to-cause-kernel-panic-with-a-single-command

This, of course, shouldn’t cause any damage.

2

u/PaddyLandau Mar 22 '22

Because the OP asked for, "a command so deadly, that upon running it, the OS will instantly crash to an unrecoverable state and corrupt everything". The Magic SysRq key doesn't do this.

5

u/systemBuilder22 Mar 22 '22

yes > /dev/sd0

I started in the days before sudo, when men were men and running a root shell was how we flexed on Unix ...

5

u/ZuriPL Mar 22 '22

Add --no-preserve-root

2

u/Zambito1 Mar 22 '22

Won't change anything for /*

3

u/[deleted] Mar 22 '22

How to Crash Systemd in One Tweet

The following command, when run as any user, will crash systemd:

NOTIFY_SOCKET=/run/systemd/notify systemd-notify ""

After running this command, PID 1 is hung in the pause system call. You can no longer start and stop daemons. inetd-style services no longer accept connections. You cannot cleanly reboot the system. The system feels generally unstable (e.g. ssh and su hang for 30 seconds since systemd is now integrated with the login system). All of this can be caused by a command that's short enough to fit in a Tweet.

Edit (2016-09-28 21:34): Some people can only reproduce if they wrap the command in a while true loop. Yay non-determinism!

The bug is remarkably banal. The above systemd-notify command sends a zero-length message to the world-accessible UNIX domain socket located at /run/systemd/notify. PID 1 receives the message and fails an assertion that the message length is greater than zero. Despite the banality, the bug is serious, as it allows any local user to trivially perform a denial-of-service attack against a critical system component.

The immediate question raised by this bug is what kind of quality assurance process would allow such a simple bug to exist for over two years (it was introduced in systemd 209). Isn't the empty string an obvious test case? One would hope that PID 1, the most important userspace process, would have better quality assurance than this. Unfortunately, it seems that crashes of PID 1 are not unusual, as a quick glance through the systemd commit log reveals commit messages such as:

coredump: turn off coredump collection only when PID 1 crashes, not when journald crashes

coredump: make sure to handle crashes of PID 1 and journald special

coredump: turn off coredump collection entirely after journald or PID 1 crashed

Systemd's problems run far deeper than this one bug. Systemd is defective by design. Writing bug-free software is extremely difficult. Even good programmers would inevitably introduce bugs into a project of the scale and complexity of systemd. However, good programmers recognize the difficulty of writing bug-free software and understand the importance of designing software in a way that minimizes the likelihood of bugs or at least reduces their impact. The systemd developers understand none of this, opting to cram an enormous amount of unnecessary complexity into PID 1, which runs as root and is written in a memory-unsafe language.

Some degree of complexity is to be expected, as systemd provides a number of useful and compelling features (although they did not invent them; they were just the first to aggressively market them). Whether or not systemd has made the right trade-off between features and complexity is a matter of debate. What is not debatable is that systemd's complexity does not belong in PID 1. As Rich Felker explained, the only job of PID 1 is to execute the real init system and reap zombies. Furthermore, the real init system, even when running as a non-PID 1 process, should be structured in a modular way such that a failure in one of the riskier components does not bring down the more critical components. For instance, a failure in the daemon management code should not prevent the system from being cleanly rebooted.

In particular, any code that accepts messages from untrustworthy sources like systemd-notify should run in a dedicated process as a unprivileged user. The unprivileged process parses and validates messages before passing them along to the privileged process. This is called privilege separation and has been a best practice in security-aware software for over a decade. Systemd, by contrast, does text parsing on messages from untrusted sources, in C, running as root in PID 1. If you think systemd doesn't need privilege separation because it only parses messages from local users, keep in mind that in the Internet era, local attacks tend to acquire remote vectors. Consider Shellshock, or the presentation at this year's systemd conference which is titled "Talking to systemd from a Web Browser."

Systemd's "we don't make mistakes" attitude towards security can be seen in other places, such as this code from the main() function of PID 1:

/* Disable the umask logic */

if (getpid() == 1)

umask(0);

Setting a umask of 0 means that, by default, any file created by systemd will be world-readable and -writable. Systemd defines a macro called RUN_WITH_UMASK which is used to temporarily set a more restrictive umask when systemd needs to create a file with different permissions. This is backwards. The default umask should be restrictive, so forgetting to change the umask when creating a file would result in a file that obviously doesn't work. This is called fail-safe design. Instead systemd is fail-open, so forgetting to change the umask (which has already happened twice) creates a file that works but is a potential security vulnerability.

The Linux ecosystem has fallen behind other operating systems in writing secure and robust software. While Microsoft was hardening Windows and Apple was developing iOS, open source software became complacent. However, I see improvement on the horizon. Heartbleed and Shellshock were wake-up calls that have led to increased scrutiny of open source software. Go and Rust are compelling, safe languages for writing the type of systems software that has traditionally been written in C. Systemd is dangerous not only because it is introducing hundreds of thousands of lines of complex C code without any regard to longstanding security practices like privilege separation or fail-safe design, but because it is setting itself up to be irreplaceable. Systemd is far more than an init system: it is becoming a secondary operating system kernel, providing a log server, a device manager, a container manager, a login manager, a DHCP client, a DNS resolver, and an NTP client. These services are largely interdependent and provide non-standard interfaces for other applications to use. This makes any one component of systemd hard to replace, which will prevent more secure alternatives from gaining adoption in the future.

Consider systemd's DNS resolver. DNS is a complicated, security-sensitive protocol. In August 2014, Lennart Poettering declared that "systemd-resolved is now a pretty complete caching DNS and LLMNR stub resolver." In reality, systemd-resolved failed to implement any of the documented best practices to protect against DNS cache poisoning. It was vulnerable to Dan Kaminsky's cache poisoning attack which was fixed in every other DNS server during a massive coordinated response in 2008 (and which had been fixed in djbdns in 1999). Although systemd doesn't force you to use systemd-resolved, it exposes a non-standard interface over DBUS which they encourage applications to use instead of the standard DNS protocol over port 53. If applications follow this recommendation, it will become impossible to replace systemd-resolved with a more secure DNS resolver, unless that DNS resolver opts to emulate systemd's non-standard DBUS API.

It is not too late to stop this. Although almost every Linux distribution now uses systemd for their init system, init was a soft target for systemd because the systems they replaced were so bad. That's not true for the other services which systemd is trying to replace such as network management, DNS, and NTP. Systemd offers very few compelling features over existing implementations, but does carry a large amount of risk. If you're a system administrator, resist the replacement of existing services and hold out for replacements that are more secure. If you're an application developer, do not use systemd's non-standard interfaces. There will be better alternatives in the future that are more secure than what we have now. But adopting them will only be possible if systemd has not destroyed the modularity and standards-compliance that make innovation possible.

2

u/cjcox4 Mar 22 '22
sudo grub-reboot menu-entry-num-for-windows

2

u/agentrnge Mar 22 '22 edited Mar 22 '22

chown root:someusergroup -R from /

edit: i guess its not really a candidate for most dangerous. But bad in a way that might seem OK at first, not critical, but generally hose up a lot of things that gradually cause all sorts of things to go south.

1

u/[deleted] Mar 22 '22

One of the most dangerous would be to use !<number>, but you use the wrong number, and don't realize before hitting enter.

What would happen, could be quite bad, depending on your luck

/edit: should maybe add that this for bash, not sure how history and ! works in other shells

1

u/zoharel Mar 23 '22

Well, your desire to corrupt everything is rather at odds with your desire to crash. It's difficult to do both at once.

1

u/Purple-Turnip-2879 Mar 23 '22

that's why the dd configurations I use most are in a script, so I don't mistype anything

yeah, dd can be dangerous

that rm thing I think has been disabled but dd can still destroy stuff

here's another...

was changing permissions using find exec & forgot to exclude directories & hidden files

in went the live cd so I could undo the damage, changing directories & hidden stuff back to executable

find can be a bit dangerous, it has a delete option too

🤪🔥💥💀

1

u/[deleted] Mar 23 '22

:(){:|:&};:

1

u/wikerone Mar 23 '22

Lookup the command to create a new GPT or MBR partition table.

This will do it too: sudo dd if=/dev/zero of=/dev/sdX bs=4096 status=progress

And let's not underestimate all those well-educated hackers..... in Bangladesh.

The bottom line though is that everyone should have a comprehensive backup strategy to recover when US(A) stupid humans make stupid mistakes.

1

u/[deleted] Mar 22 '22

sudo apt remove systemd busybox

7

u/[deleted] Mar 22 '22

Situational. Not all distros use busybox. Not all distros use systemd. Not all distros use apt. While we're at it, not all systems will have sudo enabled.

But I get what you mean. Your OS needs an init system and coreutils.

1

u/LeiterHaus Mar 22 '22

Don't know why you're getting downvoted. I have systemd, but don't have apt. After looking up busybox, don't have that either.

0

u/[deleted] Mar 22 '22

Im generalizing

1

u/BandicootBroad Mar 22 '22

The exit command should give you that connection lost message reliably.
I kid, I kid. I agree with the others who say to use dd improperly. There's a reason I've heard it derisively called "disk destroyer".

1

u/Max-Normal-88 Mar 22 '22

dd

1

u/michaelpaoli Mar 22 '22

sh

cat

...

nothin' much special about dd itself.

1

u/alexforencich Mar 22 '22

There is a command to trigger an instant reboot via sysreq. As in it basically does the same thing as mashing the reset switch; no cleanup of any kind is done. This does has its uses though - I have used it to trigger reboots after screw-ups in driver development, where doing a normal reboot would hang.

# echo 1 > /proc/sys/kernel/sysrq
# echo b > /proc/sysrq-trigger

1

u/vrikancs Mar 22 '22

Forkbomb anyone?

1

u/Cephalon_Zeash Mar 22 '22

I'm absolutely terrified of any use of dd. That one has potential to absolutely demolish systems.

1

u/h4ckt1c Mar 22 '22

alias cd='rm -rf

1

u/[deleted] Mar 22 '22

I feel like downloading and run a script that you don't know is more dangerous, cuz the worst you can do is brick your system, even the BIOS, but say if you let some mf get access to your bank account....

1

u/flatfishmonkey Mar 22 '22

Putput dead yet?

0

u/josejuanrguez Mar 22 '22

Hahahahaha.

1

u/_SuperStraight Mar 22 '22

You can try removing your UEFI folder.

1

u/AsleepThought Mar 22 '22

a lot of people say dd and rm, but the really dangerous ones are mv and cp. Because without aliases to cp -i and mv -i on your system, its way too easy to clobber files with cp and mv by accident. This is a lot more dangerous than dd and rm because everyone already knows that those are dangerous. On the other hand, mv and cp are used without discretion all the time so its a lot more surprising when they screw up.

I knew a sys admin that tried to help a user move their files on the new server and accidently ran something like find . -type f -exec mv {} dir \;. Take a guess at what happened...

0

u/raven2cz Mar 22 '22

This is just one example command from many. You have dozens of options how to destroy your system.

I have comparison for young users. What does Uncle Ben say to Spider-Man?

"With great power comes great responsibility"

If you use sudo and press enter, you have great power which brings full responsibility, you have to be 100% sure what you are doing. And mainly paste some things from internet.

In addition posix allows you to swap arguments and destination folder. Your example is not secure, if you want to delete something, better is used this

sudo rm /ReqDir -rf because if you accidentally press enter before you insert correct path you still doesn't type -rf, and nothing happens!

0

u/R3D3MPT10N Mar 22 '22

Not really answering your question, apologies, but this is a pretty cool and relevant blog post:
http://lambdaops.com/rm-rf-remains/

To answer your question, I guess:

dd if=/dev/zero of=/dev/sda

If it run long enough, you might not be able to recover from that I guess.

0

u/DonkeyTron42 Mar 22 '22

I used to have a co-worker that would always type "rm -rf" even if he was deleting a single file.

1

u/goldscurvy Mar 22 '22

I do this. It makes the files even more deleted

0

u/SadisticTeddy Mar 22 '22

I've seen people do some dumb shit with internet facing boxes around ssh etc just to make connectivity more convenient for them - anything that allows for promiscuous connectivity is generally a bad thing, especially if the box isn't intended as a boundary device.

'its just a test environment' is a popular excuse from a few devs I've known who want to rapid prototype something and want an easier life with all network security disabled.

0

u/Artemis-4rrow Mar 22 '22

dd can overwrite ur entire disk

meaning that all the data is gone and can't be recovered even via recovery software

0

u/goldscurvy Mar 22 '22

If you want it to say connection lost and ur in a ssh session can't you just hangup?

FYI the actual most dangerous command isn't native and is platform dependent but setting nsfc to 0 and then using radeontop to increase your clock speed will literally fry ur computer. That seems pretty dangerous to me.

0

u/smjsmok Mar 22 '22

sudo rm -rf /* ; shutdown now

:))

(edit: this is just to showcase a dangerous command, DO NOT ENTER THIS INTO YOUR TERMINAL, it will erase your system!)

0

u/cchoe1 Mar 22 '22

it would be the command that gets run to order nuclear missiles to launch

$ man nuke
----
nuke(1)
NAME
        nuke - Simple tool for ordering nuclear bombardment
SYNOPSIS
        nuke [-m log message]  [-v verbose]  
             [-d dry run]  [-f force] 
             *missile ID* *target coordinates*

0

u/str8toking Mar 22 '22

In scripting, not closing out loops with fi or done. You can send yourself emails infinitely with no way of killing your current session. Also attract the attention of InfoSec…

0

u/Foreign_Jackfruit_70 Mar 22 '22

You need to add --no-preserve-root to remove everything.

0

u/_Fuzen_ Mar 22 '22

sudo do-release-upgrade had my vote. 100% failure rate here

0

u/[deleted] Mar 22 '22

just make poweroff on prod ;)

-1

u/WhooUGreay Mar 22 '22

I don't know exact commands but in some computers/laptops you can turn fans of. Then run for i in {0..10}; do dd if=/dev/zero of=/dev/null;done this heats up you CPU and (I think) can do physical harm to your computer. And for dd command you can set output file to something real so it damages your storage device also.

If someone knows exact command for that or knows other ways to damage physical hardware please let me know

1

u/michaelpaoli Mar 22 '22

No, maxing out the CPU(s)/core(s) won't cause hardware problems unless you've already got hardware issues. Generally it should be able to reasonably cool that or keep that cool ... heat sink(s), fan(s), and failing that, throttle down the CPU if/as needed.

1

u/WhooUGreay Mar 22 '22

Okay I am professional at hardware. But could you force the CPU to max performance even if heat is above safe temperature. Or would it be limited by CPU software?

1

u/michaelpaoli Mar 22 '22

Modern CPUs self limit if the temperature gets too high - they get too hot, they slow down. Not software, the CPU itself in its hardware or possibly firmware.

1

u/WhooUGreay Mar 22 '22

Ah okay then it is hard to damage those. But modern ssd's can you destroy those by writing a lot data to those?

0

u/[deleted] Mar 22 '22

[deleted]

29

u/Sol33t303 Mar 22 '22 edited Mar 22 '22

I don't think that'd actually work, you'd actually want /dev/zero. /dev/null explicitly does not output anything, try and cat it and you'll see. Whereas /dev/zero outputs NULL characters, aka zeroes.

Also makes me wonder why theres no /dev/one.

5

u/Down200 Mar 22 '22

Probably just that there’s not much that a /dev/one could do that a /dev/zero or /dev/urandom couldn’t accomplish

3

u/[deleted] Mar 22 '22

[removed] — view removed comment

0

u/[deleted] Mar 22 '22

[deleted]

2

u/[deleted] Mar 22 '22

alias no="cat /dev/zero"

0

u/Lucarai Mar 22 '22

This just writes over sdx indefinitely right?

2

u/ArsenM6331 Mar 22 '22

With zeroes until it reaches the end of /dev/sdx