How to Install and Use Nano (aka pico) text Editor on a CentOS Linux server
Why Use GNU Nano
Vi (or Vim) is a very powerful text editor that comes installed by default with most versions of Linux. It’s also very overwhelming when you’re first learning it! That’s why I like to install Nano in whatever Linux environment I happen to be working in. Nano is based on the Pico editor, which was originally used in the Pine email client (Pico meaning “PIne COmposer).
To install Nano in CentOS 6.2, you’d type
yum install nano into your console. By default it will install to the /usr/bin directory. If you get an error that say something like You need to be root to perform this command, you will need to type
sudo yum install nano, if you have su privileges. If you do not, contact your system administrator and ask them to install it for you
Once installation is complete, you can freely edit your text files with Nano by typing
nano filename.txt when your in the same directory as
filename.txt. Alternatively, if you’re trying to edit a file in another directory, you could employ it with
All operations are done with CTRL key combinations. For example to save the file, you simply hit
CTRL+O (“O” stands for write-Out). To exit, simply hit
CTRL+X (“X” stands for eXit). If you’ve forgotten to save your changes, Nano will be nice enough to ask you if you’d like to save the file before exiting. You can also open a file when the program is running with
CTRL+R (“R” stands for “Read file”). Most of the frequently used commands are always displayed on screen as well. If you’re new to Linux, this should make text editing much easier.
How To Setup and Use Nano as the default text editor
If you want to go a bit further, you can set up Nano as your default text editor in Linux. To do so, you simply need to add the following code to the .bashrc file in your home directory:
The next time you login, Nano will be your default text editor. So for example, when using Git you don’t need to remember how to save & exit with Vi any more. You’ll have all the commands you need to know displayed on your screen at all times.
Alternatively, if you’d like to change only the Git editor to Nano, you’d add
export GIT_EDITOR=/bin/nano to
You can visit the Official Nano Homepage here. If you don’t have YUM installed on your machine, you can download it here. It’s available in .RPM, .TAR.GZ, .ZIP, and in several binary formats for Linux, and even Windows.
Installing Nano on Windows
This has been pretty straightforward for me. You’ll need to download the Nano for Windows ZIP file. After that, in my experience all that’s been required is to extract the ZIP file to C:\windows (or wherever you happen to have Windows installed), and since it’s in your path, you’ll be good to go!
Compiling from Source
Compiling nano from source is easy, if you have the right tools on your system. You’ll need at least a C compiler, make, and ncusrses-devel package. You can download the source with
wget https://www.nano-editor.org/dist/v2.7/nano-2.7.4.tar.gz which will download a Gzipped file which includes the source code. Then ungzip it in the current folder with
tar -zxf nano-2.7.4.tar.gz. Enter the directory that was createded by expanding the source with
At this point you’re ready to configure the source for compiling. This is done by running
./configure in the same folder as the source. You’ll see a bunch of lines go by, mostly starting with “checking for”. As long as it exits without an error, you’re ready to start compiling. This is done in the same folder by simply typing
make. Again, a bunch of stuff will go flying by, and if it exits without any errors, you can now install the program with
sudo make install which should install it in the directory at /usr/local/bin/
Happy text editing! Please feel free to leave any tips you might have for other users in the comments.
Update January 7, 2015
The original post only mentioned CentOS 6.2, but after some testing I can say that this also works on CentOS 7, RedHat, and Fedora for those of you who may be using more modern systems.
UpdateMay 7, 2017
If you’re used to typing `pico` instead of `nano` you can save the hassle by adding
alias pico='nano' to your ~/.bashrc or ~/.bash_profile files to load the alias at every login.
There are no trackbacks on this entry.