How to use the Nano text editor

Created by Jordy Leffers at 06-12-2017 11:05:35 +0100

Are you new to the, somewhat scary looking, Linux command line? And just want to know how to edit that simple text file? Search no longer. In this guide we'll go over how to install and use Nano: One of the most popular and beginner friendly text-editors for Linux out there. 

This tutorial is based on the cloud containers created on the page. This means that you are by default the root user, so all of the commands below don't make use of sudo. If however, you're not the root user on your system, you'll have to add "sudo" in front of the commands found in the guide below.

On many Linux distributions the editor is already installed by default, if that happens not to be the case, you can install it with this command:

apt install nano

You can run nano by typing the program's name, followed by the file name you want to edit. If the file doesn't exist, it will create the file.

nano newFile

You could also open a file in another directory by inserting the path as well. Again, if the file in this folder does not exist, nano will create it for you:

nano /path/to/filename

You should now have an empty (black) sheet or "buffer" in front of you. 

On the top, in the center, you should find your file name. On the right, it'll say "modfied" if the file was modified after it was last saved, and on the left you'll see your current Nano version.

On the bottom of the page there are some shortcuts, that we'll go over as well.


In this editor you can simply start typing and make any edits you want. On the bottom of the screen you see some often used shortcuts. We'll first go over how to save, or discard our changes and then we'll get to some other nifty ones.

You can hide/ the shortcut bar by pressing  Alt + X if you feel comfortable enough.

The shortcuts in the bottom of the screen are all capitalized. You don't have to do this Ctrl + X, for help, is not the same as Ctrl + Shift + X . The keys you press on your keyboard are lowercase.


In order to save your file, pres Ctrl + O. In the shortcut bar this option is referred to as "writing out".


You can leave the editor by pressing Ctrl + X. If you haven't saved your last modifications, you'll be prompted whether to save or discard your changes. Press "Y" to save, "N" to discard your changes to the document. Next, it will ask you what name you want to give the file. Either change it, or press enter to use the same name and overwrite the file.


Nano has a screen that will help you remember additional shortcuts. You can acces this screen by pressing Ctrl + G. You'l see ^ and M- mentioned a lot. The ^ symbol refers to Ctrl; The M- symbol means Meta which is Alt. In this tutorial we'll simply use the normal Ctrl and Alt notation.

Pres Ctrl + X to leave the help screen.


What follows is a list of navigation shortcuts, for navigating within the text file. Of course we all have our arrow-, home- and end keys, but these tend to be faster. In the beginning you might still have to think a lot in order to use these shortcuts effectively, but when you have a little more experience these tend to be faster:

Right/Forward: Ctrl + F

Skip one word Forward: Ctrl + Space or Ctrl + Arrow right

Left/Backward: Ctrl + B

Skip one word Backward: Alt + Space  or Ctrl + Arrow left

Line up: Ctrl + P

Line down: Ctrl + N

End: Ctrl + E

Home: Ctrl + A

Page-up: Ctrl + Y

Page-down: Ctrl + V

Jump to line number: Ctrl + -  Now enter the line you want to jump to, if you add a comma you can even jump to the designated column!


One of the most important functions of a text editor is its ability to be able to copy and past pieces of text/code. In order for us to be able to copy anything at all however, we need to first select text. So first we select text by pressing Ctrl + 6 (^), this will set a mark. Wherever you move your cursor now will select every piece of text from your mark up until (but not including) your cursor. Next, you can de-select by "un-setting" the mark through pressing Ctrl + 6 again. 

Copy: Alt + 6

Cut: Ctrl + K

Pasting: Ctrl + U

You can search the text for a string. Type Ctrl + W to open up this search bar. Within square brackets you will see your previous search. Your cursor will be sent to the beginning of the nearest string that matches your search.

Thank you for reading this tutorial, I hope it helped you learn something concerning Nano and you've become a bit more comfortable using it. 


Comments are turned off.