Command Line

Fix Terminal Command Mistakes

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 CTRL + ALT + T and your default terminal should open.

With your terminal now open, type an incorrect command. For example, you could try entering the following command to change to the ~/Downloads directory:

cds ~/Downloads

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:

^cds^cd

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:

See? It changes ‘cds’ to ‘cd’ and runs the command on your behalf. Pretty nifty, huh?!?

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.

Closure:

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.

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 own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

KGIII

Retired mathematician, residing in the mountains of Maine. I may be old and wise, but I am not infallible. Please point out any errors. And, as always, thanks again for reading.

Recent Posts

Enable/Disable Your Network Interface

Today we'll cover one way to enable or disable your network interface in the Linux…

5 months ago

Check Your NIC Speed In The Terminal

Today's exercise is a nice and simple exercise where we check your NIC speed in…

5 months ago

Easily Monitor Your Wireless Connection

Have you ever wanted to easily monitor your wireless connection? Well, now you can learn…

6 months ago

Count The Files In A Directory

I think I've covered this before with the ls command but this time we'll count…

6 months ago

Get System Information With The ‘uname’ Command In Linux

Today we'll be learning about a basic Linux command that's known as 'uname' and it…

6 months ago

hardinfo Has Been Rebooted As hardinfo2

If you've used hardinfo in the past, it may interest you to know that hardinfo…

6 months ago