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

Installing Flatpaks In Linux

Today we're going to have a pretty easy article where you'll learn about installing Flatpaks…

2 days ago

A Quick Look At The Shutdown Command

This is going to be just a quick article about a command many of you…

4 days ago

Setting Up Coding Environments on Linux for Educational Use

With so many strong attributes, such as robustness and flexibility, Linux stands as a powerful…

6 days ago

View Detailed Hardware Information

There are many tools for showing your hardware information and today we'll get to view…

1 week ago

How To: Install Wine In Lubuntu

Today's article isn't going to be complicated or long as we are going to cover…

1 week ago

Update Python Packages (PIP)

We've had a run of Python packages recently and you can tell that I'm a…

2 weeks ago