0

How to get bash history of already running session?

1.) I was thrown out of my server because of a cable fault.
2.) I logged in again using a new session. History of the other session is not accessible.
2.) I want the bash history from the other session.

Any ideas if this can be accomplished? (I know of methods how to change this for the future)

2

If you send SIGHUP or SIGTERM to your previous bash session, it should terminate and write out its history. Once that's done, start a new bash session (or just look in your ~/.bash_history file) to access the command history.

So in summary, use something like ps -fu <your_username> | grep bash to find the PID of your previous bash session, then kill <bash_pid>.

Your Answer

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