Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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?
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.
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.)
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.