Questions tagged [bash-history]

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

Filter by
Sorted by
Tagged with
16 votes
4 answers
3k 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 (...
user avatar
  • 2,307
4 votes
1 answer
112 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
user avatar
14 votes
1 answer
760 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 ...
user avatar
  • 590
2 votes
0 answers
24 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
user avatar
1 vote
1 answer
39 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 ...
user avatar
  • 31
0 votes
1 answer
39 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 ...
user avatar
  • 49
0 votes
0 answers
126 views

Log all commands executed inside kubernetes pods

I have a ttyd pod launched and running in my kubernetes cluster. I want to log all the commands executed in the ttyd or the bash shell NOTE: the security context "readOnlyRootFilesystem" is ...
user avatar
1 vote
1 answer
138 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 ...
user avatar
0 votes
0 answers
61 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/...
user avatar
  • 3,691
0 votes
1 answer
460 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 -...
user avatar
  • 14k
2 votes
1 answer
243 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 ...
user avatar
  • 143
2 votes
0 answers
25 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 ...
user avatar
3 votes
1 answer
112 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
user avatar
  • 33
0 votes
2 answers
187 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 ...
user avatar
  • 111
8 votes
2 answers
1k 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 ...
user avatar
1 vote
1 answer
151 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 ...
user avatar
  • 11
7 votes
2 answers
3k 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 ...
user avatar
  • 109
1 vote
2 answers
12k 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.
user avatar
0 votes
1 answer
284 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 ...
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 ...
user avatar
  • 21
11 votes
1 answer
2k 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 ...
user avatar
  • 33.7k
4 votes
1 answer
356 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?
user avatar
  • 117
6 votes
1 answer
4k 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. ...
user avatar
1 vote
1 answer
215 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.
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/...
user avatar
  • 117
1 vote
2 answers
6k 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 -- "${...
user avatar
  • 167
5 votes
2 answers
598 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
228 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 ...
user avatar
2 votes
1 answer
221 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 ...
user avatar
  • 73
5 votes
1 answer
8k 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 ...
user avatar
  • 153
0 votes
1 answer
204 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 ...
user avatar
  • 1
0 votes
1 answer
70 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 ...
user avatar
0 votes
0 answers
216 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 ...
user avatar
  • 168
2 votes
0 answers
478 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 ...
user avatar
0 votes
1 answer
144 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 ...
user avatar
1 vote
0 answers
201 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 ...
user avatar
14 votes
5 answers
3k 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 ...
user avatar
12 votes
1 answer
486 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 ...
user avatar
  • 263
1 vote
1 answer
562 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 ...
user avatar
  • 31
13 votes
1 answer
3k 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 ...
user avatar
  • 323
8 votes
7 answers
7k 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 ...
user avatar
  • 563
6 votes
1 answer
9k 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 ...
user avatar
3 votes
2 answers
600 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?
user avatar
  • 2,218
0 votes
1 answer
221 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 ...
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 ...
user avatar
  • 11
-1 votes
2 answers
380 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 ...
user avatar
  • 163
16 votes
5 answers
34k 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 ...
user avatar
3 votes
2 answers
514 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) ...
user avatar
  • 163
18 votes
3 answers
55k 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.
user avatar
11 votes
2 answers
25k 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 ...
user avatar