Today’s article is another short-form article, where the subject is how to not save a command to bash history. It’s trivially easy and something everyone can learn. So, read on and learn how to not save a command to Bash history.
The vast majority of my readers are going to default to using Bash.
bash – GNU Bourne-Again SHell
You’ll access Bash through your terminal and, again as the default, will save x-amount of past commands to a file known as ~/.bash_history
. Anything you enter as a command (though not passwords entered at the password prompt, as that’d just be silly) will be saved to that file.
If you’re like me, you use the terminal a great deal. Again, if you’re like me, you value the Bash history aspect but you don’t want it full of trivial or experimental nonsense. You can prevent a terminal input from being saved in your ~/.bash_history
– and it’s trivial to do so.
Seeing as I’ve been doing short-form articles for the past couple, this one seemed like a lovely tip to share with my readers, as I’m sure some will not know this.
Of course, you’ll need an open terminal for this. Press CTRL + ALT + T and your default terminal should open.
With your terminal now open, we’ll use the ‘ls’ command to list the contents of your present working directory. Ready?
ls
Now, that’ll be saved to your Bash history file. What if you don’t want it saved to that file? Just add a space in front of it, like so:
ls
I don’t know how well that will show up, but trust me when I say there’s a space there. By adding that space, I’ve effectively told the terminal to not save that entry into the history file.
See? Pretty darned simple!
So, yeah… I’ve been doing a few short articles and this seemed like the perfect article to do in that format. It’s something not everyone knows, isn’t made immediately obvious, and will likely be of importance to someone. If you’ve ever wanted to not save a command to bash history, that’d be how you do it.
I could have added a few more bash tricks and turned this into a longer article, but I’m having fun with this shorter stuff right now. If you prefer the longer articles, don’t worry. They’ll be back soon enough. These short articles are fun and easy, and they have the added benefit of keeping me interested in writing these silly things.
Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.
Today we'll cover one way to enable or disable your network interface in the Linux…
Today's exercise is a nice and simple exercise where we check your NIC speed in…
Have you ever wanted to easily monitor your wireless connection? Well, now you can learn…
I think I've covered this before with the ls command but this time we'll count…
Today we'll be learning about a basic Linux command that's known as 'uname' and it…
If you've used hardinfo in the past, it may interest you to know that hardinfo…