The most basic tool provided by the shell is the command interpreter. Specifically, the shell executes utilities (or programs) specified by the user. To execute a utility, you must follow the basic format of command followed by a "-" followed by optional options and arguments as in:
command -options arguments
Right off the bat, you may execute any of the utilities found in "/bin" or "/usr/bin". You can also use the command interpreter to execute any executable utility that you install.
|Another cool way to run commands is to use the backtick character (`). essentially, the backtick surrounding a command means that the shell should execute it. This is most commonly used when more than one command are interacting as you will see later...|
We are going to talk more about all the utilities you have at your disposal in the next couple of days, but for now, lets just work with the "ls" utility used to list the contents of a given directory. This utility demonstrates how "all" commands are executed in general.
As we said, a utility can be run simply by typing its name at the command line as in the following case where we simply type "ls" at the command line: (Notice that the "ls" utility reports that there are three files in this directory)
However, many utilities also take options that modify how the command is executed. For example, consider the -l option for the "ls" command. This option produces a more detailed listing. We will talk more about the meaning of the listing later. Just notice how the option was applied to the comand generically.
|In order to stop a command while it is running, you should press the BREAK or DELETE key. If that does not work, try hitting CNTRL-D or CNTRL-C.|
Finally, many utilities also take arguments. For example, to get a listing of all the files with . extensions, you might use the following: (We will talk more about the "*" argument later. For now, just notice the lack of the Mail directory which appeared in the other listings)
|You can execute several commands on the same comand line by
separating them with a semi-colon such as:
$ ls -l; who; cal; pwd.
Likewise, if you do not want to wait for the command to finish before you continue working, you can request that UNIX performs the command in the background. To do so, you use the "&" character such as:
$(ls > dir.txt)&
Finally, you can keep a job alive even after you logout by using the nohup (no hang up) utility such as:
nohup sort address_book > sorted_addresses &
If you are not sure what arguments or options a command takes you can always use the generic -? or --help, which will give you some hints. the following image shows a help request for the "pwd" command
Of course, the "man" command, that we will discuss later, or a good reference book may be a better resource.