You probably know about the command line history: typing, for example, an up-arrow will recall the last command typed, and the
history command will list as many commands as have been saved.
But suppose you don’t want a particular command to appear in the history? You may want to give a password on the command line and hide that from the history. Just start the command with a space:
$ mycommand --user me --password secret # goes into the history $ mycommand --user me --password secret # doesn't go into the history
- Be aware that your command may still be seen by other users using the
pscommand or exploring the
- As pointed out in the comments , the environment variable
HISTCONTROLneeds to be set to
ignorebothfor this tip to work. That appears to be the default in most Linux distributions, but BSD seems to have different defaults and a local sysadmin might have changed the global profile.
Despite the caveats, the above can be useful for all sorts of things. Next time you’re embarrassed at needing to look at the
man page for
ls and don’t want anyone else to see that in the history, just precede
man with a space…
Could this Linux Tip be improved? Let us know in the comments below.