728x90

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

$HOME/.hushlogin

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.


$HOME/.profile

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

VariablesWhat it does
PRINTER=mylaserControls 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=3600Will 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=1000Controls 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 noclobberWon'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 ignoreeofDisables ^D to logout; you must type exit to exit the shell
set -o viEnable 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.
-xcase 
won't allow you to login unless in lower case.


alias, unalias

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

ExamplesWhat it does
aliasLists the aliases that are currently defined.
alias "dir=ls"Creates an alias. dir will output the same contents as the lscommand.
unalias nameRemoves an alias. unalias dir


exec

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.

ExamplesWhat it does
exec /usr/bin/smitWill execute the System Management Interface Tool (SMIT) program - overlaying the current shell program
Changing standard input (stdin)
exec <FileNameForInputReassigns standard input from the keyboard to a file
exec </dev/ttyReassigns standard input back to the keyboard
exec <&-Closes standard input
exec </dev/nullAssociate standard input to null device
Changing standard output (stdout)
exec >WriteToFileNameReassigns standard output from your terminal display to a file
exec >/dev/ttyReassigns stardard output back to your terminal
exec >&-Closes standard output
exec >/dev/nullAssociate standard output to null device


$HOME/.sh_history

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


history

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

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


kill

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.

ExamplesWhat it does
kill -9 5344Will 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 -lLists 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 3901Suspends 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 3901Resumes the suspended process whose PID is 3901


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.

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


set, unset

Set positional parameters for the current shell.

ExamplesWhat it does
set `date`; echo $1 $2 $3 $4 $5 $6Thu Nov 14 20:12:47 CST 2002
echo $6Displays the year - 2002
set -oDisplays current settings for the set command.
set -o noclobber 
set +o noclobber
Won't allow a user to overwrite a file with the same file name. Use -oto 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 ENVUsed to undefine a system variable. Removes the system variable ENV from your user environment



http://www.ahinc.com/aix/kornsh.htm


728x90

'*nix' 카테고리의 다른 글

Determining how many CPUs you have on HP-UX  (0) 2011.11.20
cpio: 0511-903 Out of phase!  (0) 2011.11.01
dummy file 생성방법  (0) 2011.03.11
디스크 사용량 확인  (0) 2011.03.11
[linux] 메모리 상태 체크 (free)  (0) 2011.03.11

+ Recent posts