How about sharing your favorite lessons learned moments?
53 Answers
I was curious if chmod 000 /
would work.
Well, flawlessly. A few minutes later I was searching for a rescue CD.
-
11Wow I never even considered that until you mentioned it. Good one. Commented Oct 11, 2010 at 17:57
-
-
-
I usually do such 'experiments' in my Arch VM. If it bombs I just roll it back. Commented Jan 20, 2011 at 23:47
-
I made this mistake once. It was highly embarrassing, but a valuable lesson. Commented Jul 12, 2011 at 3:38
When I first started working as a user consultant for the university I was attending, I was given limited sudo
rights to help students who had lost/forgotten their passwords. sudo passwd <username>
was my new friend. An hour after my orientation, my curiosity got the better of me and I typed in sudo passwd
and stared in horror at the prompt for a new password. I was a bit scared to ^C
my way out of it, thinking (erroniously, it turns out) that I might leave the account in question in a transient state, so I entered a password and immediately walked upstairs to the hallowed 2nd floor domain of the campus SuperUser and asked if he would like to know the root password of the main system.
-
4
-
30you could have entered a mismatch password at the 2nd confirmation prompt, so nothing would have been affected then and passwd would exit.– Wadih M.Commented Sep 1, 2010 at 14:53
-
1@Wadih:
passwd
behaves funny when run as root. For example, when failing the typo check, it asks again. Commented Mar 6, 2011 at 3:57 -
You could have just changed it back to what it was before. Commented Mar 10, 2011 at 5:24
-
1@HandyGandy he didn't know the original root password. He just had sudo rights to run passwd.– gnudCommented Mar 10, 2011 at 14:28
Surprised nobody else has mentioned this one yet:
rm -rf .*
(While attempting to remove all hidden files and subdirectories, completely forgetting that it will recurse into .
and ..
)
-
3While that has burned me in the past, many versions of
rm
won't do that now. I tried on Darwin and got the errorrm: "." and ".." may not be removed
. Commented Aug 24, 2010 at 3:43 -
7I do that all the time, on all kinds of platforms. Works as intended on OpenBSD, NetBSD, Linux, and OpenSolaris.– polemonCommented Aug 29, 2010 at 13:47
-
If you want to match all dotfiles except for
.
and..
, use.[^.]*
. (Well, this will actually miss all files starting with..
, but usually there is only one.) Commented Jun 4, 2011 at 23:38 -
@Sven: Another way is
.??*
, which I find easier to type. This one won't match two-letter dot files like.a
, but those are unusual too. I search the config files in my home directory withgrep -r .??*
, for example. Commented Jul 5, 2011 at 3:38
Makefile:
clean:
@rm -f * .o
Which, of course, makes make clean
wipe your source code instead of just object files.
Lesson: use version control.
-
11If you can't see it, notice the space character between
*
and.o
Commented Aug 17, 2010 at 23:32 -
1
-
Lesson reloaded: whenever you do shell-stuff, and you see a "", be *extra, no, be extra Extra EXTRA careful. Commented Apr 12, 2011 at 23:05
-
I did that one, by hand, after pulling an all-nighter in the lab. The project was due a few hours later. It turned out to be a blessing in disguise; the new, rewritten version I turned in was much better than the bandaged version I erased. Commented Aug 31, 2011 at 17:07
-
1Obligatory Bumblebee reference: github.com/MrMEEE/bumblebee/commit/a047be– ResiduumCommented Sep 5, 2011 at 13:05
Had a friend run :() { :|:&}; :
on a remote server where we didn't have console access to. Couldn't reboot it, completely frozen, production server.
Broken down (by request) to make it a bit more readable.
:() # Define ':' as a function. Every time we say ':' execute the following code block
{ # Start of code block
: # Call ':' again.
| # Pipe output to...
: # Another ':'
& # Disown process.
# All on one line this would read :|:&,
} # End of code block
; # End definition of ':' as a function
: # Call ':'
It might be easier to look at it as
bomb() { bomb|bomb& }; bomb
-
1Would You be so kind to explain what it does? I can't figure it out and I don't want to try it ;)– naugturCommented Aug 19, 2010 at 8:54
-
23Look's like a fork bomb. Don't try this unless you really know what you're doing.– ZaidCommented Aug 19, 2010 at 9:29
-
5Yup. It's a forkbomb. And a nice one :) It seems to fork bash interpreter as it endlessly tries to parse it. If You skip the last
:
it does nothing. And it doesn't use memory at all, just forks a lot. [Yes, I did try it:)]. Effects can be blocked with a quota on number of processes per user.– naugturCommented Aug 19, 2010 at 10:16 -
8
-
4+1 for the above comment. It's far easier to understand than it looks.– UmangCommented Aug 19, 2010 at 11:54
I meant well, I really did. Trying to chmod
recursively a directory and ended up swapping ./
with /
.
As root of course, because only with root can true pain (and thus enlightenment) be achieved.
-
23+1 for quotable "Only with root can true pain (and thus enlightenment) be achieved." Commented Aug 27, 2010 at 22:49
I wiped the partition table of my main drive by accident, thinking I was working on another drive.
With scrollback, careful use of df
, memory, and luck I was able to recreate it exactly, rewrite it, reboot, and hope... And it worked.
-
6A friend did this, and I helped him restore the table. Unfortunately, we didn't have the previous values for the partition sizes and offsets, so we used a bash loop with
dd
reading the first 4k block of every cylinder piped intofile -
to find the superblock and thus the start of the filesystem. This was on a live CD and there wasn't enough RAM to do everything we needed to do (which included installing a package or two) so we piped into a process running in ssh on another machine. Commented Sep 12, 2010 at 23:37 -
2Ouch. That's why I always use
sfdisk -O
to back up the partition table, always. FYI: cgsecurity.org/wiki/TestDisk can automate what @Neil Mayhew's did. Commented Nov 17, 2010 at 18:25 -
2
-
These days, we have
gpart
, which looks for things that might resemble filesystems and constructs a partition table from that. Commented Mar 10, 2011 at 17:54
Not really my moment, but someone else's.
Back when I worked at a nuclear sciences research facility we used to run a number of SunOS, Ultrix and Linux computers and researchers had to share the CPU on those machines. As individual research groups got their own research grants they purchased their own computers, mostly SparcStations and they did the system administration themselves.
SunOS used to ship with the OpenView desktop and a nice file manager, this is what it looked like:
Most of our researchers were running as root, and more than once we had to reinstall their operating systems because someone had decided to tidy-up the root directory and moved /bin, /etc, /tmp and everything else that cluttered the view into either the Trashcan or some subfolder.
Other users chose to tidy up the /bin directory and remove any command they did not know.
The lucky ones had back ups, most had purchased a tape drive, but did not have a tradition of running backups themselves.
-
11
-
41TRWTF is they were running as root, at a nuclear sciences research facility!– invertCommented Aug 16, 2010 at 8:37
-
4
-
@Alex - well there was this big VMUNIX file that I wasn't using .... Commented Aug 20, 2010 at 0:10
-
1On old Mac OS versions, you could pretty much move any file anywhere, so maybe that is what they were expecting... Commented Oct 14, 2010 at 21:01
Back in the mid to late 90s, a friend of mine and I were discussing the folly of rm -rf *
and at what point a Linux box would go belly up. We got into statically linked versus dynamically linked libraries and I posited that the system could live quite well without /lib
and then proceeded to rename it on my workstation. Bad things happened, but we were left with several open console windows with which to try and fix the damage (shutdown wasn't an option anymore). None of the editors would run. It is amazing the esoteric uses you can find for the echo
command.
-
19There is a classic story on this exact topic: lug.wsu.edu/node/414– Alex BCommented Aug 16, 2010 at 10:19
-
1@Alex B: The story is also part of the Unix Horror Stories, which is just great to read.– BobbyCommented Feb 9, 2011 at 19:50
vi
and Caps-Lock vs. /etc/passwd
- Connect to an old Solaris box using an old serial terminal that doesn't refresh the screen correctly.
su -
vi /etc/passwd
. There is novipw
, and "we're just making minor edits" anyways.- Hit Caps-Lock key and don't notice.
- Hit j a couple times to scroll down. Ignore the fact that you actually just typed J ("Join"), which combines this line with the next line. The serial terminal screen was not refreshing correctly, so you didn't see that you just combined the first 5 lines into one Loooooong line, thereby corrupting the first 5 users ('root', 'daemon', etc).
- Finish your OTHER intended edits to the file, way down at the bottom.
- Save file.
- Log out.
I did this once. Amazingly, the system remained functional for months. Cronjobs ran fine, no errors stood out in the logfiles.
We didn't notice this problem until we rebooted the system months later and couldn't log in at the console. ps
showed a bunch of jobs owned by UID '0' not by user 'root'.
You could not log in as root, nor run su
or su -
, and there was no sudo
on this box. There was no floppy drive, the CD-ROM was busted and no USB ports (so no external CD-ROM). Single user mode did not work, because you need to type in the password for root, and that comes from /etc/passwd
.
-
2Surely "J" is the "Join" (as in join lines together) command?– dr-janCommented Aug 19, 2010 at 18:07
-
2Wait a minute, I don't need to type the password to boot into single user mode. In fact that is how I reset the root password if I lose it. Or was it different in the old time? Commented Nov 20, 2010 at 16:05
-
On Solaris, you need to know the root password to enter single user mode. I had to do this 2 weeks ago actually. Commented Nov 22, 2010 at 5:38
-
@phunehehe I think your thinking of the init=/bin/sh trick. That does indeed not require the root password. However runlevel 1 does still require root pass– phemmerCommented Feb 7, 2011 at 16:16
rm -f * ~
and
rm -rf ${DIR}/
when DIR
was not set!
-
4You mean
${DIR}
? Because$(DIR)
would try to execute DIR command. Commented Nov 13, 2010 at 22:49
I remember trying to send a SysRq key sequence to a remote machine...
...but it was captured by the local one.
A simple halt
recognizing some seconds later that I'm not on a local shell and having no possibility to power on the production server again.
Lessons learned? The prompt of the machine now looks like
[ --> root <-- @kompost:/home/echox] #
with some nice red markup ;-)
-
6There is a tool called
molly-guard
that checks whether you are logged in remotely and asks whether you really want to do this. Commented Mar 10, 2011 at 17:58 -
My favourite moment was, when a co-worker, who is an emacs user, wanted to edit an important file.
Because emacs
is too much to type he had setup an alias for emacs
:
alias em=emacs
Under the influence of not enough or too much coffee he of course mis-typed em
...
Well, this is just another reason to use vi
... ;)
Or another experience, how to feel really stupid in a few easy steps that don't seem all that stupid individually.
Step one: establish an account for the kid, in case he wants to use a Linux box. Give it a trivial password, since after all this is a home system and isn't exposed to the net.
Step two: allow time to elapse, so you don't remember step one.
Step three: open the SSH port in the firewall (actually the NAT on the router) in order to ssh in. After all, my accounts have pretty good passwords, and it isn't like there's anything tremendously valuable.
Step four: get notification from ISP that there's some sort of DOS activity going to a Swedish site. Assume it's probably the Windows boxes, and examine and harden them.
Step five: get notification from ISP that it's still going on. Ask for some detail, get IP address of Swedish site, fire up Wireshark, find which box the attack is coming from.
Step six: clean up Linux box, feeling stupid. Find the login came from a Romanian address. Remove accounts without good passwords.
-
1Been there. I once created an account with a login of test:test, intending to use it for only about five minutes. I forgot to delete it and got same results as you. Never again. I go all public-key auth now.– ATCCommented Oct 9, 2010 at 17:00
-
1Yeah, I also use public/private keys. They can be a bit annoying sometimes, but a lot safer than simple passwords. Commented Nov 13, 2010 at 22:48
-
4When opening SSH to the internet, NEVER EVER allow password authentication. Only public/private key auth, that way you can't get caught off guard.– wazooxCommented Jan 21, 2011 at 14:47
-
-
I use a non-standard, high-numbered port for ssh, forwarded from the router to the standard ssh port on my Linux and Mac OS X boxes. I never get any attempted logins. I have the port configured in a shortcut in ~/.ssh/config on my other machines so usually I don't even have to type it. Commented Jul 5, 2011 at 3:28
In the computer labs when I was in college, they had a screen saver that simulated a bunch of balls that would float back and forth. They pulled on each with simulated gravity.
Once, while I was messing around with the settings, it crashed with the error Error: force on balls too great
I was once developing a device driver for Unix. It had a pointer problem and during testing it started to write off the end of an array in kernel memory. I was slow to spot this and didn't hit the reset button immediately. The driver had scribbled all over the disk buffer cache which was then flushed to disk before I hit reset. A lot of the blocks were inodes and directories, and I ended up with a totally trashed filesystem. I think 6000 orphaned files were put into lost+found
before I gave up and reinstalled. Fortunately, this was only a test system, not my workstation with all my files on it.
-
Now doing that on your work system would have been really stupid ;-) Commented Apr 12, 2011 at 23:23
I deleted /etc and then recovered it. I don't think I learned my lesson... I've had to recover from a deleted /bin
too. Seems to happen when I've been working with a chroot
.
-
-
1I've been witness to this as well. I'm amazed that a system can survive without /etc --- just don't restart anything. Commented Aug 19, 2010 at 17:06
Last year, a colleague of mine was using one of our linux workstations to create copies of flash disks using the dd
command. He accidentally typed something similar to the following:
dd if=flash-image.img of=/dev/sda1
By the time he realized his mistake - overwriting the machine's hard disk instead of the flash drive - the machine was already hosed. We had to rebuild the box, which incidentally was also the machine hosting all of our development VM's at the time...
-
2
This happened to me last year. I was removing some files from the server using a temporary variable:
rm -rf ${prefix}*
Guess what? The variable $prefix
was not defined!
You can imagine the disaster... it resulted in some very critical files deleted.
I almost broke the Control-C and ran to the CPU to remove the network cable!!
Hahaha I'm sure someone had already done this...
While in my 2nd year of studying computer science we were given a homework assignment to write a program in C that would spawn a number of subprocesses with fork
and make them communicate with pipes in a "circle" and figure out which one should be the "leader".
We were still quite noobs back then and most of peple didn't have any Linux machines, so we worked on our accounts on our faculty's main server (which was hosting official site and staff accounts and sites as well). Most of the people wrote forkbombs at some stage of trying to do the homework. Over half of my group got to the abusers
file. That was the highest load on that server in a looong time :)
-
that was silly of them... they shouldn't have put you on the same machine as webservers and stuff. (My school has the same thing, but we have severs dedicated to remote shells so the yearly forkbombs don't really get too out of hand)– Spudd86Commented Feb 9, 2011 at 3:26
-
Microsoft got the faculty to get into partnership and windows and .net were much promoted then already. Nobody expected a bunch of noobs on the server :)– naugturCommented Feb 10, 2011 at 17:21
When my University decided to switch the wireless network to use proprietary Cisco LEAP authentication...
Started a very long battle that ended well enough. Wrote up documentation for others who wanted to run Linux and have access to the internet. Six months later they decided to add PEAP support as well. face slap
It is my favorite because I won. I got it to work.
As root on Solaris,
$ kill -9 1
...and everything went down.
My friend got fired because of this.
I was a lab assistant for a Linux class. One of the students called me over because she could no longer su -
because she was getting permission denied
. OK, she's misremembered/mistyped the password. Reboot into single-user mode and reset. What?! su
STILL doesn't work?! It MUST bow to my will! So I reboot into single user mode to find out what she did. I realized that she ran chmod -R 777 /var/www/html/drupal-6.19 /
Note the space between the directory name and the final slash.
After a few minutes of "I really don't want to have her reinstall, so what is this doing and how.", I managed to find that /bin/su now had file permissions of 777
. That can also be read as file permissions of 0777
, which removes the setuid bit from /bin/su
. A quick chmod u+s /bin/su
and I was a hero.
-
5That was the only thing you needed to change to unbreak her system? Commented Oct 10, 2010 at 0:10
-
1I'm sure it was still broken, but maybe it worked well enough for the rest of the class. Commented Oct 10, 2010 at 3:53
-
1It did work well enough for the rest of the class; the school evidently has a requirement that all student drives be reinstalled every quarter. And she wasn't going on with Linux after this quarter was over, so I didn't bother fixing it the rest of the way.– Kevin MCommented Oct 10, 2010 at 12:43
Not that painful... But a fun little moment:
I've mistyped ls
as sl
and found out that the sysadmin had something installed for such case.
(already available in Debian, Ubuntu, Gentoo,... repositories)
-
4That's more of an Easter Egg than a painful moment. I read about it before I came across it, but I've never found myself mistyping that, so no +1.– UmangCommented Aug 19, 2010 at 11:56
-
Grinn.. I had a user once that came to me "You're system is hacked!!!11one I got an ASCII-art animation when I typed ls" Commented Jul 27, 2011 at 9:56
-
git init
git clean -f
This does not remove the repository. This removes everything that is not in the repository.
After trying to get rid of the existing repo and then start source control again (on the completed first version of a project), these two commands nuked my entire code.
-
git rebase (with squashing) and git filter-branch (for removing files) are your friends :-) By this I mean that there are safer ways to remove cruft from your repo history and end up with a relatively clean project. I usually make a backup copy of the current branch before extensive rebasing. Commented Jul 5, 2011 at 5:14
A company that I used to work for had its product running on SCO. I was doing some debugging about applications getting very slow on our demo server and at the same time there was a bunch of customers being given a demo/lecture about upcoming new features.
So, I ran the application that used to get stuck, did my stuff on it to verify the root cause, but since it was still "stuck", I tried to kill it:
pkill -9 mytestapplication
What I did learn was that pkill doesn't do exactly the same on SCO as it does on linux =)
... It basically kills everything the user has access to, and with root... that's everything =)
-
1Could you please describe what it does on SCO? I have no idea, and I couldn't find it easily on google. Commented Nov 13, 2010 at 22:55
-
1it basicly kills everything the user has access to, and with root .. its everything =)– rasjaniCommented Nov 18, 2010 at 12:09
My switch from Debian to Ubuntu started the day I tried to delete some files and directories, meaning to type
rm -r /var/tmp/*
Unfortunately, I inserted a space between "/var/tmp/" and "*" and even worse, I was in the root of the filesystem.
root@workstation:/# rm -r /var/tmp/ *
Please don't try that at home!
-
'zsh: sure you want to delete all the files in / [yn]?' - it's quite useful Commented Jan 21, 2011 at 0:04
-
There's a neat trick to do the equivalent of dirname
and basename
, respectively, in Bash:
${path%/*}
${path##*/}
Not so funny when $path
contains a trailing slash...
I had two drives installed at one point and had the root filesystem of the second drive mounted in a directory within /mnt
. I was in that directory and tried to delete var
but ended up typing rm -rf /var
instead. Some instinct seemed to kick in that said var
must be preceded with a slash!
When I realised what I'd done I immediately hit Ctrl-C but it was too late. My rpm
database had long since left the building. I spent ages getting everything back to normal.
Now for the painful part.
I go back into that directory in /mnt
to resume what I'd been doing. What do I type? Well, let's just say that instinct kicked in again.
At least I was able to restore the system a lot quicker the second time ;)
-
1
rm
command. Or sad.