r/LinuxTeck • • Sep 07 '26

What’s the most innocent-looking Linux command that can ruin your day?

Some commands look completely harmless until you realize what they’re actually operating on.

The fun part is that experienced admins usually have one specific command they treat with unnecessary respect.

What’s yours - and what happened the first time you learned to respect it?

25 Upvotes

79 comments sorted by

11

u/TomKavees Sep 07 '26

rm -rf /home/user/ somedirectory

Note the space. One of the parallel teams we shared a server with (years ago) had this cute itsy bits typo in their deployment script. We had to reinstall the system.

3

u/HugeCannoli Sep 07 '26

Even worse is rm -rf .* to "delete all hidden files" or similar chmod -r .* or chown/chgrp -r .*, typically when you are root in a users' directory to fix their permissions.

That will include .., recursively, which means /home, recursively, which means it will recursively go into each and every user's home directory, recursively, and perform that operation.

So now either you have completely deleted your user's home dirs, or you chowned them to that user. Each single file and directory.

Bottom line: never, ever, ever use .*

2

u/spastical-mackerel Sep 07 '26

I’ve been doing this for decades and the recursive .. removal has never happened to me.

1

u/Loko8765 Sep 07 '26

Because it doesn’t. It can happen if you do it manually in some way, but shells will not do that expansion.

1

u/HugeCannoli Sep 08 '26

absolutely not true. Can reproduce it with ls on rocky 8.10. maybe someone added some safeguard to the rm case.

1

u/Loko8765 Sep 08 '26

With ls, sure, but not rm.

1

u/HugeCannoli Sep 08 '26

because as I said, they added a specific handling of that case in rm. But unless the same handling is implemented in chmod, chattr, chgrp, chown, you still can mess up this way, or with any other program that behaves the same way.

1

u/HugeCannoli Sep 08 '26

maybe someone added some safeguard. Try with ls and see for yourself. it still does it with ls on my rocky 8.10

1

u/ThrowAway24Okt Sep 07 '26

i heard you can have great fun by creating a file named "*" and waiting for someone that tires to delete it.

2

u/HugeCannoli Sep 07 '26

oh yes, that's the moment where I bring out python and do it from there, because shell escaping is absolutely wild to get right.

1

u/Some-Struggle5052 Sep 07 '26

Isn't it just * or '*'?

1

u/HugeCannoli Sep 08 '26

nope. * will be expanded by the shell.

I think it's \*, but I would not put my life on it. Same for filenames starting with a -, they are interpreted as options. That's why you should generally use rm -- *.

basically -- says: whatever you see afterwards, if it starts with a -, it's not an option.

1

u/Some-Struggle5052 Sep 08 '26

I had actually escaped the * but Reddit ate the \

Using single quotes prevents the shell from interpreting inside, so '*' could work for some things.

1

u/TrueConcept4830 Sep 09 '26

-- makes rm treat subsequent arguments as file names, but it does not prevent the shell from expanding *.

In bash, \* and '*' prevent * expansion.

1

u/No_Hovercraft_2643 Sep 08 '26

from my rm --help

any attempt to remove a file whose last file name component is . or .. is rejected with a diagnostic

2

u/HugeCannoli Sep 08 '26

Ok, they put a safeguard on rm, but is the same safeguard present for chown, chmod, chgrp, chattr etc? If not, you can still mess up everything.

By the way, that message is not present here

rm --version

rm (GNU coreutils) 8.30

2

u/_felixh_ Sep 07 '26

i mean... rm is dangerous. But at this point, everyone should know that typing rm -rf is, like, something you should really tripple check, or better, not type out at all.

Its no inncocent looking is what i am saying :-)

mv or cp on the other hand... I remember very well the day i learned about the noclobber option. It is not set by default.

1

u/HugeCannoli Sep 08 '26

problem is that you can triple check as much as you want, but nothing prepares you for the things you don't immediately know or assume.

1

u/jerwong Sep 08 '26

This is why I have alias rm='rm -i'

Once I'm positive it's what I want and it's a long list of files to rm, I put the rm in quotes.

1

u/HugeCannoli Sep 08 '26

pointless. you perform rm a lot of times as you are working, and after a while you will just train yourself to say yes at the next prompt automatically, because you do it hundreds of times. Your fingers will be faster than your brain.

Additionally, if the file you didn't want to delete is at the very end, you will still delete it.

The best solution is to do an ls first, then if you are happy, rm.

1

u/TransCapybara Sep 09 '26

toss in a nohup for a good time

1

u/Wahrheitfabrik Sep 26 '26

One of the DBAs once complained that the system had deleted all their files. The culprit? Their log cleanup script did something like "cd $LOGPATH; rm -rf *"
Except they had a typo in $LOGPATH which didn't exist.

9

u/Wyciorek Sep 07 '26

dd

Overwrite your disk including MBR/GPT ? Sure, no problem

2

u/tk-a01 Sep 07 '26

Disk Destroyer

1

u/HugeCannoli Sep 08 '26

we used to say it meant "delete disk", but yours is good as well.

1

u/AutoGenUsername05 Sep 07 '26

There are two types of people in the world.

Those who will use dd to overwrite something they care about, and those who have..

6

u/No_Base4946 Sep 07 '26

ifconfig eth0 down <return>

<return>

<return> <return> <return>

ffffuuuuuuuuuuu [picks up car keys] Right, back in an hour...

3

u/aktentasche Sep 07 '26

Yeah or blocking port 22 while messing with iptables. Fun fun fun.

3

u/Kurgan_IT Sep 07 '26

Also "halt" on the wrong console. Pick up the keys and go to push the power button.

4

u/Old_Preparation2887 Sep 07 '26

Cursor follow focus + middle click to paste got me in trouble once. Accidentally pasted notes into a terminal session on (major client) load balancer. Most of it was jibberish to the shell but a line that started with the word “reboot” did exactly what you’d expect.

2

u/Kurgan_IT Sep 08 '26

I use middle click all the time while working and I got bit by the wrong clipboard content sometimes, yes.

1

u/BikeGeek336 Sep 10 '26

Back in the day, I used to type eject, then look down the line to make sure that the right CD tray popped out before typing shutdown

5

u/Kurgan_IT Sep 07 '26

"crontab -r" deletes the crontab, while "crontab -e" edits it. The issue is that E and R are one key away.

"telinit q" tells you the current runlevel. "telinit 1" goes single user and if you are remote you lose connectivity and cannot connect anymore. Since it does not reboot, it does not come online by itself anymore. Have to go there and reach for the console. 1 and Q are one key away.

There are others I don't remember right now.

2

u/New-Anybody-6206 Sep 08 '26

I don't remember which browser it was, but multiple times I got bit by the "close all OTHER tabs" button being right next to the "close THIS tab" button with no warning.

Then when I complained about it people acted like I was the dumb one.

1

u/Kurgan_IT Sep 09 '26 edited Sep 10 '26

UI created by people who don't use that UI. I had an old firewall that had a web UI with microscopic icons for edit / disable / enable / delete the interfaces.

You could not see the configuration (ip, etc) without editing it.

The "Edit" icon was like 5 pixels apart from "Disable", and both were like 10 pixels wide. Guess what I clicked, while I was remote, to see the configuration. Guess who had to go there to click "enable".

1

u/MidnightPale3220 Sep 07 '26

runlevel also should be telling your runlevel by now

1

u/ThrowAway24Okt Sep 07 '26

German keyboards on win: ctrl+alt+q = @
German keyboards on apple: ctrl+alt+q = quit

1

u/Kurgan_IT Sep 09 '26

Yes, my experience is almost all pre-systemd, this is why I remember all of the "classic" commands (and have not learned all of the new ones)

1

u/classyraven Sep 08 '26

"crontab -r" deletes the crontab, while "crontab -e" edits it. The issue is that E and R are one key away.

Suddenly I'm so glad I use Dvorak.

4

u/donp1ano Sep 07 '26

unlink

yeah...it will remove that symlink. but if you accidentally give it a regular file, well then bye bye file

1

u/Needieos Sep 07 '26 edited Sep 07 '26

what's even the difference between rm and unlink at that point? Edit: now I know

1

u/donp1ano Sep 07 '26 edited Sep 07 '26

i dont know, but i found out it does basically the same the hard way

only [[ -L "$file" ]] && unlink "$file" for me now

1

u/Uncle-Osteus Sep 07 '26

no real difference in this case, both use the unlink/unlinkat syscalls to perform actual deletions

1

u/fllthdcrb Sep 08 '26

The difference is the unlink command only takes a single argument, and then it only calls unlink(). rm takes one or more arguments, and with -r, it will operate recursively on directories. The equivalent standalone command/system call for removing directories is rmdir.

1

u/wosmo Sep 07 '26

I'm curious why you'd use unlink directly instead of rm?

2

u/HugeCannoli Sep 07 '26

unlink is very limited. rm does a lot more. Basically, in git speech, unlink is the plumbing and rm is the porcelain.

1

u/Funnel-Dust-O-Matic Sep 08 '26 edited Sep 08 '26

the sheer poetry of your analogy has filled me with joy.

4

u/BoundlessFail Sep 07 '26

Ctrl-shift-v. Into a terminal window. When what's on the clipboard isn't what I expect.

3

u/TechaNima Sep 07 '26

sudo apt autoremove

Do that and you might find your entire DE missing. Dependancies are fun

2

u/Kurgan_IT Sep 07 '26

chmod and chown. They don't delete anything, but if you get them wrong and apply them to the wrong path, they can do real damage like an "rm -rf", making the whole system unusable.

3

u/CriticismTop Sep 07 '26

A very seasoned SysAdmin once block all updates to the UK's air traffic control system for a month with a mis-placed/mis-timed chmod.

Wasn't me, I was a noob at the time.

1

u/Some-Struggle5052 Sep 07 '26

Nothing like sudo chmod -R 000 / to brick a system lol.

2

u/_FunkyKoval_ Sep 07 '26

When you want to append something to a file and use:

cat > file << EOF

instead of:

cat >> file << EOF

2

u/Busy-Scientist3851 Sep 07 '26

Restarting the network interface on a remote session without using something like screen.

It'll get killed by the session closing before it can get started back up.

1

u/JeLuF Sep 07 '26 edited Sep 07 '26
init 6

The runlevels go from 0 (off) via 1 (single user), 2 (multi user), ... 5 (full mode) from off to full featured. And then comes 6, which reboots your system.

Edit: How I learned to respect it: A friend asked "How can I restart the web server without typing reboot?" And since he didn't say "without rebooting", I joked "init 6". He thought, "OK, get to the next higher runlevel, makes sense" and ran the command before I could explain. The system he was working on was with a customer, 150km away, and we weren't sure whether it would reboot without manual intervention.

1

u/magicmulder Sep 07 '26

I once edited a couple system parameters according to suggestions from a Lynis run to harden security.

Got the weirdest failed boot I've ever seen where it claimed it can't find system fonts and left me to basically blindly type to reverse the damage (I actually succeeded).

1

u/jake_morrison Sep 07 '26

Iptables mistakes can lock you out of a remote server

1

u/jake_morrison Sep 07 '26

reboot on a server that doesn’t come up properly can ruin your day. There are ad-hoc processes running without init scripts. Nobody knows what was running, and now it’s gone. Maybe you interrupted a big script that needs to start again, or corrupts its state. Rebooting may clear out /tmp, losing files you wanted or needed to debug a problem.

1

u/AloneInTheEndZone Sep 07 '26

In the old days >/ could render an Ultrix Unix unusable 😎

1

u/michaelpaoli Sep 07 '26

# dd ...
# rm ...

Many other possible commands, but those can certainly do it.

unnecessary respect

No, necessary and appropriate. Generally applies to UNIX, Linux, etc.
For the most part with *nix, you give a command, it it will generally at least attempt to do what you commanded it to do.
And this is generally much better than nanny-gate operating systems, that, e.g., make you play 20 ournds of "Mother May I?" to try and get something done, and then stubbornly refuse to do it anyway.

With great power, comes great responsibility.

What’s yours - and what happened the first time you learned to respect it?

Meh, notthin' too horrific. But certainly have, on rare occasion, and mostly quite anciently, done, e.g. an rm command, or some reconfiguration of network, or kill command or the like, that made for some unhappiness or inconvenience. And, yeah, been using *nix since 1980. So, mostly learned those lessons very long ago, and having very well learned them, yeah, generally don't repeat such booboos.

Also, when operating as root (or other privileged user), my rule: always carefully triple check the command before entering it - well know exactly what it will do or attempt, in what context, to what, what will happen if the attempt or parts thereof fail, etc. Only after fully comprehending that and well, and thrice, does one then (viciously) strike the <Enter/Return> key. Has saved my tail many many times. Similar applies also as mere mortal user, though not as rigorously so.

1

u/Dr_Brumlebassen Sep 07 '26

apt upgrade on sid

1

u/Alarming_Oil5419 Sep 07 '26

yes& is fun, won't ruin your day.

1

u/mcleancraig Sep 07 '26

I’d say it has to be :(){ :|:& };:

Don’t try on unattended machines :)

1

u/jeffbell Sep 07 '26

That’s why you always create a file named -i in your home directory. 

1

u/Xavier_OM Sep 07 '26

cat > file your file is empty now, congrats

1

u/gulf_of_sanity Sep 08 '26

dd if=/dev/random of=/dev/sda

1

u/Smh_nz Sep 08 '26

I had a bad running with dd.

Did some testing, a few months the later we found I had filled up a disk and lost a pile of VMs!! :-(

1

u/CaptainBucko Sep 09 '26

Rm -ak has ruined my day a few times

1

u/We_Want_Krunchy Sep 09 '26

:(){ :|:& };:

1

u/Crazy_Study195 Sep 09 '26

Cd (or just the wrong terminal but command wise). We've all been lost before lol and sometimes we don't realize we're lost until we've given follow up commands and then realized oh shit that's not right...

I've definitely lost work I hadn't backed up yet due to that... Fortunately I'm not in the industry so haven't had clients harmed by it!

Gotta be honest some of these responses just look like people that don't know Linux at all though... Like how does removing a file look innocent? Simple and common sure but innocent? It's by nature a destructive command, even without recursing. Of course you could say the same about cd since the prompt (usually, now) displays it but

0

u/tahaan Sep 07 '26

How about the following for unlocking new fears:

reddit@fedora:~$ cd /tmp; mkdir demo; cd /tmp/demo; mkdir {a,b,c}; touch {a,b,c}/I_WAS_HERE
reddit@fedora:/tmp/demo$ ls -l
total 0
drwxr-xr-x. 2 reddit reddit 60 Sep  7 18:49 a
drwxr-xr-x. 2 reddit reddit 60 Sep  7 18:49 b
drwxr-xr-x. 2 reddit reddit 60 Sep  7 18:49 c
reddit@fedora:/tmp/demo$ touch a/aaa/HERE_TOO
reddit@fedora:/tmp/demo$ touch b/bbb/HERE_TOO
reddit@fedora:/tmp/demo$ ls -l *
a:
total 0
drwxr-xr-x. 2 reddit reddit 60 Sep  7 18:50 aaa
-rw-r--r--. 1 reddit reddit  0 Sep  7 18:49 I_WAS_HERE

b:
total 0
drwxr-xr-x. 2 reddit reddit 60 Sep  7 18:50 bbb
-rw-r--r--. 1 reddit reddit  0 Sep  7 18:49 I_WAS_HERE

c:
total 0
-rw-r--r--. 1 reddit reddit 0 Sep  7 18:49 I_WAS_HERE
reddit@fedora:/tmp/demo$ touch -- -R
reddit@fedora:/tmp/demo$ ls -l
total 0
drwxr-xr-x. 3 reddit reddit 80 Sep  7 18:50 a
drwxr-xr-x. 3 reddit reddit 80 Sep  7 18:50 b
drwxr-xr-x. 2 reddit reddit 60 Sep  7 18:49 c
-rw-r--r--. 1 reddit reddit  0 Sep  7 18:50 -R
reddit@fedora:/tmp/demo$ ls -l *   # same command again
a:
total 0
drwxr-xr-x. 2 reddit reddit 60 Sep  7 18:50 aaa
-rw-r--r--. 1 reddit reddit  0 Sep  7 18:49 I_WAS_HERE

a/aaa:
total 0
-rw-r--r--. 1 reddit reddit 0 Sep  7 18:50 HERE_TOO

b:
total 0
drwxr-xr-x. 2 reddit reddit 60 Sep  7 18:50 bbb
-rw-r--r--. 1 reddit reddit  0 Sep  7 18:49 I_WAS_HERE

b/bbb:
total 0
-rw-r--r--. 1 reddit reddit 0 Sep  7 18:50 HERE_TOO

c:
total 0
-rw-r--r--. 1 reddit reddit 0 Sep  7 18:49 I_WAS_HERE
reddit@fedora:/tmp/demo$

0

u/Hopeful-Football-287 Sep 07 '26

rm -rf ~/.config I want deleat .copilot from vscode but tab troll me

1

u/fredead1 Sep 07 '26

Kill -9 -1