Questions tagged [bash-history]

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

Filter by
Sorted by
Tagged with
3 votes
1 answer
369 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
  • 441
0 votes
1 answer
52 views

Bash don't save history to file but allow up arrow to cycle through history

I have an Ubuntu which is shared by other people using my account. I don't want the to see my history by running the history command. Here is what I have tried: export HISTIGNORE='*' It removes ...
sudoer's user avatar
  • 100
0 votes
2 answers
563 views

Ubuntu's history keeps popping up

I've got a problem with my Ubuntu 22.04. I want to clear out the command line history, so I type 'history -c' and everything seems fine, I type 'history' and it's all cleard. Then, I logout and ...
user1607778's user avatar
20 votes
4 answers
5k 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,093
4 votes
1 answer
223 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
15 votes
1 answer
1k 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
  • 744
2 votes
0 answers
27 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
1 vote
1 answer
70 views

Handy command for editing previously executed mistyped command and overwriting history entry with the fixed one

until recently I was pretty sure that fc command opens previously executed command in the default editor, executes submitted changes and overwrites last entry from the bash history. However, seems ...
zeko868's user avatar
  • 31
0 votes
1 answer
49 views

How to briefly use last ignored (not saved in history file) command in bash?

In my bash config file .bashrc,I have set it up in a way that commands preceded by a space are not saved in history. What I am asking is, how to achieve similar function as this answer here which was ...
llesh's user avatar
  • 119
1 vote
1 answer
546 views

bash history: can't retrieve commands/commands not saved [duplicate]

I suddenly got a problem with my bash history. When I type history, it only shows: 1 history I tried following commands: set -o | grep history echo $HISTFILE echo $HISTSIZE echo $HISTFILESIZE and ...
user790082's user avatar
0 votes
0 answers
78 views

Find the history of all commands entered in a specific location in terminal

Is there a way that I could find history of all commands (or 100 most recent commands) that were entered in a specific directory? For example, imagine I am in mona@goku:~/research/code/phosa/external/...
Mona Jalal's user avatar
  • 4,349
0 votes
1 answer
1k views

use the terminal without making history

I use a shared Ubuntu computer at the local Makerspace. looking at history I can see some times where I sshd into a remote host... I kinda wish I hadn't done that from here. I am able to run history -...
j0h's user avatar
  • 14.6k
2 votes
1 answer
387 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
0 answers
26 views

How can i write only the latest commands to ~/.bash_history file? [duplicate]

my ~/.bash_history file keeps record of all the commands i've typed. can i not put only the latest commands that i've typed from the start of terminal so that it always show me the recently typed ...
Vivek Kumar's user avatar
3 votes
1 answer
128 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
0 votes
2 answers
359 views

No history and path/bash completion on some systems

For some reason, I don't have a history of commands in the terminal and neither can I complete paths or commands. Pressing arrows also show symbols like ^[[D and ^[[C. The shell is bash and .bashrc ...
aardbol's user avatar
  • 111
9 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
1 vote
1 answer
163 views

How can I test if there are entries in the terminal command history in bash?

I'm still quite new to bash scripting and I need a very simple script that, if there is command history, displays it, and, if there isn't, informs the user that there is no command history. What I ...
saalkom's user avatar
  • 11
8 votes
2 answers
5k 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
1 vote
2 answers
20k views

clear terminal cache [duplicate]

I need to clear the terminal cache, I have tried with history -c but it clears the cache in that terminal session, but if I open another session and type history it shows all the previous commands.
Jaime Roman's user avatar
0 votes
1 answer
370 views

Prevent admins from disabling bash history

I have some admins that don't want their activity seen. They cleverly run set +o history once they log in. Doing so means that commands they run don't get recorded in the history file. Is there a ...
Rick Philbrtmo's user avatar
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
13 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.2k
4 votes
1 answer
694 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
6 votes
1 answer
5k 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
1 vote
1 answer
343 views

How to keep all bash history

I want to keep my duplicates and all commands started with a space. How do I do that? I have no ideas what to do. Last time that I messed with bash nothing worked at all afterwards.
matty shamrocks's user avatar
0 votes
1 answer
37 views

Couldn't navigate through directories using bash script

Through script I am not able to change into directories and list the files. cd is not working. Here is my script #!/bin/bash export HOME=/home/yesh DIR_START=2 DIR_END=`wc -l < ${HOME}/conf/...
yeswanth's user avatar
  • 117
1 vote
2 answers
7k views

bash history log all commands to syslog

I am trying to log all commands ran by all users. I got a solution from Github function log2syslog { declare COMMAND COMMAND=$(fc -ln -0) logger -p local1.notice -t bash -i -- "${...
Vishnu V's user avatar
  • 167
5 votes
2 answers
642 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
1 vote
2 answers
282 views

Cannot connect to the internet after cleaning history

I was using a friend's laptop with an Ubuntu 16 OS. I was asked to clean the historic files an after browsing a few websites, I used: cat /dev/null > ~/.bash_history command which appear not ...
user678722's user avatar
2 votes
1 answer
293 views

Gnome Shell command prompt history

I have a question regarding the Gnome Shell command prompt (Alt+F2). I already know that I can delete/reset the command history using dconf, but is there a way to completely disable it? Also, where ...
Silubr's user avatar
  • 73
7 votes
1 answer
10k 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
0 votes
1 answer
231 views

Terminal saves junk values in history

When I'm pressing upper arrow to browse history for some reason the terminal saves either bad out put and good output (commands and junk). for example when I'm typing the following junk it remember ...
Asaf's user avatar
  • 1
0 votes
1 answer
75 views

Reverse-i-search jumps back in time!

Sometimes I want to search for a previously executed command in my console. So I press Ctrl + R and I enter in (reverse-i-search) mode. I start typing my command and I press Ctrl + R again and again ...
Sembei Norimaki's user avatar
0 votes
0 answers
261 views

How does setting the time format in .bash_history work?

I turned on the time logging flags for .bash_history (HISTTIMEFORMAT='%F %T ') and as expected, when I checked history, I was able to see the time at which commands were executed, up to a point. And ...
lightsong's user avatar
  • 168
2 votes
0 answers
484 views

How to delete bash history for specific date range [duplicate]

I know how to delete the complete history of all the commands I have ran in my bash terminal, however, I don't want to delete all the history. What I want is to delete the history for a specific ...
Tshilidzi Mudau's user avatar
0 votes
1 answer
187 views

Create record of bash-commands and its properties

I want to keep a history of whatever I do on bash and its output. I need to create a DB which can store command path (at command time) command start time command end time output of the command Can ...
Manasvee Kumar's user avatar
1 vote
0 answers
258 views

Wanted to disable history -c for all users except the one with sudo rights?

I am able to secure .bash_history and .profile files so that user cannot delete or edit those files and cannot change shell as well. I needed this for bastion host for all production instances. I ...
rabbi bhumbla's user avatar
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
12 votes
1 answer
541 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
1 vote
1 answer
686 views

Excluding some commands from getting stored in bash history only after terminal is closed

Currently I am using $HISTIGNORE to ignore some commands and not save them in bash history. But current behaviour is if I am running a terminal I executed a command which is in $HISTIGNORE then on ...
ksmukta's user avatar
  • 31
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
  • 323
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
  • 583
8 votes
1 answer
11k 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
3 votes
2 answers
618 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,408
0 votes
1 answer
233 views

Customise Bash Terminal Font Colours

A short while ago I asked this question, on how to customise the bash terminal font colours. The question was answered and I got the colours wanting, using the link provided by a helpful user. The ...
devklick's user avatar
  • 127
0 votes
0 answers
42 views

show what command is used in graphical mode

Is it possible to use some kind of verbose to show on the terminal what commands are executed when using graphical mode? For example: if I click on chrome it must show: google-chrome. My goal is to ...
Zaico's user avatar
  • 11
-1 votes
2 answers
440 views

Add to History Script not working

I am trying to add lines from a file to my history, but it just adds the program code! What am I doing wrong? #!/bin/bash HISTFILE=~/.bash_history set -o history cat file.txt | while read line do ...
lol's user avatar
  • 173
18 votes
5 answers
39k 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
3 votes
2 answers
558 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