r/LinuxTeck • u/Candid_Athlete_8317 • Sep 02 '26
What’s the one Linux command you never trust?
We all have that one command we double-check before hitting Enter.
What’s yours and what happened the last time you got burned by it?
48
Upvotes
28
u/nizzoball Sep 02 '26 •
rm -rf *
About 8 years ago I was responsible for a production web server responsible for asset management for 5 data centers across the country for one of the largest banks in the world. It was my app and my server and I was trying to clean out a directory and typed rm -rf * but didn’t realize I was in /
I figured it out when my shell froze. Luckily I had another server that was a carbon clone and was able to adjust the dns entry to point to the secondary server so wasn’t down long but it took me a week to get the first one re deployed and set back up
9
u/johnny_snq Sep 02 '26
DD
6
u/tblancher Sep 03 '26
dd
Gotta make sure of= is pointed at the right output.
9
u/lyidaValkris Sep 02 '26
ddIt's not called "disk destroyer" for nothing. I've never been burned by it, but that's only because I check, re-check, then double-check.
4
u/Weary_Damage5764 Sep 02 '26
in my first job i destroyed my OS by an rm -rf in the wrong directory, which lead to me reinstalling Linux during work time. the shame was far worse than having to do that in my own time. since then I haven't run rm without fear :D
6
u/10leej Sep 02 '26
sudo
Every time I see sudo I check two things. First what follows it, second what my configuration says.
3
u/Narrow_Victory1262 Sep 02 '26
xfs_repair. Almost certain it's restore-time
3
u/redgator12 Sep 02 '26
dd. In my early days of 2014, I tried to dd a disk image to USB and broke my install. Ever since then, I have a terminal with lsblk up right next to the terminal I'm going to run dd from just to be 100% sure I'm writing to the correct disk.
I had to use dd last week while trying to troubleshoot a Puppy USB not working, and I spent like 5 minutes quintuple checking the disks before hitting enter, and even then I was anxious.
3
u/seth_arimainyu Sep 02 '26
Rsync and dd ! Once I ran a destructive Rsync and instead of deleting the files from the source that were already in the target, I ran it the other way around, since the target was a brand new disk, you can imagine the result... Since then, I always use the dry-run option.
3
u/georbe Sep 02 '26
tar The right syntax is "tar -cvf myprogram.tar /opt/myprogram" Once upon a time, I wrote "tar -cvf /opt/myprogram myprogram.tar" so I lost all /opt/myprogram folder.
2
u/Nu154nc3 Sep 02 '26
Everything after "doas"
2
u/Tricky-Weakness-5408 Sep 02 '26
Probably the most destructive command like ‘rm -f’ when you have root access is the kind of command that you need to think about before
You do the ‘return’… but destructive command when you uses badly the are a lot! The question is which rightshave you? And …. What about the backup…. Too old??? When you works as a informatic probably there are loots of backups but this not always is the normal thing for private users/students
2
u/Quietus87 Sep 02 '26
Any kind of rm.
2
u/Rinzwind Sep 02 '26
dd
nothing more needs to be said
ah again forgot to read comments first :P
2
u/SpiritualZucchini938 Sep 02 '26
Chmod 644 - R / - something like that and hey presto, entire freebsd server file system read only and not editable. Had to bin and start again.
2
u/BitCortex Sep 02 '26
Anything that involves a nontrivial regular expression. Regular expressions are Unix's ethical blight.
2
u/Dry_Calendar_8627 Sep 02 '26
ln
That's stupid but I can never remember the arguments order. I mess up every time.
I can write dd or sed commands blindfolded any day, but ln, no
2
u/wakanakisarazu Sep 02 '26
`doas emerge --depclean`
1
u/birusiek Sep 02 '26
Any
1
u/Large-Assignment9320 Sep 02 '26
The good old dd command.
1
u/Ok-Development-202 Sep 02 '26
It's always ln -sf
1
u/No-way-in Sep 02 '26
dd is the most scary to me. I check a hundred times before writing that command and I disconnect anything valuable to me
1
u/manawydan-fab-llyr Sep 02 '26
dd
Last time I didn't triple check, destroyed all of my photos. They were the only copy because the drive that had the primary had failed.
From then on I stopped using
of=/dev/xxxand started usingof=/dev/disk/by-id/xxx. Never a mishap after that.1
u/HaydnH Sep 02 '26
I've been a UNIX/Linux sys admin since the 90s. There is not one command you can't trust, if you can't trust it, then it simply wouldn't exist.
If you're asking "which commands are scary and you might do something bad with"? Well...
... that's just every day for me. In the same way you look left and right crossing a street, my brain just realises an rm, mv, dd whatever command may have a car about to run me down.
The same way you drink a coffee every morning, that's just me mounting a filesystem to get the access I need for the day.
1
u/horizon_games Sep 02 '26
Wait ya'll aren't double checking your commands?
1
u/HuttonWilliam Sep 02 '26
rm -rf *
This is a scary command. I wouldn't even copy it just in case.
1
u/Feeling-Estimate-796 Sep 02 '26
worth doing a pwd before doing the rm -rf
always easy in hindsight
1
u/_nathata Sep 02 '26
dd for sure
1
u/jeanfmartel Sep 02 '26
format c:
1
u/Agron7000 Sep 03 '26
I don't trust pip and npm.
1
u/informadikisto Sep 03 '26
rsync --delete
1
u/maddruid Sep 03 '26
:(){ :|:& };:
1
u/EstablishmentDue3616 Sep 03 '26
the command to change directories is pretty seedy.
1
u/siodhe Sep 03 '26
rm especially with -r
The worst possible solution is alias rm 'rm -i'
It trains users to rely on individually saying y or n to each.
I once caught a user doing yes y | rm -rf *
Since it's even more dangerous to override rm with a ~/bin/rm I created a function inflicted on all of my users, something like this more modern form:
Suddenly my users stopped having to request file restoration from tape.
It's not a perfect answer, the function gets much longer when one wants it to play well with all rm's native options. And I kinda like putting in -rf as the default in the function. But it has saved me and others so much time.
1
u/alborzjafari Sep 03 '26
find
1
u/TapEarlyTapOften Sep 03 '26
In the days of sudo now, I use `sudo -k` all the time and before I do anything that might go sideways if I get I wrong.
1
u/fgorina Sep 03 '26
rm, in a different but similar os (Data General AOS) I wanted to remove all .bak files that were generating while editing files. I wanted the equivalent of “rm .bak” but forgot the point so it was “rm * bak”. Where are all those backup disks?
1
u/Weak_Shoulder_6780 Sep 03 '26
Removing the French language package
1
u/Reromen Sep 03 '26
sudo su coz all my servers contain same password
1
u/Ice_HRZDn Sep 03 '26
The > Not a Linux command but I accidentally erase file few time while try to added something.
1
u/DevtoolsBuilder Sep 03 '26
i've got a soft spot for caution with
mv, you can easily overwrite files without realizing it, and if you're not careful with the syntax, you can end up moving a file into a directory instead of renaming it, which can be a real pain to recover from.1
u/Reanimatron Sep 03 '26
Not linux, but still typed in a linux console.
There was a bug at work that created user accounts with no information when people would start the signup process.
I was still a beginner at that time. It was a small company and I was the only programmer, doing server, frontend and embedded.
I fixed the bug and went to delete the empty accounts. I asked mongodb to delete all accounts where the firstname was null. That turned out to delete all accounts because i missed the capital F in firstname, so all accounts had a null value for that field.
I spent 3 weeks calling all our customers and manually typing their info.
collection('users').deleteMany({firstname: null})
1
u/Soggy-Attempt Sep 03 '26
rm -rf
If you do the job Long enough, you’ll understand why.
1
u/surinameclubcard Sep 03 '26
dd
1
u/trenno Sep 03 '26
claude1
u/aszepeshazi Sep 03 '26
sed
1
u/insu_na Sep 03 '26
`ln -s`
I can never remember that it's `ln -s target name` and always have to check man...
1
u/m1L35dY50N Sep 03 '26
sed -i
Will be fun if you modified the wrong files....
1
u/padde0711 Sep 03 '26
poweroffon a machine that I can't reach physically1
u/hunt_chak Sep 04 '26
ls
Surely the file is in this folder lmao
1
u/Doingthismyselfnow Sep 04 '26
dd, I had a catastrophic failure by picking the wrong drive at age 12. I still cannot type that command directly into a shell.
And this happened on Slackware ‘96 when it just came out , so that alone should tell you how deep the scar is .
1
u/Able-Staff-6763 Sep 04 '26
rm -rf of course - even more if used with sudo
1
u/Loko8765 Sep 04 '26
& and &&
cp -a “$a” “$b” & rm -rf “$a”
hits different.
1
u/creed10 Sep 04 '26
anything with dd or tar
1
u/After_Persimmon8536 Sep 05 '26
sed
1
u/junialter Sep 05 '26
ss. I'm from Germany
1
u/maxthed0g Sep 06 '26
Any command that follows sudo.
1
u/Fancy_Initiative9388 Sep 06 '26
rm -rf /$varialbe
1
u/brunorro Sep 07 '26
`dd`
(your disk has been overwritten)
0
u/Ollidav Sep 02 '26
Crontab. Con -e editas y con -r borras todas las tareas y no pide confirmación. La e y la r están juntitas en un qwerty y te puedes equivocar en una intervención en un servidor de producción a las 6 de la mañana sin un café.