Questions tagged [command-history]

Questions relating to the command history features of command-line shells like Windows' CMD and Bash on Unix-based systems - features that store and deal with previously-executed shell commands.

Filter by
Sorted by
Tagged with
1
vote
2answers
67 views

Is there a way to view or store file history (like browser history) in Linux?

Is there any way to "view" (or) "store" file history (similar to browser history). For example if I have 10 files, and I open 2 of them, the following 2 details should get stored ...
3
votes
3answers
190 views

How to delete history lines when browsing history with fzf

There are often items in the bash history which I don't need anymore and/or are so long that when used with fzf match pretty much any text entered, making fuzzy matching on the history a bit useless. ...
0
votes
0answers
21 views

Count all called programs/commands from ~/.bash_history

I want to extract all the commands/programs in ~/.bash_history and count how many times each one was called. The arguments to the programs are irrelevant and should be ignored. I used this bash ...
2
votes
1answer
211 views

Make zsh history search behave like bash reverse-i-search

In bash, pressing [CTRL]+[r] will open the reverse-i-search prompt. How can I search the zsh history in a similar way? Note: The search query will hit the middle of the full command only, instead of ...
2
votes
1answer
213 views

How to setup zsh to append history to a file named dynamically by date

My biggest sticking point moving from bash to zsh is the history configuration. Using oh-my-zsh there is a history.zsh file in #ZSH/lib that I found (I think) can be disabled via unsetopt ...
1
vote
1answer
74 views

Get up-arrow key to only show unique commands? GHC Haskell

Haskell uses the GHC (Glasgow Haskell Compiler) which is basically a command line interface to compile and run Haskell. Like many popular CLI's, GHC allows you to use the up and down arrow keys to ...
0
votes
0answers
137 views

centos history command delete flag throws how to use

When I try to delete a specific command from the history on centos Linux 3.10.0-693.21.1.e17.x86_64 #SMP on trying history -d 34 I get an error saying Usage: history [-chrSLMT] [# number of events].
1
vote
0answers
563 views

Powershell persistent history in the ISE

(EDIT 2: now including the output of Get-Module) In a Powershell prompt I have persistent history across sessions (see this related question). But when I launch the Powershell ISE, I do not have ...
0
votes
0answers
32 views

Command history lost

Is there a way to know if someone (including system administrators) has deleted the bash commands history on purpose? (the history -r doesn't seem to work) And is there any way to recover that history?...
1
vote
3answers
103 views

Forget history position

Currently I using Bash with Cygwin. With Bash, I can enter these commands: $ date Thu, Apr 23, 2020 7:51:43 PM $ echo Sunday Sunday Then if I press Up twice, I get this, as expected: $ date If I ...
1
vote
1answer
66 views

How to search backwards in zsh/bash BUT relative to directory

Problem: In the terminal, when I press Ctrl+R to do a backward-search using the zsh/bash history, it searches all commands sorted by most recently used. Problem is some commands are completely ...
0
votes
1answer
75 views

How many ways are there to trace a user`s login and used commands in Linux after they deleted it (somehow)?

I am looking for a way to prove that my colleague at work did some changes to a configuration file while working with me on this case and now there are consequences because of his actions. I checked ...
0
votes
1answer
67 views

History of the run command box in Ubuntu

Most Linux desktops have a dialog box that opens at the press of alt+F2 where you can run simple commands like suspend and shutdown. Where is the history of commands of this dialog box stored? I know ...
1
vote
2answers
342 views

infinite history in bash, when using multiple terminals(terminator) without losing commands and messed up order

I want infinite history, because I type a lot of commands I can forget at the spot and would like to have it stored somewhere as a reference. But by just setting HISTSIZE and HISTFILESIZE it does not ...
1
vote
1answer
63 views

How much time has passed since first command in zsh

By executing this command, ❯ fc -l -1 | awk 'END{print $1}' 8845 I can see that I have 8845 commands in my history file. And I'm using zsh, so my history file looks like this: ❯ head $HISTFILE ...
0
votes
2answers
820 views

Show sudo history in history command?

I want to show which user turns to root in history command or in logs As we have multiple users which turn to root using sudo sudo -i and we are not able to track which users turns root and runs ...
0
votes
0answers
2k views

How to have a single history from all bash terminals?

I typically have multiple bash terminals open and I would like for the commands from all terminal sessions to go into a single history file, so I can see my command history chronological order across ...
3
votes
0answers
105 views

Setting Bash history sizes to -1 clears the history

I want to save all my bash history so I set my Bash history sizes in ~/.bash_profile to negative values: export HISTSIZE=-1 export HISTFILESIZE=-1 According to the Bash reference manual, all my ...
0
votes
1answer
70 views

Command executed via ssh

On CentOS 6, how can I tell what commands were executed via someone that ssh'ed into as root? I looked in /root/.bash_history. I also ssh'ed into myself and did a history but the only commands I ...
1
vote
1answer
110 views

Custom bash client history overlap

I am writing a client for doing various tasks on the zimbra server via ssh, and I've hit a bit of a snag. Here's the code: #!/bin/bash set -e export PATH=/usr/bin:/bin:/usr/sbin:/sbin export ...
0
votes
1answer
55 views

Calling back history in bash

I am a huge fan of this magic in my .inputrc which allow me to quickly autocomplete a command with the up arrow key. "\e[A": history-search-backward "\e[B": history-search-forward "\eOA": history-...
0
votes
4answers
2k views

When I try to change the directory on Ubuntu, it won't let me

When I type in cd Desktop/Code and then press Enter, it says -bash: cd: DesktopCode: No such file or directory I do have that file in my desktop, but I'm not sure how to access it and I'm not sure ...
1
vote
1answer
93 views

Why Bash does not scan all of its own history file

I use a common history for all sessions. It happens to me frequently, that a part of the history is lost, however. Therefore, I just swap different "common session" scripts in a hope that one will fix ...
0
votes
0answers
71 views

Is there a way to preload previous commands into a cmd window without running them?

So that I can just press up and get a list of commands I would potentially wish to run?
0
votes
3answers
1k views

Why is the command history only saved on exit

I am trying to save a different history file per tab / terminal but I cannot manage to save it immediately after a command is run. The history is just saved when I run "exit". This is a problem as ...
1
vote
0answers
74 views

Wrap the history number - reset history number without losing history

I display the history number as part of my prompt, e.g., {!1123}(j:~)$ ls /some/long/and/hard/to/type/path so that I can do it later with !1123. My HISTSIZE and HISTFILESIZE are both 200, but this ...
4
votes
0answers
92 views

TAB completion with .bash_history

I usually use PageUp/PageDown to search through .bash_history given a prefix. However, I regularly catch me pressing TAB multiple times before realizing that I need to use PageUp/PageDown in this ...
0
votes
1answer
2k views

How to bring bash history to default in CentOS 7

$ set -o | grep history history on $ echo $HISTFILE /root/.bash_history $ echo $HISTSIZE 1000 $ echo $HISTFILESIZE 1000 I ran following command and ...
0
votes
0answers
238 views

Bash - history search by ordered characters subset

I want to be able to write dockercomex and have, for example, a history match: docker-compose exec (...). Searching like this works in PyCharm and it's fantastic for productivity. In Firefox it's ...
0
votes
1answer
90 views

Store SSH command history on local machine

I often use SSH to connect to ARM machine which reboots regularly and doesn't have any persistent memory to store sh command history. Is there a way to store such history on my local machine so it ...
3
votes
1answer
1k views

Why was ctrl+c chosen to kill a process? [closed]

I'm aware of why ctrl+c kills a program; I'm more interested in the history as to why "c" was chosen over other letters, given that it (apparently) has no semantic meaning. If anyone knows the ...
1
vote
1answer
183 views

How do I make . execute the last shell command in zsh?

In bash, alias .= "fc -s" works for this purpose, it does exactly what I want. But in zsh, using fc -s just outputs fc: bad option: -s. How do I make . execute the last shell command in zsh?
2
votes
3answers
2k views

How to run encryption commands on linux without shell history logging

I want to encrypt something without logging any part of the shell command to bash history. I don't want the password or any filenames or the command to appear in the shell history. How to do it using ...
2
votes
0answers
106 views

applying reverse-i-search to a file

The bash reverse-i-search (ctrl-R) is quite handy to find a command you typed a while ago. However, it only searches the history of the current terminal (which consists AFAIK of the history loaded at ...
1
vote
0answers
1k views

Bash history not working?

I'm using FreeBSD 11, and Bash as my shell. I've checked all the basics. History shows as "on" HISTFILE, HISTFILESIZE and HISTSIZE are all set with sensible values. $HISTFILE exists and has rw ...
3
votes
1answer
256 views

Replace argument N in previous command

I've recently migrated to ZSH, and I'd like to get a bit more efficient at substituting arguments in commands. Specifically, I'd like to replace argument "N" in the most recent invocation of command "...
5
votes
3answers
5k views

Why can you not sudo history?

If I want to view root's bash history, why can I not just run sudo history? when I do it says command history not found, but if I run it without the sudo it runs fine. Edit: it's a duplicate answer, ...
2
votes
1answer
4k views

Why are powershell commands named cmdlets (command lets) and what is the difference between command and command-let?

I was trying to figure out the nomenclature of calling commands in powershell as command-let (cmdlet). Why they are simply not called commands, instead (what is the difference?). I could only guess ...
9
votes
3answers
21k views

Is it possible to clear history in windows command prompt?

As the title states. When using CMD, one can press upper arrow key to retrieve old commands. Is it possible to erase the history of these commands? If so, how could one do so?
1
vote
1answer
171 views

How do I write a bash alias that replaces !$ with the previous command’s last word?

I have a script named cpodin that copies several build artifacts to another directory. Afterward, I edit SHA1SUM in the destination directory. For example: cpodin /foo/bar/baz vim !$/SHA1SUM How do ...
0
votes
1answer
144 views

Linux utility to add a command line history buffer to any executable that gets input from STDIN?

A long time I was working on a Linux setup that had a great utility to add a command line history buffer to any executable that read from stdin. So if you have a Linux executable, for example a ...
1
vote
3answers
3k views

How does the “history” command work?

Trying to understand the functionality of bash_history: /home/user# ls -a . .. .bash_history .bash_logout .bashrc .cache .profile pylabs .viminfo .Xauthority I do see a .bash_history file ...
1
vote
2answers
482 views

Is there any way to prevent the current CMD input being erased by a blank history suggestion?

In the CMD interpreter on Windows, the ↑ arrow key replaces the current input (not sure what the accurate term is) with commands in the command history; commands that have previously been executed. ...
0
votes
1answer
60 views

How to get commands before timestamps in `history` output in Bash?

I found this answer about time-stamping history for Bash. Is there any way to permute the output? In particular Number command time-stamp rather than Number time-stamp command
1
vote
1answer
259 views

Bash history corrupted after power loss

I went to the store and when I came back, I found that I had forgotten to plug in my laptop and It had died from a low battery. When I rebooted, I was surprised to find that my bash history, instead ...
1
vote
1answer
749 views

How to run previous command by history index in Windows command prompt

I want to know to how run a previous command in history by index like how it is done in Linux (i.e ![index]). Yes, F9 in cmd raises a pop up box that allows me to enter in the index, but how do I do ...
0
votes
0answers
47 views

which IP address connects to my server

For some internal reasons, several people in our company are sharing the same USERNAME when connecting to SERVER, but they connect from different clients and machines. We need to track what each IP ...
0
votes
1answer
143 views

bash: opposite of “histignore” behavior

I am looking for a way to ignore every command by default, unless I specifically want to save it in history. Ideally, saving a command should be as easy as prepending it with a space.
0
votes
1answer
90 views

Seeing actual commands typed in bash history

Is it possible to retrieve the actual commands typed in a bash history? If the command involved (for example) a history substitution or modifier, what is seen in the history is the resulting command ...
3
votes
2answers
496 views

How to log every input and output and write to file in Bash?

I am often on assignment and sometimes I forget to document my work. E.g. write down output from different one-off tools. Is there a way to automate that via .bashrc? So I open up a new shell, it ...