[SOLVED] Used CLI commands saving for future reference.

If none of the more specific forums is the right place to ask

[SOLVED] Used CLI commands saving for future reference.

Postby edbarx » 2017-11-04 12:41

Since my wetware is getting sluggish to remember past CLI commands accurately, and Linux keeps only the last couple of thousand commands without removing redundances, I was thinking about the possibility of a package existing that efficiently keeps a lean record of such commands.

So, in effect such a package should look into .bash_history and similarly used files to save a list of all used commands without unnecessary repetitions.
Last edited by edbarx on 2017-11-08 17:42, edited 1 time in total.
Debian == { > 30, 000 packages }; Debian != systemd
The worst infection of all, is a false sense of security!
It is hard to get away from CLI tools.
User avatar
edbarx
 
Posts: 5388
Joined: 2007-07-18 06:19
Location: 35° 50 N, 14 º 35 E

Re: Used CLI commands saving for future reference.

Postby debiman » 2017-11-04 12:51

edbarx wrote:Linux keeps only the last couple of thousand commands without removing redundances

bash history settings are adjustable.
my history is HUGE, and it makes me happy :D
relevant settings in .bashrc:
Code: Select all
HISTSIZE=50000
HISTFILESIZE=2000000
# unix.stackexchange.com/a/18443
# history: erase duplicates...
HISTCONTROL=ignoredups:erasedups
shopt -s histappend
User avatar
debiman
 
Posts: 1539
Joined: 2013-03-12 07:18

Re: Used CLI commands saving for future reference.

Postby edbarx » 2017-11-04 14:16

Thanks for the prompt reply.

Do I need to modify some other file so that commands run as root are also preserved without redundant duplicates?

EDIT:
Under /root, .bashrc is all commented out which should mean, I assume, the other .bashrc is used also for root. However, I may be wrong and that is why I am posting again.
Debian == { > 30, 000 packages }; Debian != systemd
The worst infection of all, is a false sense of security!
It is hard to get away from CLI tools.
User avatar
edbarx
 
Posts: 5388
Joined: 2007-07-18 06:19
Location: 35° 50 N, 14 º 35 E

Re: Used CLI commands saving for future reference.

Postby Bulkley » 2017-11-04 15:08

That's an interesting idea. In my case it won't show much because I have been in the habit of cleaning out
bash history fairly regularly. I started that when I discovered my root password in it. No, that's not a failure of Debian; it is the result of my absent-minded brain going off on a tangent.
Bulkley
 
Posts: 5325
Joined: 2006-02-11 18:35

Re: Used CLI commands saving for future reference.

Postby edbarx » 2017-11-04 17:19

Bulkley wrote: I started that when I discovered my root password in it.

You don't need to delete .bash_history to remove that password from the list of commands. When I make the silly mistake of typing my root password as if it were a command and it ends in the .bash_history file, I open the latter with nano, remove the password from the list and save the edited file. For the password to appear in .bash_history, you may need to close all bash terminals, but I don't remember this is actually necessary. Again, I blame my rusty wetware!
Debian == { > 30, 000 packages }; Debian != systemd
The worst infection of all, is a false sense of security!
It is hard to get away from CLI tools.
User avatar
edbarx
 
Posts: 5388
Joined: 2007-07-18 06:19
Location: 35° 50 N, 14 º 35 E

Re: Used CLI commands saving for future reference.

Postby debiman » 2017-11-05 08:16

edbarx wrote:Do I need to modify some other file so that commands run as root are also preserved without redundant duplicates?

funny you should mention that, because i actually lied: the above was taken from /etc/bash.bashrc which is parsed for all users.
still you'd have a different history file for root i guess.
User avatar
debiman
 
Posts: 1539
Joined: 2013-03-12 07:18

Re: Used CLI commands saving for future reference.

Postby Thorny » 2017-11-05 10:53

debiman wrote:funny you should mention that, because i actually lied: the above was taken from /etc/bash.bashrc which is parsed for all users.
still you'd have a different history file for root i guess.

I don't believe you lied, I'd guess you didn't consider your answer carefully enough before posting, maybe you were in a hurry but I wouldn't want to think you lied. ;-)

Does that mean that there has been a change in Stretch, because those, HIST* lines are not in /etc/bash.bashrc in my Jessie installation or is it because that is where you put the lines in your system?

A system administrator on a multi-seat system may or may not want that to be global. They may want to be able to examine all the commands and fumbling that a user may do as an assessment, even dups, thus they may decide to do it on a per user basis in the user's home .bashrc.

Yes, I too would expect the superuser's bash_history and .bashrc to be in /root, the superuser's home.
Thorny
 
Posts: 340
Joined: 2011-02-27 13:40

Re: Used CLI commands saving for future reference.

Postby debiman » 2017-11-05 17:59

Thorny wrote:I don't believe you lied, I'd guess you didn't consider your answer carefully enough before posting, maybe you were in a hurry but I wouldn't want to think you lied.
no, i did it quite on purpose because i didn't want to bother you with confusing details.

Does that mean that there has been a change in Stretch, because those, HIST* lines are not in /etc/bash.bashrc in my Jessie installation or is it because that is where you put the lines in your system?
i put them there.
User avatar
debiman
 
Posts: 1539
Joined: 2013-03-12 07:18


Return to General Questions

Who is online

Users browsing this forum: No registered users and 5 guests

fashionable