This chapter shows you how to begin using your Linux system. It shows you how to boot your system, log in, issue commands, log out, and shut down your system. It also explains how to use the man command, which provides help on using other commands. The chapter describes how Linux organizes data as filesystems, directories, and files and how you can work with removable media, such as diskettes. It describes how to query the status of your system. And, finally, it explains how to use pico, a simple text editor.
The cycle of Linux system use is similar, even though you perform the tasks somewhat differently.
First, you must prepare your system for booting. If your system is running, you must shut it down by following the proper procedure for shutting down the operating system that’s active. For example, if you’re running Microsoft Windows, click Start → Shut Down and select the Shut Down option in the Shut Down dialog box. Press OK to begin the system shutdown. After a few seconds, Windows displays a screen telling you that it’s safe to turn off power to your system. Turn off the power or, if your system automatically powers down, wait a few seconds until the system powers itself down.
Next, you must set your system to boot from the desired device. To boot your system from its hard drive, remove any floppy diskette from your system’s floppy drive. To boot your system from a floppy diskette, insert your Linux boot diskette into your system’s floppy drive.
Now, you’re ready to boot your system. Switch your
system on (or press your system’s reset button, if your
system is powered on) and watch as it performs its self
test. Shortly thereafter, you should see a
boot: prompt on the system’s monitor. If
you like, you can list the available boot configurations
stored on the boot device by pressing Tab. To boot the
system, type the name of the desired configuration and press
Enter, or simply press Enter to boot using the default
Once it loads, Linux begins probing your system and its devices, printing status information on your system’s monitor. This status information is helpful if your system fails to boot properly, because it discloses the point in the boot process where the problem occurred.
Red Hat Linux release 6.0 (Hedwig) Kernel 2.2.5 on an i586 login:
Before you can use the system, you must identify
yourself by logging in. The install program created a
special user named
root; by identifying
yourself as the
root user, you can gain
access to the system. Normally, you use the
root userid only when performing system
administration tasks, because the
user has special capabilities that other users
lack. However, because
root is currently
the only userid that has access to your system, you must log
root. Later, you’ll add one or more
To log on, type
root and press
Enter. The system prompts you
for the password associated with the
userid. Type the password you established during the
installation process and press Enter. To prevent anyone nearby from
learning your password, Linux does not display it as you
type. If you suspect you’ve typed it incorrectly, simply
press Enter and start over;
or press Backspace once (or
more) for each character you’ve entered and then re-enter
it. If you type the userid or password incorrectly, Linux
displays the message “login incorrect” and prompts you to
Like other members of the Unix family, the Linux
operating system is case sensitive. Be sure to type the
root just as it appears, using all
lowercase characters. Similarly, you must type the password
in exactly the same way you entered it in the Root Password
dialog box during system installation.
The component of Linux that interprets and executes
commands is called the shell. Linux
supports a variety of different shells, but the most popular
bash shell. This chapter presents
the basics of using the
you’ll learn more about the shell in Chapter 13.
bash shell presents the
user with a command-line interface (CLI). CLIs are familiar
to Windows users who have worked in the MS-DOS window, and
indeed the Microsoft Windows MS-DOS Prompt window is a kind
of command-line shell for Windows. The Linux
bash shell works much like the MS-DOS
Prompt window. You type text commands and the system
responds by displaying text replies. As your first Linux
command, type w and press Enter. Your
screen should look something like this:
w11:12am up 6 min, 1 user, load average: 0.00, 0.08, 0.05 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root tty1 11:13am 0.00s 0.20s 0.11s -bash
The w command tells Linux to display
the system status and a list of all system users. In the
example, the output of the command tells you that it’s now
11:12 a.m., that the system has been up for 6 minutes, and
that only one user—
currently logged in. Notice that the command output is very
terse, packing much information into a few lines. Such
output is typical of Linux commands. At first, you may find
Linux output cryptic and difficult to read, but over time
you’ll grow to appreciate the efficiency with which Linux
Linux provides many commands besides the w command; so many that you may despair of learning and recalling them. Actually, the number of commands you’ll use regularly is fairly small. Soon, these will become second nature to you.
Now try a second command, the date command:
dateTue Feb 23 11:15:20 PST 1999
If you find working with MS-DOS distasteful or intimidating, you may not immediately enjoy working with the Linux command line. However, give yourself some time to adjust. The Linux command line has several features that make it easier to use, and more powerful, than MS-DOS. If, after working with the Linux command line for several days, you don’t find yourself at home, don’t despair. Linux provides a graphical user interface in addition to its command-line interface. You’ll learn about the graphical user interface in Chapter 6.
datbash: dat: command not found
In such a case, carefully check the spelling of the command and try again. If you notice an error before pressing Enter, you can use the Backspace key to return to the point of the error and then type the correct characters.
Just as a web browser keeps track of recently visited sites, Linux’s BASH shell keeps track of recently issued commands. This list is called the history list, and you can scroll back through it using the Up arrow key, or back down using the Down arrow key, just as you would with the Back and Forward buttons on a web browser. In fact, the history list provides several powerful ways to remember and reuse frequently issued commands, as we’ll see in Chapter 13.
The Up and Down arrow keys let you scroll through a list of commands recently issued. This feature is handy when you want to repeat a command. Simply use the Up arrow key to find the command and press Enter to re-execute it. You can also use this feature when you want to issue a command similar to one you recently issued. Use the Up arrow key to find the original command. Then, use the Left and Right arrow keys to position the cursor and make whatever changes to the command you like. Finally, press Enter to execute the command.
In Microsoft Windows, you can have several MS-DOS Prompt
windows simultaneously active. Although the
bash shell doesn’t have a graphical user
interface, you can nevertheless work with several instances
of the shell, by using Linux virtual consoles. Linux
provides six virtual consoles; you can use special
keystrokes to switch between them. The keystroke Alt-F
n is the number of a virtual console
(1-6), causes Linux to display virtual console
n. For example, you can display virtual
console 2 by typing Alt-F2. You can view only a single
console at a time, but you can switch rapidly between
consoles by using the appropriate keystroke.
Virtual consoles are handy when you’ve started a time-consuming task and want to be able to perform an unrelated task while the original task is working. You’ll also find them useful after you’ve established several userids on your system, because you can log on as one userid on one virtual console while you’re logged on as another userid on a different console.
Virtual consoles have a screen saver feature like that found on Microsoft Windows. If a virtual console is inactive for an extended period, Linux blanks the monitor screen. To restore the screen without disturbing its contents, simply press the Shift key.
When you’re done using a virtual console, you should log out by typing the command exit and pressing Enter. When you log out, the system frees memory and other resources that were allocated when you logged in, making those resources available to other users.
When the system logs you out, it immediately displays a login prompt. If you change your mind and want to access the system, you can login simply by supplying your userid and password.
You shouldn’t turn off power to a computer while it’s running Linux; instead, you should shut down the operating system and then turn off power. To shut down a Linux system, you use the shutdown command, which resides in a directory named /sbin:
/sbin/shutdown -h now
Don’t type the prompt, which automatically appears on
the command line. Only the
root user can
issue the shutdown command. If you want
to restart a Linux system, you can use an alternative form
of the shutdown command:
/sbin/shutdown -r now
Or, even more conveniently, you can use the familiar MS-DOS “three-finger salute”: Ctrl-Alt-Del, which simply issues a shutdown command on your behalf.
When you shut down a system, Linux automatically logs off all users, terminates all running programs, and closes all open files. Before shutting down a system, you should check each virtual console to determine if an important operation is in progress. If so, you should delay shutting the system down until the operation completes.