This chapter from A Practical Guide to Ubuntu Linux, 4th Edition takes a close look at the shell and explains how to use some of its features. It discusses command-line syntax and describes how the shell processes a command line and initiates execution of a program. This chapter also explains how to redirect input to and output from a command, construct pipelines and filters on the command line, and run a command in the background. The final section covers filename expansion and explains how you can use this feature in your everyday work.

Objectives

List special characters and methods of preventing the shell from interpreting these characters

Describe a simple command

Understand command-line syntax and run commands that include options and arguments

Explain how the shell interprets the command line

Redirect output of a command to a file, overwriting the file or appending to it

Redirect input for a command so it comes from a file

Connect commands using a pipeline

Run commands in the background

Use special characters as wildcards to generate filenames

Explain the difference between a stand-alone utility and a shell builtin

The introduction to the command line on page 125 described some of the advantages of using the command line over a GUI, how to use a terminal emulator, how to correct mistakes on the command line, and how to run some command-line utilities. This chapter takes a close look at the shell and explains how to use some of its features. It discusses command-line syntax and describes how the shell processes a command line and initiates execution of a program. This chapter also explains how to redirect input to and output from a command, construct pipelines and filters on the command line, and run a command in the background. The final section covers filename expansion and explains how you can use this feature in your everyday work.

The exact wording of the shell output differs from shell to shell: What the shell you are using displays might differ slightly from what appears in this book. Refer to Chapter 9 for more information on bash (the default shell under Ubuntu) and to Chapter 28 for information on writing and executing bash shell scripts.