Terminal for entertainment: how to safely enter passwords
Sometimes command line programs allow you to pass passwords to switches. For
mysql -u user -p password. However, if your shell records
history, you’re risking to store your password in a plain text file. There’s a
way to avoid this. Depending on your shell add the following line.
# ~/.zshrc setopt HIST_IGNORE_SPACE
# ~/.bashrc HISTCONTROL=ignorespace
Now you can prepend a space character before your command. Such a command won’t be stored in your history.
% whoami linuxhacker % mysql -u user -p password % # do your business... exit MySQL % Bye.
Press Arrow_Up. The MySQL command isn’t in your history.
% ↑ % whoami