2. Anatomy of a Commmand

Every UNIX command has three parts: a name, options, and zero or more arguments. They all have the following appearance

 commandName -option(s) argument(s)

Notice how the options are preceded by a -. Certain “long–form” options are preceded by a --. In a Mac terminal, all options are preceded by a simple -.

A command always has a name. Grammatically you should think of a command as an imperative sentence. For example, the command passwd means, “Change my password!” You can type this command at the prompt, hit enter, and follow the instructions to change your password any time you wish.

Arguments are supplementary information that is sometimes required and sometimes optional, depending on the command. Grammatically, arguments are nouns: they are things that the command acts upon.

Options are always, well, ... optional. Options modify the basic action of a command and they behave grammatically as adverbs. All familiar features of a graphics-based machine are present in Linux, you will just invoke them with a text command instead of a mouse click. We will go through some examples so you get familiar with all the parts of a Linux command.

Two very basic Linux commands are whoami and hostname. Here is a typical response. These commands give, respectively, your user name and the name of the host you log in to.

Now we run them. We show the results here; your computer will show your login name and your host name, putting to stdout. Here is what they look like on a server.

unix> whoami
morrison
unix> hostname
carbon.ncssm.edu
unix>

Here is their appearance on a PC (A Mac in this instance).

unix> whoami
morrison
unix> hostname
John-Morrisons-MacBook-Pro.local
unix> 

We will next turn to the organization of the file system.