In today’s article, we’re going to cover how to fix terminal command mistakes. While this may sound complicated, it’s actually very easy. As such, it should be a pretty short article. There’s not a lot to it, so it’s not hard to cover.
When you type a command in bash using systems, the command gets saved to the ~/.bash_history file. You can then use the up arrow and use that command again without having to type it again. We’ve also covered how to delete a ~/.bash_history entry. There have been a few articles on this subject.
So, with all that, this shouldn’t be a completely foreign article. It should be something that’s more or less familiar to new people and my regular readers. Because of this, it’s going to be a pretty short article.
Amusingly, it’s not that I want to write an easy/short article today, it’s just that this topic isn’t all that complicated. I was perfectly willing to write a longer article.
So then, let’s have a short article! Let’s learn how to…
Fix Terminal Command Mistakes:
This article requires an open terminal, like many other articles on this site. If you don’t know how to open the terminal, you can do so with your keyboard – just press
With your terminal now open, type an incorrect command. For example, you could try entering the following command to change to the
As you can guess, that’s likely to throw some sort of error. The command you’re actually intending to type would have been
cd ~/Downloads. Well, you can fix it and run it automatically. Try this:
Tada! It should correct the previous command and then handily run the command on your behalf. To show you what I mean, here’s an image:
Yup, it just takes a couple of carets and spelling the proper command. It’s not all that hard to fix terminal mistakes. Just to be clear, bash will store both the original mistaken command and the properly fixed command in your
~/.bash_history. But, you can still use the arrow key to go back to either in the future. Of course, you can always delete the bash history entry if you want.
See? It is indeed a short article after all. It’s not all that complicated to fix terminal command mistakes, so it’s easy to cover. It’s that how to fix terminal command mistakes is just not something that many Linux users, especially new users, know they can do. Well, you can – and it’s really simple.