-->
Previous Table of Contents Next


Chapter 1
Linux Structures and Commands

Depending on your background, Linux is either an amazingly complex and, inscrutable operating system (that is, if your background is in the Microsoft Windows or Macintosh worlds) or just another simple, command-line–driven operating system (if your background is in the MS-DOS or UNIX worlds). The truth lies somewhere in between: yes, Linux can be inscrutable at times, and yes, it is built around the command line, even if you’re running the X Window System. However, as far as operating systems go, Linux isn’t any more complex than MS-DOS or UNIX, and it’s actually got some tools that rival those of Windows and the Macintosh.

As you prepare to plumb the depths of the Linux operating system, two rules will make your life easier:

  Linux is really a collection of small, easy-to-use commands. If you can simplify your tasks and break them down into discrete elements, you can do just about anything.
  Even when you’re working with XFree86, the Linux version of a graphical interface, you’re still basically working with a collection of small, easy-to-use commands.

It would be easy to deduce that anyone wanting to master Linux should first be eager to master its command structure. That’s where this book comes in: Linux in Plain English is a listing of the Linux command structure. But before you can use these commands, you need to know how Linux deals with commands and how to enter these commands into the system.

The Command Line

We’ve already mentioned that Linux is a command-line–driven operating system. Commands are given to the operating system on the command line. You know that Linux is ready to accept a command when you see the following on your screen:


$

This can appear in a full screen when you’re running in terminal mode, or it can appear in an xterm window when you’re running the X Window System, as shown in Figure 1.1.


Figure 1.1  Xterm running in the X Window System.

The dollar sign is called a prompt, and it’s the mechanism Linux uses to tell you that it’s ready to accept a command. At tthe prompt, you can enter a single command or a combination of commands and options, the sum of which is called a command line.

A command is exactly that. No matter what you enter at the prompt, Linux interprets it as a command, or an order to do something. You can use commands directly to do something, such as moving and copying files. You can also use commands to run other programs, such as elvis or emacs. Linux has a specific set of commands, so if you type in something that doesn’t match one of its commands, it tells you it can’t find the command. (You can actually see the list of commands when you look in directories, but we’re getting ahead of ourselves here.) There are literally hundreds of commands in the Linux operating system.

Commands have options, which serve to better specify the behavior of a command. These options can tell a command to perform an action only under certain circumstances. This can be best seen with a general command and some of its options.

The ls command is one of the most basic and most used commands. It’s used to list the files in the current directory. By itself, it merely lists the files in a given directory, as shown in Figure 1.2.


Figure 1.2  Using the ls command by itself.

This tells us that this particular directory contains a single file called fig1_1.gif. (The names of the files and directories in this chapter aren’t important; all you need to know are the mechanisms for calling these files and directories and how they can be applied to almost any command.) However, the ls command by itself refers only to files that are accessible to all users and aren’t hidden in some way. Hidden files begin with a dot (.), and so you need to tell the ls command to look for all files, including hidden files. This is done with an option. When we add the -a option to the ls command, we get a listing of all files and directories, including hidden files, as shown in Figure 1.3.


Figure 1.3  Adding the -a option to the ls command.

Taking the example one step further, we can ask the ls command to return a long listing for the files or directories in the current directory with the -l option, as shown in Figure 1.4.


Figure 1.4  Adding the -l option to the ls command.

There are very few Linux commands that don’t have options or arguments of some sort. Chapter 5, which lists all the commands, devotes a lot of space to these options.


Previous Table of Contents Next