quarta-feira, 4 de setembro de 2013

7 Little Command Line Errors That Can Cause Big Disasters


If your system suddenly shut down while you were working on the command line, chances are that you have committed some error. Here we bring to you 7 very silly errors that can cause trouble to you PC.

Wednesday, September 04, 2013:  It is a well known fact that if used incorrectly, even the most powerful too can turn against you, leading to unimaginable losses. Same is the case with the Linus terminal. Even small carelessness with the commands can lead to big system malfunctions which can spell disasters.


Linux, open source, Linux tools, Linux command line, Linux command, Linux commands, command line mistakes

Here we bring to you 7 silly command line errors that can create serious havoc in you system.

Warning: DO NOT attempt these command on you system and just in case you willing to try out, you can do that on a virtual machine.

1. Writing rm / somedir instead of rm /somedir

The minor mistake of adding a space in the rm command can actually delete the entire content of the root (/) directory. To avoid such situation, it is advisable to use rm command with the -i extension that prompts before removal. The -i extension is much more helpful as there is no option like undelete in Linux, so whenever you are using the rm command always use the -i extention.

2. -v is not always verbose.

Yes -v is means verbose in most cases of UNIX, but not always! Especially when it comes to pkill. The pkill command that is used to terminate a process with a certain name or pattern. If used with the -v option (which is used to negate the matching), it can kill any process that can be killed except for those whose name contain the process name. This can end up shutting down whole of your system.

3. Writing last | reboot instead of last | grep reboot

Missing the grep in the above command can cause your whole the system to shutdown instead of reboot. So it is advisable to be sure about what you are trying to do with your command. You can always refer the manual page to know about all the features of a command.

4. Writing crontab -r instead of crontab -e

r and e are adjacent to each other in the keyboard, so there are quite some chances that you might make a typo error and use the r instead of e and remove the whole processes instead of editing it. 

Writing /sbin/init 1 instead of /sbin/init q 

Similarly typo error of 1 and q here can cause the system to shutdown.

Hence it is advisable to be precise while typing your commands.

5. Writing g++ -o abc.cpp abc.cpp instead of g++ -o abc abc.cpp

The addition of extension while compiling a c++ file will cause the output of the compiled c++ program to be placed in abc.cpp. As a result, the source code gets deleted. Hence, always keep a backup of your source code.

6. mv /* ../ instead of mv ./* ../

This command which is basically used to move the files in the current directory up one folder to its parent directory. And this little error can move everything from the root directory to the parent directory of the current directory. Which can cause you rescue your grub by reinstalling the OS again.

../ is used to signify the parent directory of the current directory.

./ is used to signify the current directory

/ signifies the root directory

7. Using cat > [filename] instead of cat >> [filename]

‘>>’ is used for appending the content to a file where as ‘>’ is used to overwrite the current content. So, if you replace ’>>’ with ‘>’ the entire content of the file gets deleted.

Courtesy: fortystones 

Atithya Amaresh, EFYTIMES News Network 

7 Little Command Line Errors That Can Cause Big Disasters

Nenhum comentário:

Postar um comentário