How to bring bash history to default in CentOS 7

0

$  set -o | grep history    
    history         on
    $  echo $HISTFILE       
    /root/.bash_history
    $  echo $HISTSIZE
    1000
    $  echo $HISTFILESIZE
    1000

I ran following command and history become disabled for all users on logout

$  ln -sf /dev/null ~/.bash_history && history -c && exit

How can I re-enable history or make it normal as default?

LifeSaver

Posted 2018-03-24T10:43:06.293

Reputation: 5

Other users shouldn't be affected, unless they use the same home directory... or you changed the /etc/skel files so all new users get the null-linked history – Xen2050 – 2018-03-24T11:01:18.400

Answers

1

You have symlinked ~/.bash_history file to /dev/null which is basically an empty file, void.
To start a new history file just:

rm -rf ~/.bash_history

The command you have used:

ln -sf /dev/null ~/.bash_history && history -c && exit

Basically redirects (content of a) file .bash_history to a "trash can" (/dev/null) but, unlike MS Windows trash can, you won't be able to recover files from there. Then:

history -c

Clears all the history entries for current user.
Basically, this whole line intends to clear history and throw away any new history entries.

yahol

Posted 2018-03-24T10:43:06.293

Reputation: 71

1Should work. /dev/null might be more like a black hole of nothingness than a trash can. – Xen2050 – 2018-03-24T10:59:59.373

@Xen2050 thank you! I couldn't think of the right words to describe it ;) – yahol – 2018-03-24T12:09:42.763