LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-11-2007, 04:05 PM   #1
WingnutOne
Member
 
Registered: Sep 2007
Location: Kansas City
Distribution: Mixed, mostly RH / Fedora
Posts: 76

Rep: Reputation: 16
Question BASH shell temporary history


When you close a BASH shell, it writes the command history from that session to your $HISTFILE. Where does the shell keep the temporary command history list while the shell is still open?

Thanks!
 
Old 09-11-2007, 04:51 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
In memory?
 
Old 09-12-2007, 09:57 AM   #3
WingnutOne
Member
 
Registered: Sep 2007
Location: Kansas City
Distribution: Mixed, mostly RH / Fedora
Posts: 76

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by unSpawn View Post
In memory?
If it is in memory, would it have a filename that could be accessed directly?

(Should I put this question somewhere other than the 'Newbie' forum?)
 
Old 09-12-2007, 10:09 AM   #4
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
It is not stored in a file until written to .bash_history.
 
Old 09-12-2007, 03:15 PM   #5
WingnutOne
Member
 
Registered: Sep 2007
Location: Kansas City
Distribution: Mixed, mostly RH / Fedora
Posts: 76

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by Matir View Post
It is not stored in a file until written to .bash_history.
Maybe I'm showing my newbie-ness here, but I thought everything in a Linux/Unix system existed as a "file".
Whether it's a file or not, is there any way to directly watch for additions to the recent command history list?
 
Old 09-12-2007, 03:23 PM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Maybe tell us why you would want that?
 
Old 09-12-2007, 04:01 PM   #7
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
The concept that "everything is a file" might be a bit too broad. In a way it's true: these values are stored in memory, and the entire system memory is accessible as a virtual file in /proc/mem. So I guess you could search through there.
 
Old 09-12-2007, 04:02 PM   #8
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Or, of course, you could just type history and see the entries.
 
Old 09-14-2007, 11:25 AM   #9
WingnutOne
Member
 
Registered: Sep 2007
Location: Kansas City
Distribution: Mixed, mostly RH / Fedora
Posts: 76

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by unSpawn View Post
Maybe tell us why you would want that?
I'm one of several admins on a system which constantly has multiple root login shells open. Occasionally, commands issued by different admins working on similar things will cause unexpected problems which we then have to troubleshoot. This job would be easier if we can see all of the commands that were issued, and the order in which they were issued. It would also be nice - though usually less critical - to be able to retain the command history from a shell that locked up, died, or lost it's connection to the host and wasn't able to add it's recent commands list to the permanent $HISTFILE.
I want to create a command history file that logs commands in from each currently open session "on the fly", so that they appear in the order in which they were issued without having to close out all of the sessions first. The only way I've thought of to do this is to set up a function (something like a 'tail -f') that watches for new additions to each shell's temporary command history and drops them all into a shared file.

(We already have the history file being populated with date/time stamps, courtesy of a suggestion from rjwilmsi on another thread.)
 
Old 09-15-2007, 12:00 PM   #10
makyo
Member
 
Registered: Aug 2006
Location: Saint Paul, MN, USA
Distribution: {Free,Open}BSD, CentOS, Debian, Fedora, Solaris, SuSE
Posts: 735

Rep: Reputation: 76
Hi.

Long ago, I often used lastcomm on SunOS to tabulate command use. On some distributions, this appears to be part of package acct. On one BSD system that I use, however, the accounting is either disabled or normal users cannot use the file:
Code:
% lastcomm | less
lastcomm: could not open /var/account/acct: Permission denied
I don't know whether the commands issued are added in real-time.

Still, it might be useful to look into ... cheers, makyo
 
Old 09-16-2007, 01:37 AM   #11
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
How about using the 'script' cmd/utility to record everything: http://www.linux.com/articles/53729
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Temporary storage of password in shell script ansbaradigeidfran Programming 9 10-25-2006 09:03 AM
need someone to look into this bash history bytez Linux - General 7 10-16-2006 10:26 PM
bash history jasonnth Linux - Software 7 08-08-2006 01:35 AM
Shell History paraiso Linux - General 3 07-27-2006 04:17 AM
LXer: CLI Magic: Using command history in the bash shell LXer Syndicated Linux News 0 07-03-2006 12:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration