Working with Long Commands

As you become used to the command line, you should find some shortcuts to ease your typing chores. In this section, I show you some features of the bash shell designed to make your life on the command line as pleasant as possible. These features include command-line completion, editing, and using the history of previously entered commands.

Asking Linux to complete a command or filename for you

Considering that you do much more typing on the command line in Linux than you may normally do in a GUI environment, a feature that provides typing shortcuts wherever possible is great. Command completion is a function of the shell that completes filename and system commands.

The capability of the Linux file system to deal with practically unlimited sizes of filenames means that many filenames can become huge. Typing these long filenames can become cumbersome. Fortunately, with command completion, typing a command or a long filename is short work.

You may want to use command completion in two situations: to enter a command or to complete a filename.

Completing a command

Suppose that you want to type a command, but you can remember only that it begins with the letters up and is supposed to return the length of time that has passed since the system was rebooted. Type up at the command prompt and then press Tab:

 [dee@catherine dee]$ up[TAB]                                        

One of two things happens:

If only one matching command is in the search path (directory locations for searching for programs; ...

Get Linux® For Dummies®, 8th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.