Super User is a question and answer site for computer enthusiasts and power users. 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

I know we can do a "history" command or use control+R to find the command history in a particular shell session. But is there a way to find out the command history of my last ssh session for example?

I am also curious to know where (in the system) linux saves the command line history, even if it is just for the current shell session.


share|improve this question
up vote 6 down vote accepted

Your history is logged by your shell. Bash, for example, uses the file ~/.bash_history by default. It is also not limited by your current session, but the history is usually persisted beyond that, up to what the environment variables HISTSIZE and HISTFILESIZE allow.

More information on how the history works in bash is available in it's man page, in the section titled HISTORY.

For more thorough recording of command history, you can use process accounting, as explained in answers to this question.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .