DEV Community

loading...

Deadly commands and why you should be extra careful with them

Alexandre Plateau
C++ fanatic, video game maker, working on my own scripting language
・2 min read

I'm writing this from my personal experience, because I broke a few systems by misusing some commands...

chown & chgrp

I wanted to save a server which wasn't booting because of a kernel update which went badly. Thus I put a FTP server on the rescue server, mounted the disk of the original server, and tried to retrieve the files. The FTP was launched as user, the partition mounted listed files from root, thus the FTP couldn't retrieve them.

My best (actually, the worst) idea? A chown -R user and a chgrp -R user... This affected the mounted partition but also the original files (which is logical but I didn't think about that).

We were able to downgrade the kernel version in the /boot partition and boot it again afterward but alas, it was unusable because everything was owned by user, even things like sudo or shutdown.

TL;DR When using chown and chgrp, be extra careful.

The usual one, rm

I have a friend who was trying to create a temporary website for an association, named "abc". Well, it wasn't a success thus he tried to delete it. The first time he typed the wrong name, the second time he forgot -r, the third there was an error and he needed to add -f as well.

The plot twist? There was another folder for another website named "pbn", and 3 times he typed "pbn" and not "abc". The wrong website was deleted, unrecoverable.

How it could have been avoided? By having alias rm='rm -i' in the .bash_aliases, asking for a confirmation to delete a file (for every file if -r was added). If you are sure and have reviewed it carefully, you can pipe the rm command with yes which will send "y" to every prompt from rm -i.

Conclusion

I'm hoping that I'll be able to add more commands to this article, without causing too much damage, and I also hope that this will help some of you!

Discussion (3)

Collapse
freezmeinster profile image
Bramandityo Prabowo

Long time ago as Slackware user i accidentally wipe some important configuration file because of redirect command. I used single ">" instead of ">>"

Collapse
yellow1912 profile image
yellow1912

One time I accidentally wiped out my os with rm -rf.

Collapse
superfola profile image
Alexandre Plateau Author

Luckily that never happened to me (yet), but I'm afraid I'll forgot the . when I write rm -rf ./*

Forem Open with the Forem app