Questions tagged [bash-history]
Refers to the history of commands that have been run previously in Bash.
93
questions
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 ...
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 ...
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 ...
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 (...
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
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 ...
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
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 ...
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 ...
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 ...
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/...
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 -...
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 ...
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 ...
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
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 ...
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 ...
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 ...
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 ...
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.
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 ...
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 ...
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 ...
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?
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. ...
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.
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/...
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 -- "${...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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?
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 ...
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 ...
-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
...
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 ...
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) ...