VMware Cloud Community
taylorb
Hot Shot
Hot Shot
Jump to solution

Clear last used commands on console?

I am using the command line on the ESX console. I have a certain command I use that needs a password passed with the command. I want to make sure this is gone when I am done with it. If I push the up arrow I can cycle through the commands and find the previously entered command with the password in it. how can I clear this command without logging out?

I guess this is more of a general unix question, but was hoping it was an easy one for the linux gurus on this site.

Thanks.

Reply
0 Kudos
1 Solution

Accepted Solutions
Dave_Mishchenko
Immortal
Immortal
Jump to solution

history -c should do the job for you.

View solution in original post

Reply
0 Kudos
4 Replies
MR-T
Immortal
Immortal
Jump to solution

Is there a man page for history command?

Dave_Mishchenko
Immortal
Immortal
Jump to solution

history -c should do the job for you.

Reply
0 Kudos
taylorb
Hot Shot
Hot Shot
Jump to solution

Thanks, that worked.

FYI, logging out doesn't seem to clear the previous commands, so the history -c command seems rather important. I logged out of a SSH session and when I logged back in, I could still cycle to my old commands. This included the command with my password! using the history -c command clears it permanently

Reply
0 Kudos
Dave_Mishchenko
Immortal
Immortal
Jump to solution

You can also try the following to disabled history completely. Edit /etc/profile

and change

HISTSIZE=1000 to HISTSIZE=0

and add

unset HISTFILE

The 2nd change will disable the history file (/root/.bash_history for the root user) and the 1st change will disable history within a session itself.