Geek Stuff
| In Linux - power comes with responsibility |
|
|
|
| Written by Frank Emmons |
| Thursday, 30 July 2009 21:37 |
|
I think every Linux user has committed the cardinal sin of working as root when they should not have been as they were cutting teeth on the OS. I know I had my colossal blunder when typing the ill fated command at 'rm -rf ./*' while I was root. Furthermore - I really sealed the fate of my workstation at that time because I was currently in /etc! Only after the command had finished and the command prompt was blinking at me again did I start to get that sick cold and sticky feeling in my gut. I realized what I had just done and hoped there was a way to undo it. I had a a IRC session currently open and was idling in the #linux channel. I let my fellow Linux users know what I did and asked what the solution was. I have never seen so many 'LOL's before or since. After all the laughter had finished they confirmed what I knew in my heart of hearts to be the stone cold truth .... I had LOBOTOMIZED my OS. Nothing left to do except stop the sobbing and get to re-installing. Linux has no undo. Like other *nix OS's, it assumes that since you are bright and brave enough to login to it as root, then you are big boy ( or girl ) enough to take your lumps if you do something stupid. It's not like DOS, Windows or Mac .. it won't hold your hand and ask you for confirmation if you are about to start hosing critical system files. When you type a command into the console and strike the enter key ... then it does it. PERIOD. But, we can protect ourselves from our own stupidity. At least I learned how to protect myself from my own stupidity and impatience after whacking my /etc directory. It was at this point early in my Linux experience that I learned about alias and my .bashrc file. Now anytime I install Linux on a box, one of the first things I do as root is edit my $HOME/.bashrc and insert the following lines (if they are not already present). alias rm='rm -i' Then save the file and log out of root. What an alias in your $HOME/.bashr or $HOME/.bash_profile does is says something like when this user types in the 'rm' command, he really wants to run 'rm -i'. According to the man page for rm, cp and mv the '-i' is defined as 'prompt before every removal/copy/move'. That way anytime after I am working as root and perform the 'rm', 'cp' or 'mv' commands, I am prompted for confirmation. If I would have had that confirmation years ago when I killed my first installation of Slackware like I did .. it would have never happened. I hope my story of woe can help another up and coming Linux user avert the same disaster that is all too common among *nix neophytes. As a corralary to the tip above ... when in doubt, use pwd and/or whoami before running any kind of rm * command. |
| Last Updated on Thursday, 30 July 2009 22:20 |