Linuxables: Intro to Linux Command Line

949

This is the first in a series of a “Linuxables,” short, quickly consumable tutorials that can provide easy reference while at work or at home. We hope they’re useful for you. Let us know in comments.

Ah, the Linux command line – that of which myths and legends are made. It is that frightening beast that keeps so many users from trying Linux. After all, everyone knows you MUST use the command line if you want Linux as your operating system. Not so. In fact, you could install Linux, never touch the command line, and have an amazing experience. But there are times when you will want to have that extra power at your fingertips. And when that time comes, you want to be prepared for it. The Linux command line is not all that difficult…you’re not programming in assembly after all.

It is my intent, in this first series of “Linuxables,” to introduce you to the Linux command line interface (often referred to as the CLI) in such a way as to alleviate any hesitations related to this versatile, powerful administrative tool. I’ll cover what is the command line and its basic structure in this first piece.

What is the Command Line?

The command line is the tool that all GUI applications use to do their work. In other words: graphical tools are merely front-ends to command line tools. This is the case with most operating systems. You click a button and that button most often interacts with a command. And any time you are using the command line, you are doing so within a terminal window. To get to your terminal window, you click Applications > Accessories > Terminal (in GNOME).

All commands do not look like:

find /etc -exec grep ‘[0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*’ {} ;

In fact, most Linux commands are quite simple. It’s just a matter of understanding how the basic command structure works. Let’s take a look.

Command Structure

The basic Linux command works like this:

command OPTIONS ARGUMENTS

The explanation for each is as follows:

command: This is the base of the command. For example, if you were going to create a new directory, you would use the mkdir command. But if you used the mkdir command alone you would get an error, because you didn’t pass any arguments or options along with the command.

OPTIONS: Options are those pieces of the command that alter the behavior of the command. Say, for example, the directory you need to create needs to have specific permissions set upon creation. You could add the -m option (for mode), which would directly affect the results of the mkdir command. Options aren’t always used alone. Some times an option will be used along side a modifier. In the case of the mode option you will have to use a modifier to tell mkdir which mode to use. ‚Ä®

ARGUMENTS: Arguments are typically file names or other data that is needed by the command. Keeping with our mkdir example: Say you want to create the directory TEST with the mode 654 (more on modes in a later article).

For this, the command would look like:

mkdir -m 654 TEST

As you can see there is command OPTION ARGUMENT and TEST is our ARGUMENT.

The Linux command line interface does not have to be an overly complex tool. In fact, it’s really quite simple to use. And if you are ever in doubt about how to use any given command, don’t forget that nearly every one of those commands has a manual page included that will help you out in your quest to use that command. To read the “man page” for the mkdir command, you would issue the command man mkdir.