Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
1answer
43 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
69 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
0answers
42 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
13 views

How do I history-expand the *penultimate* word of a previous command, in zsh?

I use zsh's history-expansion for the last argument of the previous command every day: mkdir foo cd !$ I also know how to select an arbitrary word by index: npm install widget --global --no-...
0
votes
0answers
32 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
351 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
59 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 ...
3
votes
0answers
53 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
473 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
124 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
37 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 ...
1
vote
1answer
256 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 ...
0
votes
1answer
94 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
1k 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
74 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
595 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 ...
2
votes
0answers
112 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 "...
0
votes
0answers
66 views

A mysterious Windows Command Prompt opens, runs code and closes before I can read it. How can I tell what it is/does? [duplicate]

For the past week or so, a mysterious Windows command line window has randomly occasionally opened, displayed text, then closed in about 1/8 of a second. It's too fast for me to read/screenshot. I ...
4
votes
2answers
2k 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, ...
1
vote
1answer
1k 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 ...
5
votes
3answers
9k 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
72 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
109 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
2answers
1k 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
129 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 Up (↑) arrow key replaces the current input (not sure what the accurate term is) with commands in the command history; commands that have previously been ...
0
votes
1answer
55 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
138 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
354 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
46 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
93 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
74 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 ...
2
votes
1answer
193 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 ...
1
vote
1answer
133 views

Difference in cd.. and cd .. (Change Directory) [duplicate]

cd.. and cd ... Basically, they are doing the same. But, who and why thought of changing it with space or without space? Why is there space and why there isn't space between cd and two dots? C:\...
0
votes
1answer
611 views

executing history command as another user

I am confused as to why I'm having problems executing a history command as another user to return all that user's history - I need to loop though all users and get their history cat /etc/passwd | awk ...
3
votes
1answer
2k views

CTRL+R in shell - if I go past the command I want, how do I get back to it?

I'm feverishly hitting CTRL+R to find some command I used awhile ago, when suddenly I get to it. By reflex, I continue hitting CTRL+R, passing it for something further back in the shell history. How ...
0
votes
3answers
392 views

Scroll through shell history based on command or stub/stem?

Please forgive my ignorance.... I have a history of commands in Bash on OS X and Linux. At times, I want to go back to an item based on the command. For example, suppose I previously entered: make ...
2
votes
1answer
453 views

zsh doesn't log not found commands to history [duplicate]

There's a way to setup zsh to not save commands not found to history ? For example, if by mistake I type: got push instead of git push then got push entry is added to history file, how to stop ...
0
votes
0answers
73 views

Accidentally partially deleted home directory . . . Killed with ctl-c, which file is corrupted?

I was running some software in my home directory (last time I do that!). Stupid config file asks what directory I wanted to put my output files. I accidently used ~/ as my output directory. It ...
3
votes
0answers
1k views

How can I have an unlimited history in zsh?

I want an unlimited history file in zsh. As far as I know I can only set HISTSIZE and SAVEHIST to a big number.
0
votes
1answer
88 views

Sensitive info in Powershell and/or cmd invocations

I want to run commands from Powershell and/or cmd.exe on a Windows host. These commands might accept, as parameters, passwords which should not be saved anywhere. These scripts may need to run from ...
4
votes
1answer
1k views

Incorrect output of history command of ssh. How to read the timestamp info correctly

I set the HISTTIMEFORMAT variable to store the timestamp info .bash_history file. I am able to display the history properly if I use interactive shell. But, when I run history command to display ...
1
vote
0answers
30 views

Serial Port output history?

Is there a way I can go back and view previous serial sessions I have had? I use cu on ubuntu to open the serial connection. I need to see if I can find a traceback on my Cisco router.
3
votes
3answers
907 views

Is there a way to stop terminal from saving commands?

Well, the thing I'm tired of clearing my terminal history again and again. So I was wondering if there's a way that the terminal doesn't record your history or the commands you've used. If not, is ...
2
votes
1answer
250 views

How to access history of all Emacs commands?

I see that there is a way to access the history of the minibuffer. I was curious if there is a way to see a history of every action in Emacs, besides just the complex ones. My purpose is to save these ...
5
votes
3answers
3k views

Automatically export history at end of powershell session

I can export my Powershell history using the scripts outlined in the Technet page on the subject, Get-History | Export-Clixml ~\PowerShell\history.xml and I can automatically load up the saved ...
1
vote
3answers
9k views

Is there a way to determine which user ran a command in bash history?

We work on CentOS servers available to over a hundred employees via SSH, each with their own login. Running a normal history bash command shows all of the commands ran by all of the employees, however ...
2
votes
2answers
7k views

Why does “cmd /k” reset/clear/delete command history?

Can anyone explain why cmd /k clears the command history of my window terminal (CMD). When I run a batch file within a previously CMD and I put cmd /k at the end of the line, the command history will ...
2
votes
1answer
796 views

How to make windows 8.1 command line save commands history?

Exist a way to automatically save command history on windows 8.1 command line and have it available after close and open the command line program?
0
votes
1answer
65 views

How can I enable preserving of the run dialog box history in Windows XP

On my PC (Windows XP), the "Run" dialog box does not keep the history of previous commands till the next time my computer is restarted! So no suggestions are shown when a command is entered after ...
2
votes
2answers
1k views

In Windows Command Prompt, how to get the last command that started with some letters?

Let's say I entered a bunch of commands one after another: rm blah.txt pwd ls cd .. cd blah pwd If I want to get "rm blah.txt" to appear again without typing the whole thing again, I can press up 6 ...