Software

Let’s Install Nano (With Some Bonus Information)

This site mentions Nano quite a few times but never tells you how to install Nano. Today, this changes! Today, we make sure you have Nano available! Not all distros have Nano installed by default, but in pretty much all distros Nano would be a useful tool to have.

The Nano text editor (GNU nano) has been around since 1991, 21 years at the time of writing. I’ve written about it a few times, but nothing major. I think the most I’ve written about it was in an article about My Three Favorite Text Editors. If it’s not obvious from all of this, Nano is one of my favorite editors.

Rather than gush, I think I’ll just explain why I like Nano. It’s simple. When making quick edits to text from the terminal, I don’t need to know things like :q! just to exit the program, I can see how to exit the program because it’s written at the bottom. Nano has plenty of features, even a viable, albeit not great, find-and-replace function.

In Nano, you can do the obvious text manipulation tasks – like cut and paste, of course. You can jump to line numbers and all that stuff. At the end of the day, it’s a great terminal text editor that just works and is simple to use. If you’re new to Linux and think Nano looks daunting, you should introduce yourself to Vim or Emacs!

I like simplicity and effectiveness. For the things I do in that situation, quick file creation or editing, it works just fine. I don’t need anything more robust – or more complex.

Install Nano:

Sadly, Nano doesn’t come installed by default on all distros. It’s a tiny application that just works, so I’d be happy to see it as the default (or available by default) on more distros. Until that time, we’re stuck installing it ourselves.

Fortunately, there’s not much trouble installing Nano in the major distros. You just need to start with an open terminal. You can open one with your keyboard. Just pressing CTRL + ALT + T should open up your default terminal. Pick the appropriate command below and it should install nano for you.

Arch/derivatives:

sudo pacman -S nano

RHEL/Fedora/derivatives:

sudo dnf install nano

OpenSUSE/derivatives:

sudo zypper install nano

Debian/Ubuntu/derivatives:

sudo apt install nano

For everyone else, hunt around or download and compile it from source

Once you have Nano installed, you’ll need to know how to use it. Fortunately, for most users and most uses, there are a few shortcuts to learn and that’s it. For most people, you don’t need to know a whole lot for basic functionality. As you’re making basic edits, that works. It’s pretty easy.

My usual blurb (that I cut and paste) to tell people how to save a file in Nano is just this little snippet:

press CTRL + X, then Y, and then ENTER

(Which, when formatted properly, comes out looking like “press CTRL + X, then Y, and then ENTER“.)

And, that’s it. That’s pretty much all you need to know when making quick text edits in Nano. However, there’s so much more to Nano than you might be expecting.

Bonus Nano Info:

While Nano is simple, it is deceptively simple. If you type nano into the terminal, you’ll see just a few options on the bottom. And, like I said, that too is a bit deceptive. With your terminal still open, type the following:

man nano

As you can see, there are a whole lot more options. There are far too many options for me to even begin to touch on them, and you won’t need any/most of them for the basic text editing for which we usually rely on Nano.

You can open a file with Nano like this:

nano <existing_file_name>

You can also just open an instance of Nano and name the file when you’re closing it. If you want to create the title when you’re starting, you can just use:

nano <new_file_name>

That’ll auto-populate the name field when you’re saving the file. So, you can use Nano to create a new text file easily enough.

While you’re in there, you can use CTRL + W to search. If you then use ALT + W to go to the next instance of the text you searched for. Searching is even kind enough to support regex, case-sensitive searches, and can even be used to replace text.

At the bottom of the output, you’ll see directions that tell you how to use Nano. The ^ means you use the CTRL as the modifier. The M (such as M-A to undo) means you use the ALT as the modifier. So, to cut, you’d use CTRL + K and to undo something you’d use the previously mentioned ALT + M.

You’ll get used to it, I promise. You’ll learn it much faster than you’ll learn Vim or Emacs – but those too have their place. I wouldn’t want to spend hours in Nano, but it’s great for a few minutes when you need to make a quick edit.

Like I said, this is just touching on the surface. Look at the man page (man nano) for more information. There’s a lot to this little editor and the advanced features are there if you need them. For example, I often open files with the -l flag so that it will show line numbers.

Closure:

Yup… There’s another article. This one tells you how to install Nano and has some bonus information about how to use Nano. I didn’t have time (and this isn’t that kind of site) to tell you about all the other nano options. Those options are just a man nano command away, should you want to use them.

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.

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…

7 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…

7 months ago

Easily Monitor Your Wireless Connection

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

7 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…

7 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…

7 months ago

hardinfo Has Been Rebooted As hardinfo2

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

7 months ago