Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I run the most recent command again from history in AIX Server? And how to edit the most recent command and run it again in AIX?

share|improve this question
up vote 2 down vote accepted

what shell are you using?

if korn?

'r' will run the previous


ctrl-p or up-arrow or '!!'

to edit the command try using fc - it will used the $EDITOR env variable and open up the editor. For example if it's vi then it'll open vi with the command and when you save exit (ZZ or wq) it'll run it.

share|improve this answer
I'm using the Korn shell – jrara Nov 27 '12 at 7:15
How to edit the last statement before running it? – jrara Nov 27 '12 at 7:16
set -o vi for example will give you inline interaction with the command line using vi command mode. That said, ESC invokes the mode and you can use the standard hjkl movement keys as well as many of the other vi motion keys to move around and modify your command. – mattcaffeine Nov 29 '12 at 4:40

With bash, you can try


to replay the last command you used. Don't know if it works with Korn.

share|improve this answer

If you comfortable using vi, the best way is to set your shell editor to vi by running command:

set -o vi


esc-k will give you the last run command

subsequent presses on keys "j" and "k" (both lower case) will take you up and down in the command history.

if you want to edit a line, use keys "h" and "l" (lower case again) to move "left" and "right" respectively. Use "x" to delete character under cursor. Hit "i" to go into insert mode to add characters and words, hit esc again to go back to cursor moving mode. I know it sounds complex and archaic, but if you know vi, these actions come to you like a second nature (and in my opinion, every UNIX sysadmin should learn vi at least in a moderate level)

Having said all of this, you can use the command

set -o emacs

and recall the command history with cursor up/down keys and edit the line with cursor left/right keys. Use backspace and delete keys just like you use them in a DOS prompt. But this requires that you are using a good terminal emulator (PuTTY is fine by the way) and emacs application to be installed properly (most of the time it is fine as it comes with the OS)

I am not sure which one is better for you and which one is more applicable in your case.

Good luck

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.