Does Linux save the history of executed commands

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!

Vendetta

Posted 2012-07-31T19:28:23.350

Reputation: 1 571

Answers

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.

Daniel Beck

Posted 2012-07-31T19:28:23.350

Reputation: 98 421