Linux · Server

Update the nano Text Editor on Ubuntu

In this entry I will guide you to update the standard terminal editor used by Ubuntu from its classic 2009 revision to its latest release.

GNU nano is the default terminal text editor for Ubuntu but is also used as a fallback editor in case your system fails. This might be one of the reasons why the default nano version is held back and why you may not want to apply this update.

nano -V

nano -V default

At the time of updating this article in Jan. 2018, a visit to the official GNU nano homepage reveals the current stable nano version is 2.4.3 2.9. While many Ubuntu installs are running 2.2.6. So let’s update!

Compile and install

First we remove the existing nano package and install some dependencies that we will need to compile nano from source. If you’re curious the libmagic-dev package is used to auto-detect file types for nano’s syntax highlighting feature.

sudo apt-get build-dep nano
sudo apt-get install libmagic-dev

Now download the nano 2.9 source and extract it.

cd ~
tar -xf nano-2.9.3.tar.gz
cd nano-2.9.3

Run the configuration script, I apply the following compile option.

./configure --enable-utf8

–enable-utf8 turns on UTF-8 character encoding support which is in widespread use.

You can see a complete list of options available by using help.

./configure --help

Now compile and install nano. You will see a lot of debugging feedback that can safely be ignored.

sudo apt-get remove nano
sudo make install

make install sample

When it is done let’s test nano to make sure it installed correctly.

Bash shell users will need to reload .bashrc.

source ~/.bashrc
nano -V


Change the default settings

The nano install copies a sample settings file into the etc directory. We will duplicate this file to our home directory and apply our own custom settings.

cp ~/nano-2.9.2/doc/sample.nanorc ~/.nanorc
nano ~/.nanorc

In nano tap Ctrl _ (underscore) and type 258 to jump to line 258. Un-comment the following text and exit nano.

# include "/usr/local/share/nano/*.nanorc"

Reload and again edit .nanorc but now it will be in colour.

nano ~/.nanorc

Go through the .nanorc<em> settings file and un-comment any features you want turned on. I personally enable.

set boldtext
set constantshow
set linenumbers
set mouse
set smarthome
set smooth
set titlecolor brightwhite,blue
set statuscolor brightwhite,green
set selectedcolor brightwhite,magenta
set numbercolor white
set keycolor cyan
set functioncolor green

Save your settings by pressing CTRL and the letter o and you are done!gnu_nano_270


If you ever find yourself wanting to revert back to the original nano installed by Ubuntu, you can do the following removal.

apt-get autoremove nano

You may need to remove the default configuration that was installed by nano 2.4.2 as it contains invalid directory paths.

sudo rm /etc/nanorc

Then install classic nano.

sudo apt-get install nano
nano -V

2 thoughts on “Update the nano Text Editor on Ubuntu

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s