Listing previously entered commands (history command)
Use the history command to list commands that you have previously entered.
The history command is a Korn shell built-in command that lists the last 16 commands entered. The Korn shell saves commands that you entered to a command history file, usually named $HOME/.sh_history. Using this command saves time when you need to repeat a previous command.
By default, the Korn shell saves the text of the last 128 commands for nonroot users and 512 commands for the root user. The history file size (specified by the HISTSIZE environment variable) is not limited, although a very large history file size can cause the Korn shell to start slowly.
history
928 ls
929 mail
930 printenv MAILMSG
931 whereis Mail
932 whatis ls
933 cd /usr/include/sys
934 ls
935 man pg
936 cd
937 ls | pg
938 lscons
939 tty
940 ls *.txt
941 printenv MAILMSG
942 pwd
943 history
The listing first displays the position of the command in the $HOME/.sh_history file followed by the command.
history -5
A
listing similar to the following is displayed: 939 tty
940 ls *.txt
941 printenv MAILMSG
942 pwd
943 history
944 history -5
The history command followed by a number lists all the previous commands entered, starting at that number.
history 938
A
listing similar to the following is displayed: 938 lscons
939 tty
940 ls *.txt
941 printenv MAILMSG
942 pwd
943 history
944 history -5
945 history 938