How to Clear History

Is there any method to clear history other than delete the contents of .bash_history in linux 7.2.
If there is any plz tell me.

First note that deleting .bash_history will _not_ remove history.
When bash starts it loads the history into memory and writes it back to the file when it exits.

You can set the HISTSIZE environment variable to limit the number of lines of history.
Set it to 0 to clear history.

$ export HISTSIZE=0

The HISTFILESIZE variable controls the number of history written to bash_history. If you do

$ export HISTFILESIZE=0

you will get history in the current session but it will not be written to disk.

BTW you probably mean Redhat 7.2 not linux 7.2

----------------------------------------------------------------------------------------------------------------------------

Use the command
$history -c

This will clear the history

Have a Linux Issue?
Do you have a Linux Question?

Linux Home: Linux System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.