GNU and Unix Commands
Objective 1: Work Effectively on the Command Line
The interactive shell and shell variables
A shell provides the command prompt and interprets commands.
A shell variable holds a value that is accessible to shell programs.
PATH
is a shell variable that contains a listing of directories that hold executable programs.Commands must be bash built-ins, found in the
PATH
, or explicitly defined in order to succeed.When shell variables are exported, they become part of the environment.
Entering commands
Commands are comprised of a valid command, with or without one or more options and arguments, followed by a carriage return.
Interactive commands can include looping structures more often used in shell scripts.
Command history, editing, and substitution
Shell sessions can be viewed as a conversation. History, expansion, and editing make that dialog more productive.
Commands can be reissued, modified, and edited. Examples are shown in Table 10-2.
Command substitution allows the result of a command to be placed into a shell variable.
Table 10-2. Shell expansion, editing, and substitution examples
History type |
Examples |
---|---|
Expansion |
|
| |
| |
Editing |
Ctrl-P, previous line |
Ctrl-K, kill to end of line | |
Ctrl-Y, paste (yank) text | |
Substitution |
|
Recursive execution
Many commands contain either a -r or -R option for recursive execution through a directory hierarchy.
The find command is inherently recursive, and is intended to descend through directories ...
Get LPI Linux Certification in a Nutshell, 2nd 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.