Today’s post is a friendly reminder for all you fat-fingered typers out there:

Be very careful when using a Linux command-line/SSH interface not to mistype, especially when you are the root user.

This is something that I am sad to say I have come across on more than one occasion at my job (server technical support). Tiny little mistakes can wreak havoc on your computer/server if you mistype while using the command-line/SSH.

The information below uses the following keyboard slang:

= backslash
/ = whack
. = dot

Find these Keyboard Slang and more at codejacked.com

For all you Windows users out there who just happen to be reading this, there is a world of difference between “whack dot” /. and “dot whack” ./ In Linux, your root directory is labeled as “whack” / Thinks of this like your C: Drive on your Windows machine. Everything is relative to root. For example, if the path to a file on Windows was C:\folder\sub-folder\file , it would be /folder/sub-folder/file on a Linux machine. Yes the slashes point the other way from Windows to Linux: Windows uses “back slashes” \ and Linux uses “whacks” / If a file/folder location starts with a “whack” / , it means “from the root directory”. When dealing with file locations, the “dot” . means the files in the current/selected directory. So, literally “whack dot” /. means “all the files in the root directory” since the path begins with the “whack”; while “dot whack” ./ means “all the files in the current directory” since the path begins with the “dot”.

“Why bring this up?” you may be asking. Because you can cause a world of hurt if you mix up the two. Say for instance you want to delete all the files/folders in the current directory, a legitimate use. The correct command would be rm -R ./ The -R means “recursive”, meaning delete all files in any folder you come to, and then delete the folder, since only empty folders can be deleted on Linux. Or say for instance you needed to change the ownership of all the files/folders in the current directory. Again, the correct command would be chown -R user:group ./ This would set all files in, and below, the current directory to a user of user and a group of group. Those of you who have been following along can see where I’m going with this. If you mistakenly typed “whack dot” /. instead of “dot whack” ./ you just deleted all the files (recursively) starting at the root directory, or basically everything on your computer. Likewise with the chown command, you would’ve just changed the user and group for every file (recursively) starting in the root directory. Since certain services have to be run by specific users, this will cause problems.

Now luckily, the rm command for instance, is usually set as an alias to the command rm -i which means “prompt before removing each file”. However, if you think you know what you’re doing and decide to use the -f switch, this forces removal with no prompt. Therefore, if you leave off the -f when using rm , you’ll be prompted before removing any files, which may save you time, money, headaches, and in some cases, your job. Plus, for those of you who don’t know, unlike Windows, there is no “Recycle Bin” on Linux. Once you delete something, it’s gone for good. You can’t get it back.

There are plenty of other situations where a simple misspelling can cause all sorts of problems, especially when it comes to using switches (like the -f, -i or -R listed above), these two are just the most common mistakes I see. The bottom line is, especially when you’re logged in as the root user, just be careful when your working via command-line. Take 2 seconds to review your command before you hit “Enter”, because once you do, there’s no going back. If there is (going back), it’s not fun, it’s not easy, no one wants to do it, it will waste your time, and it will cost you money.

How about you? Have you ever “fat-fingered” something like this and caused problems? Post yours below.

Check out these Related Posts