Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[SOLVED] Used CLI commands saving for future reference.

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
User avatar
edbarx
Posts: 5401
Joined: 2007-07-18 06:19
Location: 35° 50 N, 14 º 35 E
Been thanked: 2 times

[SOLVED] Used CLI commands saving for future reference.

#1 Post by edbarx »

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
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Used CLI commands saving for future reference.

#2 Post by debiman »

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
edbarx
Posts: 5401
Joined: 2007-07-18 06:19
Location: 35° 50 N, 14 º 35 E
Been thanked: 2 times

Re: Used CLI commands saving for future reference.

#3 Post by edbarx »

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.

Bulkley
Posts: 6383
Joined: 2006-02-11 18:35
Has thanked: 2 times
Been thanked: 39 times

Re: Used CLI commands saving for future reference.

#4 Post by Bulkley »

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.

User avatar
edbarx
Posts: 5401
Joined: 2007-07-18 06:19
Location: 35° 50 N, 14 º 35 E
Been thanked: 2 times

Re: Used CLI commands saving for future reference.

#5 Post by edbarx »

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
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Used CLI commands saving for future reference.

#6 Post by debiman »

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
Thorny
Posts: 542
Joined: 2011-02-27 13:40

Re: Used CLI commands saving for future reference.

#7 Post by Thorny »

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.

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Used CLI commands saving for future reference.

#8 Post by debiman »

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.

Post Reply