3

My ~/.bash_history is fine and has all of the previous commands that I ever typed. However, when I press the up-arrow key on the keyboard, I get nothing; the history command shows only the commands that I typed in this session only. How can I fix that?

I use Debian Stretch and GNOME Terminal.

Updates:

HISTSIZE=1000
HISTFILESIZE=2000

.

$ cat .bash_logout 
# ~/.bash_logout: executed by bash(1) when login shell exits.

# when leaving the console clear the screen to increase privacy

if [ "$SHLVL" = 1 ]; then
    [ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
fi

Ctrl+R only shows the commands I typed in this session

for example, if I opened a new terminal window there will be no history at all, if I typed a command then the history is this command only

Update 2.0

su 's history is working normally with no problems, it's just my user

I even created a new user and tested its history and it's working great

rahman@www:~$ history 
    1  history 
rahman@www:~$ su
Password: 
root@www:/home/rahman# history 10
  314  aptitude show linux-image-4.9.0-4-amd64
  315  aptitude show linux-image-4.9.0-3-amd64
  316  aptitude install firmware-linux-free irqbalance
  317  aptitude safe-upgrade
  318  aptitude safe-upgrade -y
  319  exit
  320  exit
  321  exit
  322  history 4
  323  history 10
root@www:/home/rahman# exit
exit
rahman@www:~$ history 10
    1  history 
    2  su
    3  history 10

Update 3.0

rahman@www:~$ echo $HISTFILE
/home/rahman/.bash_history
rahman@www:~$ echo $HISTCONTROL
ignoreboth

will someone help me, please? this problem is very annoying and pisses me off.

7
  • Check that there are no entries relating to history in /home/<username>/.bash_logout Oct 19, 2017 at 15:21
  • There are two problems. If you press Control-R, could you look on history? What value do you have on HISTFILE, HISTSIZE. What permission on your .bash_history. Note: if you have two open shell, sometime one will overwrite the other history. Oct 19, 2017 at 15:22
  • I've updated the question with the info you needed Oct 19, 2017 at 15:41
  • @A.RahmanMahmoud You never mentioned HISTFILE.
    – Kusalananda
    Oct 20, 2017 at 17:06
  • In addition to the output of echo $HISTFILE, please add the output of echo $HISTCONTROL. Oct 20, 2017 at 17:10

1 Answer 1

7

I found this link

and the problem got resolved by running

sudo chown <user> .bash_history

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.