<<

COMMANDS

The basic commands in Unix are divided into two broad categories:

INTERNAL COMMANDS The shell has a number of built-in commands that are known as internal commands. Some of these, such as and , do not generate a process, and are directly executed by the shell. These commands are built into the shell and do not exist as separate files.

EXTERNAL COMMANDS External commands are Unix utilities and programs such as and . These commands exist in the form of individual files and are distributed in different directories. The commonly used user commands are placed in the /bin directory, and the commands that are usually used only by system administrators are placed in the /etc directory. date: Displaying system date and This command displays the system date and time. Syntax: $date

Sunday 12 February 2012 05:32:20 AM IST

: Displaying The cal command is used to display the calendar of a specified month and year. Syntax: $cal month year

: Who is online The who command displays all users who are currently logged in to the system. It returns the user’s name (ID), terminal, and the time he or she logged in.

Syntax: $who [-u] [-H] [am i]

: The command tty is know the terminal number

Syntax: $ tty

stty: The command stty is used to display the settting of the terminal

Syntax: $ stty

: Displaying information about current system The uname command displays information about the current system: hardware platform, name of the , and release level. Syntax: $uname [-n] [-r] [-S system_name]

-r this option will give the version number of OS -n this option will display the name of the machine

: Print working directory pwd stands for print working directory. It displays the absolute path name of our working directory. Syntax: $pwd

finger: Online user’s details The finger command displays information of users who are logged in. Compared to the who command, the finger command displays elaborate information pertaining to these users. Apart from the login name, terminal name, date, and time of the logged-in users, the command also displays other information such as the user’s home directory, phone number, login shell, and status, among others.

Syntax: $finger

echo: Displaying messages and results The echo command is used to display messages and the results of computation on the screen. Syntax: $echo [-n] message/variables

-n It suppresses a new line after the echoed message or variables. The output of the next echo statement will appear on the current line. This option is usually used while scripting.

Example echo "Hello World"

bc: Basic calculator The bc command activates a basic calculator that is meant for doing simple calculations. The command is executed in the interactive mode, that is, we enter the expression we wish to compute on the command line, and the command immediately displays the result on pressing the Enter key. To quit the interactive mode, we either press Ctrl-d or quit followed by the Enter key. Syntax: $bc [-l]

-l defines the math functions and initializes the scale to 20, instead of the default zero.

We can use all operators including +, -, *, /, %, ^, where % represents the mod operator, that is, it returns the remainder and ^ represents ‘to the power’.

: Display a history of recently used commands – $ history all commands in the history – $ history 10 last 10 – $ history -r 10 reverse order – $!! repeat last command