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.

Two Putty sessions were opened to a Debian 6 Linux. Log-files led to a full disk. The bash history of the entire shell sessions is missing, and even beyond that (This may be due to a blocked writing-mode, with the last blocks being cut off)

  • Is there a way of recovery or a duplicate history file?
  • Do you have a cron-job running that regularly backups your bash-history?
share|improve this question
    
Its sessions ended then the history is gone. –  Ramhound Jun 11 '13 at 15:43
add comment

1 Answer 1

Unless you have set up a backup yourself I think you're out of luck. I doubt any distros use default settings which back up the history, but without inspecting your system in detail it would be impossible to say for sure.

If the sessions are still running, however, you could try running the history command. I'm pretty sure it simply reads from ~/.bash_history, but maybe it stores that in memory until the next command?

You could also copy the shell output to a file, and grep that to at least recover the last few commands.

Regarding backup, I've personally found that GitHub is a great place for .bash_history. A little excessive for most people, perhaps, but it keeps the common commands always at the ready.

share|improve this answer
    
+1 thanks for the pointer. –  Lo Sauer Jun 11 '13 at 15:04
    
Bash history entries are committed to disk only every so often by default; if you haven't yet closed the session(s) you're interested in, and assuming you haven't done export PROMPT_COMMAND='history -a' or something equally atrocious, then doing history may well get you at least the last hundred or so lines of what would've gone into ~/.bash_history. Can't hurt to try, again assuming the shell or shells in question haven't yet been killed; if they have, I'm afraid you're SOL. –  Aaron Miller Jun 11 '13 at 15:40
    
Also, +1 for the perversity of putting .bash_history under VC... –  Aaron Miller Jun 11 '13 at 15:41
    
@AaronMiller afaikt, it is a command summary. So no curl oAuth tokens and other 'sensitive material'. And yes the session was killed unfortunately. –  Lo Sauer Jun 11 '13 at 15:48
    
@LoSauer Oh, I'm not saying it's a security risk particularly, at least not for anyone who washes his hands after going to the toilet and doesn't include passwords in his command lines -- just that the idea of putting a state file like that under version control strikes me as a bit perverse. (Not that I wouldn't consider doing it, under circumstances which made it useful.) –  Aaron Miller Jun 11 '13 at 15:51
show 1 more comment

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.