1

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!

6

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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