UNIX Command

UNIX Command

UNIX Command – Most of the UNIX command names are short, single words in lowercase. The commands are basically programs written in C. Traditionally, UNIX system programs are stored in directories called/bin and/usr/bin, with additional programs usually used only by system administrators in /etc and/usr/etc. Many versions of UNIX also have programs stored in/usr/ucb . There may be other directories containing programs. Users may have their own directories where custom commands in the UNIX system, the following command is entered-
$ type cat
Cat is /bin/cat
When the cat command is entered, the shell searches for the command in the search path.
The search path is stored in an environment variable called PATH. The path is searched in the order, so if there are two commands with the same name, the one that is found first in the path will be executed. The search path isn’t built into the shell; it is specified in the shell setup
$ each $PATH

Internal and external UNIX command

Some commands in UNIX are internal, built into the shell. For example, the cd command is built-in. That is, the shell interprets the command and changes the current directory. On the other hand, cat command is an external program stored in the file/bin/cat.
The shell doesn’t start separate process to run internal commands. External commands require the shell to run a new sub process; this takes some time, especially if the system is busy.

Structure of UNIX command

The basic of structure of a UNIX command is:
Command [options,..] [arguments,”]
Where command is the name of the command and is generally singly character there may be no options or there may be several acting on the same command. Options are generally preceded by a hyphen (-) character. Grouping of option have no consistent rule and some commands allow a list of option with just a single hyphen at the beginning of the list. Some other commands may require a hyphen before each option.
There are some options which allow a value, may be filename, to be given following option. The value may be placed immediately following the option letter or a space may be required between the option letter and the value. This depends on the options The arguments are values upon which the command is to operate. These are very often filenames, and depending on the command there may be several arguments or none.
UNIX being case-sensitive, the exact combination of upper and lower case letters used in a command, option or filename are important.

Flexibility of UNIX command usages

A numbers of commands can be entered in a single command line. The commands are separated by semicolons (;) . When a shell finds a semicolon in the command line, it executes the commands on either side of semicolon separately. The semicolon is this context is called a meta-character because it has a special meaning to the shell.
Long command line can be split and entered in several lines. The shell recognizes an incomplete command and displays a second prompt (>).

Leave a Reply

Your email address will not be published.