Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

Thanks!

share|improve this question

1 Answer 1

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

Your Answer

 
discard

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.