Specifications
For example, to run the ls command in the current user’s home folder, you could enter
the following at the command line and press Return:
host:~ mariah$ ls
The shell looks through the list of folders in the PATH variable until it nds a program
named ls; in this case, it nds ls in /bin, and runs /bin/ls.
To run a command in the current user’s home folder, precede it with the folder
specier. For example, to run MyCommandLineProg, use the following:
host:~ mariah$ ~/MyCommandLineProg
To open an application, use the open command:
open -a MyProg.app
When entering commands, if you get the message command not found, check your
spelling. Here’s an example:
server:/ mariah$ opne -a TextEdit.app
-bash: opne: command not found
If this error recurs, the command you’re trying to run might not be in your default
search path. You can add the path before the command name:
server:/ mariah$ sudo /System/Library/ServerSetup/serversetup
-getHostname
server.example.com
or change your working folder to the folder that contains the tool:
server:/ mariah$ cd /System/Library/ServerSetup
server:/System/Library/ServerSetup mariah$ sudo ./serversetup
-getHostname
server.example.com
or dene the path for this session and then run the command:
server:/ mariah$ PATH=“$PATH:/System/Library/ServerSetup”
server:/ mariah$ sudo serversetup -getHostname
server.example.com
Terminating Commands
To terminate the currently running command, press Control-C. This keyboard shortcut
sends an abort signal to the command. In most cases this causes the command to
terminate, although commands can install signal handlers to trap this signal and
respond dierently.
14 Chapter 1 Introduction to the Command-Line Environment