Specifications

26 Chapter 1 Executing Commands
Correcting Typing Errors
You can use the Left and Right Arrow keys to correct typing errors before you press
Return to execute a command.
To correct a typing error:
1 Press Left Arrow or Right Arrow to skip over parts of the command you don’t want to
change.
2 Press Delete to remove characters.
3 Enter regular characters to insert them.
4 Press Return to execute the command.
To ignore what you entered and start again, press Control–U.
Repeating Commands
To repeat a command, press Up Arrow until you see the command, then make
modifications and press Return.
Including Paths Using Drag and Drop
To include a fully qualified filename or folder path in a command, you can drag and
drop the folder or file from a Finder window into the Terminal window.
Searching for Text in a File
To locate a string within a file, use the grep tool. The grep tool searches the named
input files for lines containing a match to the given pattern. By default, grep prints the
matching lines.
To search for a unique string in a file:
$ grep
search_string
filename
Replace search_string with the the string to search for and filename with the name of
the file you want to search through.
Commands Requiring Root Privileges
Many commands used to manage a server must be executed by the root user. If you
get a message such as permission denied, the command probably requires root
privileges.
However, when logged in as a root user, be careful: you have sufficient privileges to
make changes that can cause your server to stop working.
Important: Don’t execute commands as the root user unless you know what you’re
doing. Instead, log in as an administrator user and selectively use sudo, which gives you
root user privileges to execute one command. This helps you avoid making unintended
changes when running other commands.