recall commands previously typed in a shell or other utility

learn more… | top users | synonyms

0
votes
1answer
21 views

Persistence Bash history between detached processes

I haven't yet been able to find this among the bash documentation so I was hoping it could get answered if I asked it here. Is there any way that I can, on execution of a script, branch its history ...
0
votes
1answer
21 views

KSH on old unix systemV: search history

I have set a good ksh environement on old unix PATH=$PATH:/usr/lib/acct:/usr/sbin:/sbin:/usr/ucb export PATH EDITOR=vi FCEDIT=vi export EDITOR export FCEDIT HOSTNAME=`uname -n` HISTSIZE=500 ...
4
votes
1answer
52 views

What can cause an item to be deleted from my bash history?

About once a day, I'll run into an issue when I search for a history item in bash. Manipulating that item sometimes deletes the history entry, and sometimes doesn't. Here is one case of this ...
2
votes
4answers
272 views

Is there a way to show the history of the commands used in the shell?

If my Linux installation has three registered user accounts, is possible to check the history of the commands introduced by each one, and how?
2
votes
1answer
33 views

How can I use !! in zsh alias

I am trying to create an alias that builds upon my previous command. Say I run ag foo After looking at the list I want to be able to use those results in vim so I do vim -q<(!! --vimgrep) The ...
0
votes
0answers
42 views

How to implement command history in Linux terminal?

I am using Putty as Terminal to connect a Linux server running Oracle Linux. To use a command multiple times, I have to type that command each time. There is no function of Up and Down button unlike ...
9
votes
2answers
259 views

How to access the second argument from the last command in the history ?

I am starting to learn some Regex, therefore I use this command repeatedly: grep pattern /usr/share/dict/american-english Only the part with pattern changes, so I have to write the long expression ...
3
votes
1answer
51 views

Is it possible to show the current history line number when performing reverse search in bash?

Pressing Ctrl+R and typing py results in: (reverse-i-search) `py´: python I would like it to be this way: (reverse-i-search) `py´: n python where n is the history line number. I did not find an ...
3
votes
0answers
47 views

Bash: “history number” vs “command number”

While Googling how to customize my shell prompt via the PS1 variable, I'm seeing tables of special characters that can be used. In particular: \! the history number of this command ...
1
vote
0answers
26 views

Is there a way to share vim command history? [migrated]

By that I mean what people do in bash this way: export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND" That is, when I run a command echo test1 in one shell, and then press Up ...
0
votes
1answer
26 views

append file with history line number values

Is there a way to append my_computer.sh with the command on line 330 by only referencing the line number? or with the fewest keystrokes possible? 326 pip install -U pip 327 man pip 328 cat ...
1
vote
1answer
67 views

cat .bash_history | grep ./configure [closed]

Why does this not give any output: cat .bash_history | grep ./configure on an system/in an shell where ./configure has been run multiple times. And if I use the arrow key's to scroll the history in ...
2
votes
1answer
47 views

How to protect against purge of bash history?

Following the answer: When closing multiple bash instances at the same time, there is a known race condition that may cause the history to be cleared. This occurs because there is no locking ...
1
vote
1answer
52 views

Removing passwords from terminal logs in CentOS 7

Sometimes a user gives a typo when they are trying to give a password after typing a sensitive command, such as su - . The user then will assume they are being given another password request, and ...
1
vote
2answers
59 views

How do I prevent just 'exit' from being saved when I close an SSH connection?

When searching for a way to do this on Google, all I can find are ways to quit the session without saving history (like kill -9 $$), but I have the opposite problem. I want to save all of my history, ...
1
vote
1answer
22 views

After removing the history file, why do I still have older commands in the history?

In a ssh session every time that I open it I assign a value to a variable. Then I remove history with command rm -f .sh_history. Everything is ok but why if I have other session opened and I do an ...
2
votes
1answer
34 views

How to merge duplicated history of command on terminal?

Do you have an experience like this? When you try to find a previos used command on terminal by up arrow and you find $ls # 1st time push `up arrow` $ls # 2nd time push `up arrow` ...
1
vote
2answers
133 views

how to record all who that login to my linux machines and records them

I installed the package audit on my linux red-hat 6.x machine in order to view the recored of each user that log to my linux machine yum install audit kit installation from: ...
2
votes
2answers
101 views

Export Command History into a Shell Script

Often I have complicated installation procedures to follow, like having to build dependencies for buildtools, to build dependencies for the application I wish to install from source. Once I have done ...
1
vote
2answers
88 views

How do I get command name of the last executed command?

Example: I type man ls, than I want to get man only. By using !! I can get man ls but how do I get man?
-1
votes
1answer
159 views

How does this bash alias to repeat the last command as sudo work? [duplicate]

I recently came across this ingenious bash alias to repeat the last issued command, but as sudo. This could be done by using sudo !! directly in the terminal after the failed command. The alias I ...
1
vote
2answers
48 views

Why does my .bash_history contain duplicate segments? [duplicate]

Since I keep my bash history under source control, I've noticed that sometimes sizable segments of the history end up repeated, sometimes hours or days after their original execution. I use Debian 7.7 ...
1
vote
1answer
82 views

View a command in the shell history [closed]

If we put a space before any command in the shell it will not shown in history. Is there any way to see that command if the user enters a space before any command?
2
votes
1answer
48 views

HISTTIMEFORMAT syntax

There are many bash guides that include adding lines such as HISTTIMEFORMAT='%d/%m/%y %T ' or HISTTIMEFORMAT="%F %T " to ~/.bashrc or /etc/bash.bashrc. There's always a space before the final quote. ...
0
votes
0answers
38 views

Bash ignore “update” command

I have this in my .bashrc export HISTTIMEFORMAT="%Y/%m/%d - %H:%M:%S - " export HISTIGNORE="&:[ ]*:reload:update" export HISTCONTROL=ignoreboth:erasedups shopt -s autocd shopt -s cmdhist shopt ...
1
vote
2answers
91 views

bash history for current session

Maybe I'm overlooking something but is there a way to get your current bash history for the current session you are using like if i run ssh host $ pwd $ ls $ cd /tmp I just want to see those 3 ...
0
votes
1answer
73 views

What does “dd” stand for? [duplicate]

What does dd stand for? I've always referred to it colloquially as "Disk Destroyer", but what are the "official" words that make up the acronym/command? According to this link and this link it could ...
0
votes
1answer
49 views

.bash_history keeps truncating

My .bash_history keeps truncating even though I set: export HISTSIZE= export HISTFILESIZE= On my .bash_profile. Im not sure when it happens but it might happen when I logout or shut down my ...
4
votes
4answers
412 views

How to capture command line input into logfile and execute it at the same time?

Let's say I issue some commands on the command line: #capture what follows $ echo "foo" foo # don't capture $ echo "bing" bing # capture again $ echo "bar" bar How can I log commands selectively ...
0
votes
1answer
74 views

How to list down all useless or less used files or application in my linux server?

I want to clean cruft from my Oracle Linux server. For this, I need to know which application or directory isn't used or is hardly ever accessed. Is there any command or way to list directories or ...
2
votes
1answer
162 views

Never clear .bash_history (HISTFILE)

Is there any command that I could use that makes .bash_history never clear itself? After a certain amount of commands it just clear itself. I think this works but I'm not sure? ...
1
vote
1answer
294 views

How to check the time at which the command was executed?

When history command is executed, it shows a list of recently executed commands. Is there any provision with which we can see the time at which those particular commands were executed?
1
vote
1answer
29 views

Partially duplicated history when setting PS1 in .bash_profile [duplicate]

When I set PS1 variable in ~/.bash_profile, it worked as configured. However, the history is somehow messed up. When I press Arrow Up or Ctrl+P to view commands I typed, it starts to duplicate ...
5
votes
3answers
377 views

How do I auto complete a command from the command history? [duplicate]

Is there a key combination for bash to auto compete a command from the history? In ipython and matlab for example this is achieved by pressing up arrow after typing a few characters.
36
votes
2answers
2k views

How do I open an incognito bash session?

Is it possible to open an incognito session in bash? For example, when we need to enter passwords in commands and don't want bash to add them to history.
7
votes
1answer
187 views

history - List only successfully run commands

I'm wondering if there's a way to use the history command but only list commands that were run successfully. Likewise, would there be a way to list ones that produced errors? I know each command has ...
1
vote
0answers
108 views

HISTSIZE HISTFILESIZE not working [closed]

I have set these global variables in my .bashrc file Running echo $HISTSIZE echo $HISTFILESIZE both return 10000 My History contents are overding, currently from 254 - 432 If I type another two ...
5
votes
1answer
119 views

How to stop bash editing the history when I reuse and modify an entry?

Some instances of bash change the command history when you re-use and edit a previous command, others apparently don't. I've been searching and searching but can't find anything that says how to ...
0
votes
0answers
42 views

What does !$ mean exactly? [duplicate]

echo !$ outputs different strings depending on my previous command line call. For example: mrdumbdumb-redhat:~ mrdumbdumb$ ls mrdumbdumb-redhat:~ mrdumbdumb$ echo !$ echo ls ls ...
2
votes
1answer
252 views

Can you change timestamp format for history command on tcsh

When I run history command (on tcsh), it only prints the TIME portion of the timestamp and omits the date: 3 15:07 echo $PATH 4 15:07 ls -la In bash, you can use HISTTIMEFORMAT ...
5
votes
2answers
253 views

echo of a string with an exclamation point

Here are what I put in bash and the results I got about 'echo': $ echo '!$' !$ $ echo "!$" echo "'!$'" '!$' I'd like to know how 'echo' deals with the second input. It seems to me that ...
2
votes
2answers
82 views

Livesearch with first 10 matches as preview for zsh-history?

I have seen a history-livesearch with a preview, that shows the 10 first matches in the history in a list below the BUFFER-line, which is updated on every keystroke, and acts like the standard ctrl+r ...
7
votes
2answers
287 views

Is there a shortcut for repeat the second proximate command in bash?

We all know that !! can repeat the last command you do in bash. But sometimes we need to do some operation like $ python test.py $ vim test.py $ python test.py # here is where I need to repeat the ...
4
votes
4answers
144 views

Bash history in script: `!#:*`

I have been reading through the study guides for the LPIC-1. echo "This is a sentence. " !#:* !#:1->text3 I'm having trouble understanding how the above line of code repeats the echo command ...
3
votes
2answers
307 views

Show older or newer history items with the history command in zsh

I typed in the history command and it showed me the last 10 commands executed by me. Now I wanted to see the last 20 commands executed by me so (after reading the documentation): An argument of n ...
2
votes
1answer
197 views

How does execution of !find command work?

The !find command lets the user perform the previously executed find, with all its parameters. How does it work internally, where exactly has this behaviour been programmed?
21
votes
8answers
10k views

How do I repeat the last command without using the arrow keys?

I know I can use Up to iterate through previous commands. Running the last command simply involves Up + Enter. However, I was thinking of buying the Happy Hacking Keyboard as I spend a lot of time in ...
3
votes
1answer
91 views

Persistent directory stacks across sessions in zsh

I would like to share my directory stack (the one accessed with dirs) across sessions and tmux panes/windows. In the zshbuiltins man page I have found autopushd to add every directory I switch into ...
1
vote
3answers
57 views

Command to 're-apply' previous command?

Is there an easy way to re-apply a previous command to a new command line entry? Say I typed in chmod u+r,g+x file.txt but forgot the sudo. Could I simply type sudo <some easy symbol>'? ...
2
votes
1answer
34 views

Is using shorthand quick substitution of history expansion problematic?

In my terminal (bash 3), I sometimes use the quick substitution ^aa^bb^ ^string1^string2^ Quick substitution. Repeat the last command, replacing string1 with string2. Equivalent to ...