Category: CommunityEditing Text On The CentOS Command Line

Share this post...Tweet about this on TwitterShare on Google+0Share on Facebook0
Text Editor

Photo Credits: n3wjack

Most of you who are using CentOS as a server are going to frequently come across situations where editing configuration files is necessary. Almost all configuration of Linux servers and their applications is done via text-based config files. If you’re going to be tangling with text on the command line, you’ll need to get to grips with the text editors that are available for the command line.

This is a topic that has started many a flame war, so we’re going to tread lightly. All of these editors have their strengths and weaknesses, and all of them are excellent pieces of software that in the right hands can do magic.


Starting up vim (or vi) and staring at the results in confusion before giving up is something of a right of passage for Unix users. If the new user can figure out how to actually type something, they’re often left tearing their hair out when it’s not remotely clear how to save what they typed.


Vim is not user-friendly for newbies, but, after climbing the rather steep learning curve, it’s an extremely powerful text editor and it very popular among experienced system administrators.

CentOS users will find vim pre-installed on their servers.

Two things to note about vim are, firstly, it has a modal interface. Depending on which mode the text editor is in, it will behave differently in response to commands. The main modes are “normal mode”, which is the default mode when vim starts up and is also called “command mode”. In this mode, vim interprets keystrokes as commands, not as text to add to the document. “Insert mode”, which is achieved by pressing “i” while in command mode, is for text entry. You can press escape to get back to the command mode.

The second thing you’ll need to know is how to quit vim: press escape to make sure you’re in command mode, and then enter “:q!”. This quits immediately without saving. To save first, enter command mode and type “:wq”, which saves (writes) and then quits.

Vim is hard going at first, but if you stick with it and learn the most common commands you’ll find it a very powerful text editor which will reward the effort put into learning how to use it properly.


Emacs was vim’s rival in the editor wars. It’s a wonderful piece of software and very different from vim. Emacs doesn’t have a modal interface, and it also goes against the Unix philosophy of “do one thing well”. Emacs does just about everything you might want to do with text, up to and including email.

While Emacs may seem more intuitive to users not familiar with modal interfaces, it has its own quirks, including a vast array of complex keyboard shortcuts, although learning the core set of Emacs commands is no more difficult than learning Vim’s commands.

Emacs is in the base repo, so it’s only a yum command away.


Nano is a lot closer to what most users are already familiar with. It is a much simpler beast than either Vim or Emacs, and is fairly straightforward to use. As with most command line tools nano is controlled by keyboard shortcuts, but they are fewer and more intuitive than the more powerful editors.


If all you need to do is a quick config file edit, then Nano is more than capable, and won’t trip you up quite so often.

Nano isn’t installed by default on CentOS, but it is in the base repo.

The best advice for users new to the command line is to try out Vim and Emacs to see which fits your way of working, and, if they don’t suit you, you can try something that’s a bit easier to get along with, like nano.

There are also some other options out there — share any other recommendations in the comments!

LinuxSysAdmin ToolsSystem Administration
Oct 14, 2013, 12:45 pmBy: InterWorx (4) Comments
  1. sainath tare: thanks very helpful nano i like in that
    May 4, 2016 at 7:39 am
  2. Fajar: Nano is best :D
    February 2, 2016 at 1:58 am
  3. shelong: Nano comes with the ability to syntax highlight multiple different text files. It can also rebinds all its command to whatever we like, plus has mouse support. That's definitely a lot to play with before feeling limited.
    July 1, 2015 at 8:45 pm
  4. Michael Dance: I have to say, I love my Nano :)
    November 20, 2013 at 2:34 pm

Leave a Reply
Surround code blocks with <pre>code</pre>

Your email address will not be published.


Sign up to receive periodic InterWorx news, updates and promos!

New Comments

Current Poll

  • This field is for validation purposes and should be left unchanged.