Linux Command Line

Bookmark and Share
This results in a wide variety of desktop shells—and the realization by anyone who uses Linux for even a brief period of time that knowing the command-line interface remains important.

Proceed with Caution: rm
Before even opening a terminal window in Linux and playing with the command line, be aware that if you're not careful, you can wipe out your Linux operating system with one command and it won't even ask you if you're sure. The command to delete files or directories in Linux is rm (remove). It's a perfectly good command if used to delete files once you're inside a directory (rm filename) or, in its derivate rmdir form, to remove a directory (rmdir directoryname), but if used with its full power it can be disastrous. Using the - r (recursive) switch with rm tells Linux to remove the specified directory and all files and subdirectories within it. So rm -r mydocs gets rid of all the files in the mydocs directory and any subdirectories you might have in mydocs, including all the files in those subdirectories all without asking and all without providing any feedback about what it did. It's a corker.

You can force Linux into interactive mode by including the - i switching which case rm -ir mydocs asks for confirmation before removing each and every file in mydocs and its subdirectories. But it's just too easy to forget the - i switch, so for file deletion it's always best to get into the graphical file manager (File Browser in Ubuntu) and work from there

Getting Help with Commands:
Aside from a huge number of explanatory documents and forums on the Web, Linux installs with built-in help. If you try a command and get no results, Ubuntu responds with a statement of how the command is to be used and how to get more information. For example, typing rm by itself on a command line yields the following response:

rm: missing operand
Try 'rm --help' for more information

The second line is the clue: To get help, type the command, then a space and two hyphens followed by the word help. You'll find, for example:

-r, -R --recursive remove direc¬tories and their contents recursively
-v, --verbose explain what is being done

In other words, typing either rm - v or rm -verbose will get you an explanation of what the command did, instead of just the return to the standard command prompt. Use a single hyphen for an abbreviated switch, a double for the spelled-out switch.The --help switch is useful, but its output is condensed. For more comprehensive help, use man (manual): man commandname. For an example of what the man command yields, see the top screen above. How to exit from a manual page screen, though, isn't made clear. To get back to the com¬mand prompt, press Ctrl-Z

{ 0 komentar... Views All / Send Comment! }

Post a Comment