Is there a way to see a history of a particular ssh session?
Main Topics
Browse All TopicsI have three four ssh sessions running on my linux system and to know the command history for each ssh session, is this possible?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Your history or someone else's? If you haven't set up process accounting on the box, you can only see when people logged in, not what they did. If you are root, you can pop into their home directory and check out their history file...
Here is some info on Process Accounting:
http://articles.techrepubl
If you want to see your previous commands run on currently existing sessions, you can run the history command.
history
Assuming you are using the bash shell...
The history command will show you the commands that you used in the current session, plus a number of commands from previous sessions, which number is controlled via the environment variables
HISTFILESIZE=500
HISTSIZE=500
Commands run longer than 500 command lines ago are lost. If you don't have access to the shells, that is the ssh sessions are completed or from unknown sources, you will have no way of telling what they have run until they log out, and at that point you have no way of differentiating thier commands from the different shells.
So if you have access to the shells, that is they are from your own box and can look in the window, run the command "history", every command after 500 will have been done in that interactive session. If you do not, you can try to kill the sessions one at a time, and see if their commands get written to the history file.
I like to add this to my .bashrc file so I have a more permanent record of my commands...
PROMPT_COMMAND='echo $(date +%Y.%m.%d-%H:%M:%S)\|$$\|$
HISTFILESIZE=2500
HISTSIZE=2500
export HISTSIZE
export HISTFILESIZE
export PROMPT_COMMAND
Business Accounts
Answer for Membership
by: veedarPosted on 2009-09-17 at 16:18:59ID: 25362021
You can run the "history" command to see your shell history.
009/01/14/ howto-reco rd-typescr ipt- your-s helltermin al-session -activites -in-linux/
Or better take a look at the "script" command it captures all terminal activity.
http://blogs.koolwal.net/2