Generally, it's not required to delete any command from the history but some time we need to delete few commands.
Example- By mistake, In a command i have entered password in plain text format and I don't want let the history record this password. In this case i will delete that command from the history.
Let's have a look at command below.
During MySQL connection command, i mentioned password in command. as in picture below.
root@PVM-Linux-UDev:~# history
Now, I want to delete this command from the history list.
Let's use below command to delete the specific command from the history.
To delete single command use following command.
root@PVM-Linux-UDev:~# history -d 2008
In the above command use command ID with history -d command .
Let's confirm deleted entry using history command.
root@PVM-Linux-UDev:~# history
To clear entire command list use following command.
root@PVM-Linux-UDev:~# history -c
Using history -c command, you can clear entire bash history. See in above example nothing is there.
Alternatively you can run below command to clear entire bash history.
root@PVM-Linux-UDev:~# cat /dev/null > ~/.bash_history
Please note:- Generally, Normal user can view his own bash history and can perform any action over them. But root user and view anyone's bash history.
No comments:
Post a Comment