Shells Execute Programs
A command line interface primary job is to run programs. The shell program's job is to present the user with a prompt, parse the command given by the user, and run the program specified. The shell prompt will typically include a
$ for a regular
user or a
# for the root user. Some typical looking prompts may look like:
The very first thing to type at a command prompt is the name of a program. Here is where the command line is difficult for new users. How do I type the name of a program without knowing the names? There are a few common guidelines that most Unix utilities
follow. First, due to the limitations of early input hardward (teletypes), many program names are abbreviations for the action performed. Programs to copy or move files are abbreviated to
mv. Let's try to run a couple
of programs. In your practice terminal, type in the following program names and press enter (do not type the # or $ prompt symbols, just the program name).
The first "word" typed must be the name of a program, but virtually all programs allow (and many require) extra options. The shell will take whatever words are typed after a program name and give them to the program to decide what to do. Let's take a
look at the different types ways we can invoke a program. For example, the
cal command has many command line options that will alter the behavior of the program. Notice how some options can be combined together as well
# cal -y
# cal -w
# cal -wy
Some programs require extra information to do their job. Input the next two commands.
# touch file1.txt
Notice the first command complained about a missing file operand. That's because the touch program requires at least one word after the program name. The touch program updates the time a file was last accessed, or creates the file if one does not exist.
ls command to list out the files in the current directory. Try "touching" more files and listing out the directory contents.
# touch file2.txt file3.txt
To see how to use a program, you can use the
man command to view a program's manual pages. The
man program requires one parameter: the name of the program you want to learn about. Read up on the
ls command and the
different options it can take, then practice running the
ls command in different ways
# man ls
# ls -l
# ls -a # ls -al
Different programs take have different syntax requirements. Oftentimes you will need to get information about a program in order to use it properly. There are three main ways to learn more about a particular program: the
--help option, the
man command, and the
info command. Virtually all programs will have a
man page and a
--help option, but much fewer will have the longer
info file. The
apropos command can find programs
whose man page description contains provided keywords.
# ls --help
# man ls
# info ls # apropos "directory contents"