unix command history

is there any way to determine the last command entered on a unix machine???

Thanx

Hope you are using ksh ?

use,

Esc + k

combination

The command line history is specific for a user and for a shell. This is basically how bash works:

When You start a shell (for example at login or when starting an xterm) a file with recorded command line history is read from a file called $HOME/.bash_history. If You do something in this shell and then start another one, the new one will not yet be aware of what has been done in the other one, that is, they will have the same "history" to start with. When You close the first shell (log out or close an xterm), its "additions" is added to the .bash_history. When You close the second shell, IT'S additions will be added to the file. Next time You start a shell, You will have both "additions" available in history.

So, You can take a look in the history file.
Most shells have the history command which will give You a list of historical commands. This can be big or small, and handled differently on different shells. Size, duplicates and other things can be configured.

Some shells support using up and down arrow keys to browse through the the current shells history, which then can be edited and reused.

A lot could be said about this. Look in the bash man page and search for HISTORY.

But maybe You meant what command or program in general has been executed? Then one must rely on whether the program has logged anything with time stamp, in for example some of the /var/log/ files or its own log files.

Or search the web! :wink:

/Lakris

#history is a command to see the previously used commands list.