Skip to main content

Questions tagged [bash-history]

Refers to the history of commands that have been run previously in Bash.

Filter by
Sorted by
Tagged with
161 votes
5 answers
768k views

View history of commands run in terminal

Is there a way to save all my typed terminal commands and view it like history in a log book?
rgr's user avatar
  • 1,969
49 votes
2 answers
58k views

Bash history not saved after closing terminal

I recently replaced my Ubuntu 14.04 installation with Ubuntu Gnome (which comes with Gnome DE). But I noticed that bash history is not saved once the terminal session is closed. Once I close a ...
Deepal's user avatar
  • 1,656
21 votes
5 answers
6k views

How do I rerun the second-to-last command?

I'm using Ubuntu 21.10. If I mess up, I can re-run the last command with !!. Here's an example: $ apt update Reading package lists... Done E: Could not open lock file /var/lib/apt/lists/lock - open (...
cocomac's user avatar
  • 3,534
19 votes
5 answers
41k views

how do I remove the last 5 lines in bash history?

How can I remove the last 5 lines in bash history? So that when I reload the Ubuntu server, or restart it they're not there at all? history -c only removes it from current session, but when I re-login ...
Anthony Pinto's user avatar
19 votes
3 answers
67k views

Finding an old command in the shell history [duplicate]

How can I find an old command I ran in my terminal? I used an appengine command and wish to just find it in my local command history without researching it online again.
saviour123's user avatar
15 votes
1 answer
3k views

multiline command chunks in bash history into multiple lines

In Bash (as well as Bash in WSL), multiline written commands can call-back with up/down arrows correctly also built-in history command report them correctly (until I'm still logged-in in bash). But ...
αғsнιη's user avatar
  • 35.9k
15 votes
1 answer
2k views

How do I go back to the bottom of history after pressing up in Bash?

If I scroll way up or use Ctrlr search and go way up in the history, how to get back down to the clear line? I know I can clear with Ctrle, Crtlu, but that modifies them. Is there an official way ...
alchemy's user avatar
  • 772
14 votes
5 answers
4k views

Hide "history -d" in bash history

If I accidentally type my password or anything else sensitive in bash I can easily remove that line with history -d ROW#, but I'm always left with the history -d ROW# command in history showing ...
Kalle Ling's user avatar
14 votes
1 answer
681 views

Why does the '!!' shortcut fail to execute the previously run command?

Recently I typed at my terminal username:~$ !! and got error from bash: bash: !!: command not found At the same time, it succeeds when done under superuser. I investigated my user's PATH's ...
user avatar
13 votes
1 answer
4k views

How does the history command work?

When I type any command in the terminal, it doesn't appear in my ~/.bash_history file until I exit my session. Also, when I manually edit my ~/.bash_history file (for example I remove the last three ...
sys0dm1n's user avatar
  • 333
12 votes
2 answers
35k views

Half of bash history is missing

The other night I was reading AU Q&A and used a bash command: inxi -???? Problem is today I don't remember characters comprising ????. I want to put the command and parameters into my ...
WinEunuuchs2Unix's user avatar
12 votes
1 answer
579 views

Terminal replacing ! followed by a number with a command

I'm very confused about my ubuntu terminal session, it seems to replace sections in commands that start by ! followed by a number with seemingly random commands. It does that with !87 replacing it ...
usbpc102's user avatar
  • 263
11 votes
4 answers
11k views

How can I automatically rotate/archive my bash history logs?

I know that Bash has both HISTSIZE and HISTFILESIZE variables that control how long history is saved for, and how much of it is saved. I would like to keep an archive of my history. However, if I ...
fouric's user avatar
  • 4,618
11 votes
2 answers
2k views

How to prevent saving bash commands *with* space in front

I read that, in order to not save bash commands to .bash_history, you put a space in front. This worked on all my embedded Linux PCs but not on my desktop with Ubuntu 18.04 LTS. I just thought it was ...
Mark Jeronimus's user avatar
10 votes
0 answers
8k views

missing .bash_history [closed]

I cant find .bash_history file in my home directory. I do: echo $HISTFILE /home/myname/.bash_history But if I try to list the file with ls, I get: $ ls -l ~/.bash_history ls: cannot access /home/...
vico's user avatar
  • 4,597
9 votes
3 answers
2k views

How do I search shell command history with a text editor?

I know that Ctrl+R let's you search command history, but it's a little primitive. Is there a way to export all my command history (not just the current terminal session, but the full history) to a ...
a06e's user avatar
  • 13.4k
9 votes
1 answer
12k views

HISTCONTROL=ignoreboth doesn't work [duplicate]

The default .bashrc in the standard distribution of Ubuntu 16.04 that comes with AWS has these lines: # don't put duplicate lines or lines starting with space in the history. # See bash(1) for more ...
Old Geezer's user avatar
9 votes
1 answer
10k views

How can I transfer my bash history to a new system?

My bash history is my memory, it contains commands that I don't want to loose when I update to a newer version of Ubuntu or change my computer. Is it possible to transfer the commands database to a ...
Sylvain Pineau's user avatar
8 votes
7 answers
8k views

Deleting history from ~/.bash_history

I have a couple questions about the terminal or command line history that is stored in ~/.bash_history. I can see the file in the terminal with the history command but if I try to open it with gedit ...
IDK's user avatar
  • 593
8 votes
1 answer
2k views

Use the bang-commands (e.g. '!!') of bash in scripts and aliases?

Is it possible to use the so-called bang-commands (! + command/symbol, like e.g. !! or !$:p) in bash scripts and in bash aliases? I wanted to add the line alias getit='sudo apt-get install !!' to ...
Byte Commander's user avatar
  • 108k
8 votes
2 answers
6k views

How to see time in ~/.bash_history file

I added time to the ~/.bashrc file, so now it shows me time when I execute history command like this: 376 04/10/19 20:39:52 sudo cat ~/.bash_history 377 04/10/19 20:40:04 date 378 07/10/19 ...
Prototype's user avatar
  • 129
8 votes
3 answers
2k views

Install Linux Mint Cinnamon's polished Ctrl+R/"reverse-i-search" on Ubuntu?

In Mint, when you hit Ctrl+R in any terminal, you get a pretty nice UI for the reverse-i-search. (To clarify - I'm referring to the extra polish provided in Mint - the UI is a step above the basic ...
bcmcfc's user avatar
  • 848
7 votes
2 answers
11k views

Why is history and .bash_history different and how to delete an entry in history?

So I know ~/.bash_history should be the file storing all the history and that you can just type in history to see all the contents of this file. Why would my .bash_history file have just 5 entries ...
larsen161's user avatar
  • 173
7 votes
1 answer
569 views

Making reverse-incremental-search in terminal easier using comments

When you press Ctrl+r in terminal this leads to use the reverse-incremental-search mode. The reverse-i-search lets you search for previous commands in your terminal, but this can get confusing when ...
Maythux's user avatar
  • 84.9k
6 votes
1 answer
6k views

Command history seems to be missing the first 75 lines

A couple of years ago, I did the automatic distribution update from 14.04 to 16.04. For the first time in my life, I was able to continue to use the computer after the automatic distribution update. ...
el_gallo_azul's user avatar
6 votes
1 answer
2k views

How to make the terminal autocomplete based on previously entered commands? [duplicate]

It's normal when using terminals that pressing up and down cycles through previous commands entered chronologically. I learned from a site how to add to that behaviour by autocompleting what I'm ...
maki57's user avatar
  • 1,827
5 votes
2 answers
663 views

Creating a complete and alphabetically sorted .txt file of bash history

I want to have a complete and sorted list of my bash history. But there are some problems: By doing history the list never shows the complete list and only 1000 commands are shown. In my $HOME ...
user avatar
5 votes
2 answers
6k views

Does the `reset` command wipes up the session memory used by commands?

There is a reset command I can use in bash, which I think is part of core-utils. Does it clean up the RAM used by previous commands from the Terminal session? I mean everything written into the ...
userDepth's user avatar
  • 2,020
5 votes
1 answer
2k views

make sudoers use their own history file

I just can't seem to get it to work in Ubuntu, it should be a simple answer, maybe someone can help me. All I am trying to do is get a sudoers to use their own history file, but if I set the history ...
Adesso's user avatar
  • 203
4 votes
3 answers
4k views

Does bash (or any shell, for that matter) have an 'overwrite' mode?

I'm running similar commands on (e.g.) a set of files. As an example, let's say I'm doing something like this (this isn't what I'm doing, it's just an example): > cat path/to/dir/file01.txt [...
Wilson F's user avatar
  • 445
4 votes
1 answer
551 views

Different history for different terminals

I would like to have something like "history environment", so for different consoles I can access different histories. I have different terminals defined, I would like to have for each ...
guyaloni's user avatar
  • 451
4 votes
1 answer
816 views

when parent directory is mounted on to new volume, i cannot see the sub directory which was existing earlier

After mounting /yesh onto a new volume, I cannot see the sub directory /yesh/data001 which was existing before mounting. If the sub directory is existing where can I find it?
yeswanth's user avatar
  • 117
4 votes
2 answers
2k views

Trap gnome-terminal close button

I can trap the exit command from a gnome-terminal window using the Bash trap command, but it only works if the user types exit in the terminal window. If the user clicks the close button instead, the ...
Håkon Hægland's user avatar
4 votes
1 answer
598 views

What do the numbers mean in output of history?

Output of history command looks like this: 1975 mkdir adrnln/work_dump 1976 ls 1977 code What do the numbers on the left side mean? Is it true that commands entered for example on Monday will be ...
micgeronimo's user avatar
4 votes
1 answer
251 views

How to clear "run a comand" history?

I have been trying to clear ubuntu's 'run my command' history but cannot find any way. if any one have the solution please tell
Aditya Vishwakarma's user avatar
3 votes
3 answers
2k views

PowerShell-like history auto suggestion for Bash

Microsoft added a neat feature in the 7.3.0 release of PowerShell called Predictive IntelliSense which autosuggests commands to enter as you type based on the history. Such a suggestion can be ...
adanski's user avatar
  • 147
3 votes
1 answer
141 views

lines starts with # and integers in .bash_history

I see lines contains #1582696021 . Whats is this? In SIEM we use it seems like a command running by user. Any help or documentation would be appreciated. Best
jojo's user avatar
  • 33
3 votes
2 answers
631 views

After removing .bash_history?

After I remove .bash_history, will .bash_history ever be recreated again? If so what creates it after it has been removed?
NerdOfCode's user avatar
  • 2,518
3 votes
1 answer
3k views

Clear the history of recent commands in terminal [duplicate]

How to clear the history of recent commands in terminal so that I am unable to scroll through them with up and down arrow keys? Closing and reopening the terminal doesn't seem to clear the history. ...
Raw N's user avatar
  • 131
3 votes
2 answers
86 views

Customise up and down keys to match cmd (point-in-time) functionality

How do I customise Bash so that up and down keys are the same as in cmd? E.g. $echo command1 $echo command2 $echo command3 $echo command4 In both Bash and cmd, pressing ↑, ↑, ↑, ENTER will run echo ...
deejbk's user avatar
  • 31
3 votes
2 answers
326 views

How to stop command number incrementation on duplicate command?

Problem Thanks to this question, I succeed to forbid my bash to stock the same command more than one time if I write many times the same command. However, there is still a detail that I cannot ...
Aracthor's user avatar
3 votes
2 answers
572 views

!x not found - bash script

I made a simple bash script to run a range of commands in your history, but it's not working. read -p "control + c to cancel" for i in $(seq $1 $2) ...
lol's user avatar
  • 173
3 votes
1 answer
3k views

Bash History is not Working

I recently upgraded to Ubuntu 14.04 Server Edition. The first thing I noticed is that my bash history seems to be broken. When I press the up arrow I should be able to view my recent commands, however ...
Qwintus's user avatar
  • 73
2 votes
1 answer
2k views

Can users with the same $HOME have separate bash histories?

I have two users, that have the same home directory: useradd -m -d /home/mydir user1 useradd -m -d /home/mydir user2 and they are in the same group. But I have a problem, when someone logged in the ...
Romans's user avatar
  • 121
2 votes
1 answer
3k views

How to run an anonymous terminal session?

This question by Paranoid Panda asks about incognito terminal use. This means history is not recorded in bash_history; so you can't access commands that were entered during that session. However this ...
TellMeWhy's user avatar
  • 17.6k
2 votes
3 answers
807 views

key-shortcut accessible command-history (in gnome-terminal) for irssi sessions needed!

I use gnome-terminal in combination with irssi and I am wondering if there's anything like .bash_history logfile for irssi, that can be used/implemented/set up, that enables one to retrieve previously ...
v2r's user avatar
  • 9,567
2 votes
1 answer
4k views

Bash History: Default size should be 500 but getting 1000

As this question suggest that bash keeps last 500 entries in history. But following command suggest otherwise, $ echo $HISTSIZE 1000 I have never changed bash history settings or config files other ...
foxtrot9's user avatar
  • 557
2 votes
1 answer
470 views

What to do after entering sudo password as plain text into terminal?

A few days ago i entered my sudo password (and hence my root password) into the terminal as plain text by mistake. I wanted to change my password, but forgot to enter the passwd command, and only ...
Felix R's user avatar
  • 143
2 votes
1 answer
104 views

Start gnome-terminal with predefined history

I would like to start a Gnome terminal window with a predefined history file. I tried: gnome-terminal -e 'bash -c "history -c; history -r ~/test.hist; exec bash"' but it still uses the standard ...
Håkon Hægland's user avatar
2 votes
0 answers
29 views

When using the history command , is it possible to get more details such as timestamp of each result? [duplicate]

History command options to see more details such as timestamp of each command entered
Nicholas Robertson's user avatar