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.
Running the right command on the wrong SSH session/machine.
This is the scariest comment I’ve read in this thread.
Imagine that you’re using fqdns instead of ips…
I refuse to elaborate.
I set a different background color on all my machines because of exactly this while using VNC/RDP
this. after i set different zsh themes on my servers + my main machine i now know exactly what machine i’m running commands to
-
have an nvidia GPU
-
have Fedora
-
download RPM package of drivers for Red Hat (after all, Fedora and Red Hat are… compatible, right?)
-
Everything goes fine
-
Six months later, upgrade to a new version of Fedora
-
oops, kernel panic at boot after the upgrade, and no video to troubleshoot after UEFI boot
-
figure out how to boot into a recovery partition from UEFI
-
figure out how to enable a serial console over a USB device
-
figure out how to connect to the serial console from another computer using another USB device
-
figure out what the kernel panic is from (not the upgrade, but the driver which wasn’t upgraded)
-
figure out how to uninstall the incorrectly installed driver
-
figure out how to install the correct driver
That was a fun three week OS upgrade.
I have a super-n00b question, and I apologize in advance, but, uh…yeah, what is a serial console?
You attach a secondary computer via serial (COM port) with your primary computer and then you can open a console on that one. You can access the primary computer as if you would be sitting in front of it.
You probably have to explain what Serial actually is.
Adding to what DmMacniel said, it’s a hardware interface, often accessed via a USB port (which after all, is the universal serial bus).
https://en.wikipedia.org/wiki/Serial_console
tl;dr:
Serial ports are (for example) commonly RS-232, although other types of ports exist. Imagine it to be a very slow Ethernet device. Because it’s so slow (and the technology predates Ethernet and also has different requirements), it’s usually attached directly to a device instead of to a network. But you could connect a modem to it and it becomes connected to a network device.
It could also be connected to a system console device. These are commonly called terminals. Such devices are often monochrome (especially older ones) because a serial connection is often bandwidth limited (eg, measured in kilobits per second instead of megabits or gigabits). Since it’s so slow, it’s not practical for video, so it’s generally just text-only.
Note that your GPU might also output a system console but rendered on your display at very high resolution and with graphics-drawing capabilities. So a system console would be any console that connects to the system.
What is a console? Well, Wikipedia presents several valid articles and the common theme as far as computers go is that a “console” is typically something that a human and a computer use to interact with each other.
For serial consoles, you might find device files for them at
/dev/tty*
. But for general serial devices, it could be any of several different types of device files.Wikipedia’s article on
/dev
devices has a pretty decent listing of what kinds of devices you might find and several of them might be classified as a serial port. Any serial port might be connected to a serial console.So in my case, a serial console is:
- 2x USB-to-RS-232 (USB is a serial protocol and is basically “just” another (Universal) (and perhaps high speed) Serial port (Bus), so conversion is super cheap)
- 1x RS-232 null modem cable
That’s pretty much it in a nutshell. Then
- System 1 (the failing system) UEFI boots into repair system partition on a separately attached disk (eg, boot from CD or live USB) to get a local system console
- System 1 repair system mounts the failing system partition
- System 1 modifies failing system
grub
configuration to enable a serial console on the attached USB-to-serial device file and saves changes, then unmounts failing system partition - Power off System 1
- Remove repair partition device
- Open terminal window on System 2 (recovery system)
- Connect System 2 terminal to the attached USB-to-serial device file using
screen
(oh wow those were some old days) - Power on System 1
- System 1 boot enters grub recovery menu which allows fixing the system remotely
To be fair, a lot of that complexity could have been done by either reinstalling, or removing the hard drive and attaching it to another computer. But doing it this way allowed me to poke around and try different ways of solving the issue, rebooting, etc. It was a learning experience worth exploring.
It was years ago though and I think there was some complication with trying to understand what device file (or device number or something) needed to be to work on the correct serial device (there are often multiple)
Wait, that’s a tl;dr to you? o_O
I’ll quote my current boss’s boss’s boss when he asked a question of me:
@inetknght, can you please not write a book? I need a quick answer
I felt the same way so I scrolled down hoping for a shorter answer, but found yours instead and it made me laugh my ass off because how you wrote it really hit me, are you me? xD so I just wanted to say thanks for making my day even better!
Haha I’m really glad I could make another person laugh today! xD
Why would you need a serial console? Live USB is a thing
-
I once removed all groups from my user by using
usermod -g
instead ofusermod -G
You know, I’m in a constant battle with bootloaders. I’ve both deleted grub multiple times and windows boot manager by accident and by believing “I could fix it by re-generating it”… More like re-installing.
I’ve fixed the Windows bootloader before, but every result you find says something slightly different, feels like no one quite knows how to do it.
https://forums.tomshardware.com/faq/how-to-repair-efi-bootloader-in-windows-10.3275168/
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
ntfsclone /dev/sdc /dev/sdb
/dev/sdb was a blank filesystem and /dev/sdc was my Windows filesystem.
It ran for less than a second and didn’t take me long to figure out what happened. That’s the story of how I stopped using Windows.
Damn that’s the equivalent of going cold turkey.
I don’t use windows for close to 20 years so I didn’t need ntfsclone so far but do I read correctly the man page that only the source is specified as positional parameter? If so, shouldn’t you have to write
nftsclone —overwrite /dev/sdc /dev/sdb? It still can be misleading (given that mv uses two positional parameters so mv -f source destination would have done what you wanted) but a bit less cryptic?
I do dumb things like edit my network configuration do some stuff and log out. Then I can’t login the next weekend because the IP address is wrong. Also:
Ifconfig eth0 down
And I am booted from ssh.
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!Reformatted windows and installed Linux.
Wait before the hate. This was the first time I did it and knew nothing about it and didn’t know it would wipe my system. So I lost everything.
On the brighter side, you did delete windows.
Yeah I don’t see the problem here
I tried to install an OS to a USB stick. This is Kubuntu specific.
You need to create a GPT partition on the stick, then you should be able to just use the installer and install on another USB stick.
I went through it, selected the usb stick… was not sure if everything was right and went a menu back, was correct, went forth again, past the install target selection and installed.
Well… turns out the Kubuntu installer (Calamares) selects the first disk always. And that selection seems to reset to default when going a menu back…
I deleted my complete normal disk, with like everything I had.
No Backup no mercy. Luckily did one only a few weeks before. The first since half a year! Damn… had my uni stuff on Nextcloud, a lot of personal stuff synced to my phone with syncthing.
rm *.c
when I meantrm *.o
My first experience with installing Linux on a hard drive involved wiping the wrong hard drive (my dad’s) and installing on it. Then panicking when Windows 95 didn’t boot up. Thank goodness my dad was understanding lol.
“I have 200 GB of unused space in the windows partition, I’ll just plug a live CD, divide that partition and merge it with the Linux one, ggez”
Yes, dividing the windows partition destroyed it. Yes, mixing the windows and ext destroyed Linux. I might have been able to recover something but I was like 18 and I just reinstalled windows in a fit of misdirected anger against Linux.
I mounted a disk of a server in rescue mode, since I needed to extract everything (the provider didn’t have the option to dump everything as a zip). Then installed an FTP server, added a user/pass, it worked.
But I couldn’t access the files of the original disk, even though I could see them. So I just chgrp/chown the original files, since the disk was just “mounted” in the rescue disk /mnt, I thought it was alright (at the time I thought permissions were volatile, stored separately from the files). I could now download the entire disk, yay!
Upon booting the original disk again, a bunch of errors: shell not starting, tools not running, because they were owned by user and not root…
Well we reinstalled all the server from scratch that day.
Trusting tab-completion and pressing enter just a tiny bit too early, resulting in overwriting the work of at least four hours, because the files’ names started the same. That whilst trying to initiate a git repository to prevent that kind of mistake…