Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear all history in linux/ubuntu terminal or bash permanently? [closed]

People also ask

How do I permanently delete command history in Linux?

Removing history If you want to delete a particular command, enter history -d <line number> . To clear the entire contents of the history file, execute history -c .

Can I delete bash history?

How can I remove or delete a single command from bash history file? You can use the history command to clear all history or selected command line.

How do I clear browsing history in Ubuntu?

You can try by opening up browser settings and navigate to privacy. Or, you can tap ctrl+shift+del button simultaneously to purge the history!


You can clear your bash history like this:

history -cw


If you use bash, then the terminal history is saved in a file called .bash_history. Delete it, and history will be gone.

However, for MySQL the better approach is not to enter the password in the command line. If you just specify the -p option, without a value, then you will be prompted for the password and it won't be logged.

Another option, if you don't want to enter your password every time, is to store it in a my.cnf file. Create a file named ~/.my.cnf with something like:

[client]
user = <username>
password = <password>

Make sure to change the file permissions so that only you can read the file.

Of course, this way your password is still saved in a plaintext file in your home directory, just like it was previously saved in .bash_history.