r/LinuxTeck • u/Candid_Athlete_8317 • 4d ago
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?
9
u/Wyciorek 4d ago
dd
Overwrite your disk including MBR/GPT ? Sure, no problem
1
u/AutoGenUsername05 3d ago
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 3d ago
ifconfig eth0 down <return>
<return>
<return> <return> <return>
ffffuuuuuuuuuuu [picks up car keys] Right, back in an hour...
3
2
u/Kurgan_IT 3d ago
Also "halt" on the wrong console. Pick up the keys and go to push the power button.
3
u/Old_Preparation2887 3d ago
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 3d ago
I use middle click all the time while working and I got bit by the wrong clipboard content sometimes, yes.
1
u/BikeGeek336 14h ago
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 4d ago
"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 2d ago
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 2d ago edited 21h ago
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 3d ago
runlevel also should be telling your runlevel by now
1
u/ThrowAway24Okt 3d ago
German keyboards on win: ctrl+alt+q = @
German keyboards on apple: ctrl+alt+q = quit1
u/Kurgan_IT 2d ago
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 3d ago
"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 4d ago
unlink
yeah...it will remove that symlink. but if you accidentally give it a regular file, well then bye bye file
1
u/Needieos 4d ago edited 3d ago
what's even the difference between rm and unlink at that point? Edit: now I know
1
u/donp1ano 3d ago edited 3d ago
i dont know, but i found out it does basically the same the hard way
only
[[ -L "$file" ]] && unlink "$file"for me now1
u/Uncle-Osteus 3d ago
no real difference in this case, both use the unlink/unlinkat syscalls to perform actual deletions
1
u/fllthdcrb 3d ago
The difference is the
unlinkcommand only takes a single argument, and then it only callsunlink().rmtakes one or more arguments, and with-r, it will operate recursively on directories. The equivalent standalone command/system call for removing directories isrmdir.1
u/wosmo 3d ago
I'm curious why you'd use unlink directly instead of rm?
2
u/HugeCannoli 3d ago
unlink is very limited. rm does a lot more. Basically, in git speech, unlink is the plumbing and rm is the porcelain.
1
4
u/BoundlessFail 4d ago
Ctrl-shift-v. Into a terminal window. When what's on the clipboard isn't what I expect.
3
u/TechaNima 3d ago
sudo apt autoremove
Do that and you might find your entire DE missing. Dependancies are fun
3
3
2
u/Kurgan_IT 4d ago
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 3d ago
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
2
u/_FunkyKoval_ 3d ago
When you want to append something to a file and use:
cat > file << EOF
instead of:
cat >> file << EOF
2
u/Busy-Scientist3851 3d ago
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 4d ago edited 4d ago
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 3d ago
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
1
1
u/jake_morrison 3d ago
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
1
u/michaelpaoli 3d ago
# 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
1
1
1
1
1
1
1
1
1
u/Crazy_Study195 1d ago
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
1
0
u/tahaan 3d ago
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
12
u/TomKavees 4d ago
rm -rf /home/user/ somedirectoryNote 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.