Shell Commands

Korn shell

The Korn shell is a command interpreter that allows an end user to type in commands to communicate to the AIX system. By default, when a user logins, a shell process is started The default AIX shell is /usr/bin/ksh.

A ‘‘ is prefixed to the name of the ksh program to indicate that this shell initially read the contents of the files /etc/environment, /etc/profile, and $HOME/.profile.

  • /etc/environment specifies the basic environment for all processes
  • /etc/profile specifies variables to be added to the environment by the shell
  • $HOME/.profile specifies variables specific to user to be added to the environment by the shell

Other available shells are…

  • /bin/bsh the Bourne shell
  • /bin/csh the C-shell
  • /bin/sh the Standard shell

top of page


If the ./hushlogin file exists, it will suppress the displaying of the /etc/motd file (message of the day file) and the message for unsuccessful login attempts for that user account.

top of page

The .profile file is used to personalize a user’s account and/or sets the environment$HOME/.profile the user will operate under. The following table represents some examples of settings that can be set in the .profile file.

Variables What it does
PRINTER=mylaser Controls default printer. When you use the lp command with no additional flags to specify which queue to print to, by default it will go to the printer queue named after the equal sign.
TMOUT=3600 Will cause an automatic log off after 60 minutes (3600 seconds) if no keyboard activity encountered or no output is generated to the display after the timeout period has expired. There is a 60 second pause before the ksh is exited.
ESCDELAY=1000 Controls the amount of time permitted between the ESCape character and any other components of an ESCape sequence. The AIX Extended Curses library has a built-in timeout which sets the maximum amount of time permissible between the receipt of the ESC character and the second character of the escape sequence.
set -o noclobber Won’t allow you to overwrite a file with the redirection symbol (eg., cat junk > goodstuff).To overwrite the noclobber option when noclobber is enabled, type ‘>|‘ when redirecting output (eg., cat smit.log >| smit.bck).
set -o ignoreeof Disables ^D to logout; you must type exit to exit the shell
set -o vi Enable command line editing/playback using vi commands
stty -olcuc -iuclc -xcase -olcuc maps lower case to upper case on output.
-iuclc=maps upper case to lower case on input.
won’t allow you to login unless in lower case.

top of page

alias, unalias

Assign a name or an abbreviated name that makes sense or is shorter for a command.

Examples What it does
alias Lists the aliases that are currently defined.
alias “dir=ls” Creates an alias. dir will output the same contents as the ls command.
unalias name Removes an alias. unalias dir

top of page


Executes the command line directly without creating a new process (PID) (current shell is overlaid with command specified on the command line). When the command has finished or is terminated, control is returned to the init process, thereby logging off the user. Typically you will see this command used as the last entry in the $HOME/.profile.

Examples What it does
exec /usr/bin/smit Will execute the System Management Interface Tool (SMIT) program – overlaying the current shell program
Changing standard input (stdin)
exec <FileNameForInput Reassigns standard input from the keyboard to a file
exec </dev/tty Reassigns standard input back to the keyboard
exec <&- Closes standard input
exec </dev/null Associate standard input to null device
Changing standard output (stdout)
exec >WriteToFileName Reassigns standard output from your terminal display to a file
exec >/dev/tty Reassigns stardard output back to your terminal
exec >&- Closes standard output
exec >/dev/null Associate standard output to null device

top of page


Contains the history of user commands executed on the command line for each login session.

top of page


List the last 16 commands executed from the command line. (Uses .sh_history)

Examples What it does
history ! 310
Re-executes the item labled 310 in the .sh_history file
-25 List the last 25 commands executed from the command line. Default number of commands listed is 16.
r vi Re-executes the latest ‘vi’ session stored in the .sh_history file

top of page


Sends a signal to a running process to inform it to do something. Typically you use the signal KILL to terminate or suspend a process.

Examples What it does
kill -9 5344 Will terminate the process with a process id (PID) of 5344. A signal value of -9 means that the signal can’t be caught by the application but is intercepted by AIX to terminate the process in question.
kill -l Lists valid signals to use with the kill command.
kill – Easy way to terminate all processes running in the system EXCEPT your current shell and the /etc/init process.
kill -STOP 3901 Suspends the PID 3901. Execute the ps -elf|grep 3901 command and the status field (marked ‘S’) will have a ‘T’, meaning the process is suspended..
kill -CONT 3901 Resumes the suspended process whose PID is 3901

top of page

process control

Pressing ^Z will suspend a process. To unsuspend a process, use the fg command to bring that process to the foreground again or to leave the process running in the background.

Examples What it does
^Z Will suspend the current PID. Example output: [1] + 8193 Stopped
jobs -l List all current jobs suspended
fg 3934 Will bring suspended job PID 3934 to the foreground. If only one command is listed when jobs -l is executed, you only need to type fg to bring the only suspended process back to the foreground.
4011 Will run the suspended job with a PID of 4011 in the background now

top of page

set, unset

Set positional parameters for the current shell.

Examples What it does
set `date`; echo $1 $2
$3 $4 $5 $6
Thu Nov 14 20:12:47 CST 2002
echo $6 Displays the year – 2002
set -o Displays current settings for the set command.
set -o noclobberset +o noclobber Won’t allow a user to overwrite a file with the same file name. Use -o to turn on or +o to turn off
set -o vi
set +o vi
Enable users to use ‘vi’ commands to manipulate command line entry. Use -o to turn on or +o to turn off
set o xtrace
set +o xtrace
Displays commands and their arguments as they are executed. Normally, you would place the ‘set -x’ command at the beginning of a script file.
unset ENV Used to undefine a system variable. Removes the system variable ENV from your user environment

top of page