1

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 I got, respectively, the following results:

history         on
/home/mary/.bash_history
1000
2000

I added also to my bashrc, the following lines:

# Avoid duplicates
HISTCONTROL=ignoredups:erasedups
# When the shell exits, append to the history file instead of overwriting it
shopt -s histappend

# After each command, append to the history file and reread it
PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r"

Everything seems OK but I can't scroll back to retrieve commands and the reason seems the fact that nothing has saved in history and that is why the command history does not contain anything.

Could you please help me to solve this issue ?

4
  • Have you looked inside /home/mary/.bash_history? It should contain the information you're looking for ...
    – user1091774
    Feb 3, 2021 at 8:38
  • It's indicated that the permission is denied. I can't even scroll back to the previous command written in the terminal.
    – user790082
    Feb 3, 2021 at 8:49
  • What's the ownership of /home/mary/.bash_history - is it owned by you? This can be seen with the command ls -la. Feb 3, 2021 at 8:52
  • indeed you directed me towards the answer. Thanks.
    – user790082
    Feb 3, 2021 at 9:51

1 Answer 1

1

The answer resides in the ownership of the bash_history which was root. I did:

sudo chown mary:mary /home/mary/.bash_history

and that solved the problem.

1
  • Makes sense - glad it worked. Feb 3, 2021 at 9:53

Not the answer you're looking for? Browse other questions tagged .