Naturally if we want to use the commands you have entered on the terminal, you can choose them by using up arrow and it will cycle through the previously used commands. Otherwise you can use the "history" command to see the full commands entered in terminal. But what if you want to hide certain commands from showing up in command line history? To find out read on!
It is very easy to hide certain commands from history. Using this method, we will be using a 'space' before the actual command to hide that command. So whenever a command starts with a space, it will be ignored to store in the command line history. Type the following command in terminal to make terminal not to remember a command starts with space.
Now type a command by adding a space in front of the actual command. Then check whether it is showing up in command line history by typing "history" in the terminal.
You can see that the command you have typed with a space in front of it is not showing in the command line history and you cannot see that command when you cycle through the command line history using the up arrow.
Then if you want to revert back the behavior of command line as normal( ie, showing the command even if we are adding space in front of the command), please type the following command in the terminal.
It is very easy to hide certain commands from history. Using this method, we will be using a 'space' before the actual command to hide that command. So whenever a command starts with a space, it will be ignored to store in the command line history. Type the following command in terminal to make terminal not to remember a command starts with space.
- export HISTCONTROL=ignorespace
Now type a command by adding a space in front of the actual command. Then check whether it is showing up in command line history by typing "history" in the terminal.
You can see that the command you have typed with a space in front of it is not showing in the command line history and you cannot see that command when you cycle through the command line history using the up arrow.
Then if you want to revert back the behavior of command line as normal( ie, showing the command even if we are adding space in front of the command), please type the following command in the terminal.
- export HISTCONTROL=showspace
Wicked info man/gal............! Can you please share more cool tricks of the trade when using History.........How do you interact with its methods and functions
ReplyDeleteGlad to know that you liked this post.
Delete