I’m working on a some materials for a class wherein I’ll be teaching some young, wide-eyed Windows nerds about Linux and we’re including a section we’re calling “foot guns”. Basically it’s ways you might shoot yourself in the foot while meddling with your newfound Linux powers.
I’ve got the usual forgetting the .
in lines like this:
$ rm -rf ./bin
As well as a bunch of other fun stories like that one time I mounted my Linux home folder into my Windows machine, forgot I did that, then deleted a parent folder.
You know, the war stories.
Tell me yours. I wanna share your mistakes so that they can learn from them.
Fun (?) side note: somehow, my entire ${HOME}/projects
folder has been deleted like… just now, and I have no idea how it happened. I may have a terrible new story to add if I figure it out.
Renamed a drive mount folder, while it was mounted. Back in 1999 with big box Redhat 5.1, it said “okay!” And I lost all data on that drive. I was just learning Linux at the time, without an internet connection since the PCI winmodem I had didn’t work in Linux.
And then accidentally copy/pasting the failed attempt code snippets of the OP describing the situation.
I’ve regularly found a solution to my problem on SO, only to discover that I need to figure out how to break my system exactly the same way the asker did before the fix will work.
Rermoved the Wireless card drivers while troubleshooting the Internet connection…
I once removed all groups from my user by using
usermod -g
instead ofusermod -G
You probably mean that you used
usermod -G
instead ofusermod -a -G
The -a stands for append
But you understand what I mean.
I did the same! After that, I never tried to run that command from memory
I accidentally overwrote /etc/passwd once and I allowed /boot to run out of space during a kernal update and I created a local user with the same user that was also on the realm/domain that I had joined and various bash script issues.
Some stuff I’ve had to fix that someone else did:- named a file rm -rf
- rm -rf /bin instead of ./bin – Also the fact that they had sudo was crazy and also I guess this was the second time
- chmod -R 777 /
- Various software bugs running swap out of space or hitting the inode limit by creating files over and over again with a timestamp in the filename and having to remove all of them because there was no backup to the OS
- Someone disabled SELinux because something wasn’t working but didn’t tell anyone – ugh
- Compiled java because they googled some issue and followed some old tutorial without understanding anything instead of using
alternatives
and symlinked the old java from /bin to /home/theiruser/java – had sudo because he was a Windows domain admin. - Cybersecurity guy didn’t know what some VMs did so he turned them off and figured he’d find out if/when someone complained. Caused a massive core services outage.
- Same Cybersecurity guy deleted a bunch of data because he wanted to see how the sysadmins would respond and witness backup restorations. He did not inform anyone.
- Cybersecurity guy above still has Domain Admin and sudo everywhere. I would have personally removed his privileged access regardless of what ‘CyberSecurity’ management thought but I was leaving for a new job by then anyway so I figured I’d just let them eventually lie in the bed they made.
There’s more but I don’t want to keep going because it is Sunday and I don’t want to ruin it.
Use dd
My buddy was in a class doing a programming test. It was a couple minutes until turn in time, so he went to zip up the source files. He had already ran the appropriate zip command previously, so he pressed up three times and then enter. It appears he had miscalculated, because the command that ran was
rm *.c
. There were no backups.Linux commands are brutal
Added an usb drive by its /dev/sd** identifier to fstab without the nofail option. Wanted to do a quick reboot for something I can’t remember, then copy the files over to the USB drive, since I’d need them on the next day and… no boot. The reboot had assigned another name to the drive (/dev/sdb instead of /dev/sdc or something) and automount wouldn’t skip it because nofail was missing. In the middle of the night, with files I required right the next morning. Fun times.
I’m not sure anymore how I got into a state where that was necessary, but do keep a reference around for how to boot Linux or Windows from the Grub command line.
Not me but a colleague of mine wrote a bash script that had something like this and ran it on a server:
FOO="/home/bar" ... Many lines later ... rm -rf $FOOT/*
Reminder that bash will resolve uninitiated variables to the empty string.
Luckily he halted the process after it had only nuked /boot and /bin. If it had gotten to /var and the mounted data storage within, we would have been in trouble
Do you work at Valve?
Always use
set -eu
Yeah if you don’t put bash in European mode, it is a lot more dangerous.
Ahhhh why not anything in
/tmp
or better${TMPDIR:-/tmp}
or bestmktemp
Way back when I was just beginning to experiment with Linux back in the 90s I installed ZipSlack, which was a GUIless 100MB distro based on Slackware that ran from a folder on Windows. It was okay but I couldn’t really do much with it and back then 100MB was a chunk of space, so i went to delete it. But i thought I would give it one last hurrah by deleting it from Linux. So I made use of the infamous
rm -rf
and sat there thinking “this is taking a long time”… then realised I had my Windows drive mounted as a sub folder and I was in the process of wiping my hard drive of everything!Was your project folder synced via nextcloud?? I had a similar issue arise with my projects folder being deleted and not in the trash bin etc, can only think nextcloud was the culprit as I had removed the folder from my server and default behaviour must be to replicate that removal locally.
Everyone here is talking about rm, but when’s the last time you dd’ed the wrong thing by accident?
You can get tripped up by tab completion, hda vs sda, sda vs sdb, flipping the articles around, he’ll, I’ve even blasted a good drive with /dev/random because I did t pay attention to what computer I’m logged into.
My killer app for multiple terminals open at once, weather through several ttys, xterms, tmux or the other one I don’t use was to type out my dd commands with a ls or something safe making in front of it while I look back and forth compulsively to verify that all the targets are correct.
Only reason dd hasn’t bitten me is that in my head, if and of make perfect sense as input and output.
Doesn’t mean I won’t make that error tomorrow, ofc. But I tend not to alias except harmless stuff to avoid that very problem.
Yup, I did that last year. I wrote a Linux ISO to my hard drive instead of a flash drive. It was interesting watching my desktop slowly fail. Thankfully I was preparing a switch to a different distro, so I had backed up what I needed.
All my drives are nvme* now.
I feel so much safer punching in of=/dev/sdaX
I haven’t but I’m always terrified of doing it
deleted by creator
What did you send
Most of mine are variations of getting confused about what system / device is which:
- Had two magnetic HDDs connected as my root partitions in RAID-1. One of the drives started getting SATA errors (couldn’t write), so I powered down and disconnected what I thought was the bad disk. Reboot, lots of errors from fsck on boot up, including lots about inodes getting connected to /lost+found. I should have realised at that point that it was a bad idea to rebuild the other good drive from that one. Instead, I ended up restoring from my (fortunately very recent!) backup.
- I once typed
sudo pm-suspend
on my laptop because I had an important presentation coming up, and wanted to keep my battery charged. I later noticed my laptop was running low on power (so rushed to find power to charge it), and also that I needed a file from home I’d forgotten to grab. Turns out I was actually in a ssh terminal connected to my home computer that I’d accidentally suspended! This sort of thing is so common that there is a package in some distros (e.g. Debian) called molly-guard specifically to prevent that - I highly recommend it and install it now. - I also once thought I was sending a command to a local testing VM, while wiping a database directory for re-installation. Turns out, I typed it in the wrong terminal and sent it to a dev prod environment (i.e. actively used by developers as part of their daily workflow), and we had to scramble to restore it from backup, meanwhile no one could deploy anything.
Getting packages from a spider web of repos then not untangling the web before upgrading from one LTS release to another. Ended up with an unfixable problem with essential packages and dependency versions and had to do a fresh reinstall instead. Fortunately I backed up my files first so I didn’t lose anything important.