The Linux command line is one of the most powerful tools available for computer system administration and maintenance. The command line is also known as the terminal, shell, the console, the command prompt, and the command-line interface (CLI). For the purposes of this chapter and the next, these terms are interchangeable, although fine-grained differences do exist between them.

The command line is an efficient way to perform complex tasks accurately and much more easily than it would seem at a first glance. Knowledge of the commands available to you and also how to string them together will make using Ubuntu even easier for many tasks. Many of the commands were created by the GNU Project as free software analogs to previously existing proprietary UNIX commands. If you are interested, you can learn more about the GNU Project at www.gnu.org/gnu/thegnuproject.html.

This chapter looks at some of the basic commands that you need to know to be productive at the command line. You will find out how to get to the command line and learn some of the commands used to navigate the file system and perform basic operations with files, directories, and users. This chapter does not give comprehensive coverage of all the commands discussed, but only enough to get you started. Chapter 11, “Command-Line Master Class,” advances the subject further while expanding on some of the commands from this chapter. The skills you learn in this chapter will help you get started using the command line with confidence.

What Is the Command Line?

If you spend any amount of time with experienced Linux users, you will hear them mention the command line. Some, especially those who have begun their journey in the Linux world using distributions, like Ubuntu, that make it easy to complete many tasks using a graphical user interface (GUI), may speak with trepidation about the mysteries of the text interface. Others will either praise its power or comment about doing something via the command line as if it is the most natural and obvious way to complete a task.

It is not necessary for you to embrace either extreme. You may develop an affinity for the command line when performing some tasks and prefer the GUI for others. This is where most users end up today. Some may say that you will never need to access the command line because Ubuntu offers a slew of graphical tools that enable you to configure most things on your system. Although the premise may be true most of the time, there are some good reasons to acquire a fundamental level of comfort with the command line that you should consider before embracing that view.

Sometimes things go wrong, and you may not have the luxury of a graphical interface to work with. In these situations, a fundamental understanding of the command line and its uses can be a real lifesaver. Also, some tasks end up being far easier and faster to accomplish from the command line. More important, though, you will be able to make your way around a command-line-based system, which you will encounter if you ever work with a Linux server because most Linux servers have no GUI and all administration is done using a command-line interface.

NOTE

Don’t be tempted to skip over this chapter as irrelevant. You should take the time to work through the chapter and ensure that you are comfortable with the command line before moving on. Doing so will benefit you greatly for years to come.

Initially, some may be tempted to think of the command line as the product of some sort of black and arcane art, and in some ways, it can appear to be extremely difficult and complicated to use. However, with a little perseverance, by the end of this chapter, you will start to feel comfortable using the command line and you’ll be ready to move on to Chapter 11.

This chapter introduces you to commands that enable you to perform the following:

Routine tasks—Logging in and out, changing passwords, and listing and navigating file directories.

Basic file management—Creating files and folders, copying or moving them around the file system, and renaming and deleting them.

Basic system management—Shutting down or rebooting, changing file permissions, and reading man pages, which are entries for commands included as files already on your computer in a standardized manual format

The information in this chapter is valuable for individual users or system administrators who are new to Linux and are learning to use the command line for the first time.

TIP

Those of you who have used a computer for many years will probably have come into contact with MS-DOS, in which case being presented with a black screen will fill you with a sense of nostalgia. Don’t get too comfy; the command line in Linux is different from (and actually more powerful than) its distant MS-DOS cousin. Even cooler is that whereas MS-DOS skills are transferable only to other MS-DOS environments, the skills that you learn at the Linux command line can be transferred easily to other UNIX and UNIX-like operating systems, such as Solaris, OpenBSD, FreeBSD, and even Mac OS X, which provides access to the terminal.