O'Reilly logo

Running Linux, Fourth Edition by Lar Kaufman, Terry Dawson, Matthias Kalle Dalheimer, Matt Welsh

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4. Basic Unix Commands and Concepts

If you’ve come to Linux from Windows or another non-Unix operating system, you have a steep learning curve ahead of you. We might as well be candid on this point. Unix is a world all its own.

In this chapter, we’re going to introduce the rudiments of Unix for those readers who have never had exposure to this operating system. If you are coming from Microsoft Windows or other environments, the information in this chapter will be absolutely vital to you. Unlike other operating systems, Unix is not at all intuitive. Many of the commands have seemingly odd names or syntax, the reasons for which usually date back many years to the early days of this system. And, although many of the commands may appear to be similar to their counterparts in the Windows command-line interpreter, there are important differences.

Dozens of other books cover basic Unix usage. You should be able to go to the computer section of any chain bookstore and find at least several of them on the shelf. (A few we like are listed in the Bibliography.) However, most of these books cover Unix from the point of view of someone sitting down at a workstation or terminal connected to a large mainframe, not someone who is running his own Unix system on a personal computer. A popular introduction to Unix usage that also covers Linux is Learning the Unix Operating System by Grace Todino, John Strang, and Jerry Peek, published by O’Reilly.

Also, these books often dwell upon the more mundane aspects of Unix: boring text-manipulation commands, such as awk, tr, and sed, most of which you will never need unless you start doing some serious Unix trickery. In fact, many Unix books talk about the original ed line editor, which has long been made obsolete by vi and Emacs. Therefore, although many of the Unix books available today contain a great deal of useful information, many of them contain pages upon pages of humdrum material you couldn’t probably care less about at this point.

Instead of getting into the dark mesh of text processing, shell syntax, and other issues, in this chapter we strive to cover the basic commands needed to get you up to speed with the system if you’re coming from a non-Unix environment. This chapter is far from complete; a real beginner’s Unix tutorial would take an entire book. It’s our hope that this chapter will give you enough to keep you going in your adventures with Linux, and that you’ll invest in a good Unix book once you have a need to do so. We’ll give you enough Unix background to make your terminal usable, keep track of jobs, and enter essential commands.

Chapter 5 contains material on system administration and maintenance. This is by far the most important chapter for anyone running his own Linux system. If you are completely new to Unix, the material found in Chapter 5 should be easy to follow once you’ve completed the tutorial here.

One big job we don’t cover in this chapter is how to edit files. It’s one of the first things you need to learn on any operating system. The two most popular editors for Linux, vi and Emacs, are discussed at the beginning of Chapter 9.

Logging In

Let’s assume that your installation went completely smoothly, and you are facing the following prompt on your screen:

Linux login:

Many Linux users are not so lucky; they have to perform some heavy tinkering when the system is still in a raw state or in single-user mode. But for now, we’ll talk about logging into a functioning Linux system.

Logging in, of course, distinguishes one user from another. It lets several people work on the same system at once and makes sure that you are the only person to have access to your files.

You may have installed Linux at home and are thinking right now, “Big deal. No one else shares this system with me, and I’d just as soon not have to log in.” But logging in under your personal account also provides a certain degree of protection: your account won’t have the ability to destroy or remove important system files. The system administration account (covered in the next chapter) is used for such touchy matters.

If you connect your computer to the Internet, even via a modem, make sure you set nontrivial passwords on all your accounts. Use punctuation and strings that don’t represent real words or names.

Note that some distributions install a so-called graphical login manager right away, so you might not be greeted by the somewhat arcane login: prompt in white letters on black background, but with a fancy graphical login screen, possibly even presenting you with the user accounts available on your system as well as different modes to log into. The basic login procedure is the same as described here, however; you still type your username and password.

You were probably asked to set up a login account for yourself when you installed Linux. If you have such an account, type the name you chose at the Linux login: prompt. If you don’t have an account yet, type root because that account is certain to exist. Some distributions may also set up an account called install or some other name for fooling around when you first install the system.

After you choose your account, you see:

Password:

and you need to enter the correct password. The terminal turns off the normal echoing of characters you enter for this operation so that people looking at the screen cannot read your password. If the prompt does not appear, you should add a password to protect yourself from other people’s tampering; we’ll go into this later.

By the way, both the name and the password are case-sensitive. Make sure the Caps Lock key is not set because typing ROOT instead of root will not work.

When you have successfully logged in, you will see a prompt. If you’re root, this may be a simple:

#

For other users, the prompt is usually a dollar sign ($). The prompt may also contain the name you assigned to your system or the directory you’re in currently. Whatever appears here, you are now ready to enter commands. We say that you are at the “shell level” here and that the prompt you see is the “shell prompt.” This is because you are running a program called the shell that handles your commands. Right now we can ignore the shell, but later in this chapter we’ll find that it does a number of useful things for us.

As we show commands in this chapter, we’ll show the prompt simply as $. So if you see:

$ pwd

it means that the shell prints $ and that pwd is what you’re supposed to enter.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required