How to Use Nano Command Line Text Editor in Ubuntu 18.04 | 16.04

If you’re a new user or student planning on learning how to use and manage Linux systems, the easiest place to start might be on Ubuntu Linux OS… Ubuntu is an open source Linux operating systems that runs on desktops, laptops, server and other devices…

The same way one uses a mouse and keyboard to manage files and folders or perform others simple tasks on Microsoft Windows OS, Ubuntu Linux makes that easy as well, especially for new users…

This brief tutorial shows students and new users how to use the nano command on Ubuntu to edit text files or create new ones on the command line…

There are many command line text editors available to Linux users… however, nano has become the default because how easy it is to learn and manage…

When you’re ready to learn how to use the nano commands, follow the guide below:

About nano command:

The nano command is an easy to use command line text editor for Linux systems… It is included on all Linux operating systems, including Ubuntu and comes with all basic functionality of a regular text editor…

The same way you use your mouse and keyboard to view or edit files with Notepad or Notepad++ on your desktop, nano is the way to do it on the command line…


The syntax is the rule and format of how the nano command can be used… These syntax options can be reordered, but a straight format must be followed.,.

Below is an example syntax of how to use the nano command….



The command line options are switches or flags that determined how the commands are executed or controlled… they modify the behavior of the commands… they are separated by spaces and followed after the commands…

Below are some options of the nano command:

   FILES…Replace FILES….. with the files you wish to edit..
-A, –smarthome
Use the -a or –all to Enable smart home key
-B –backupUse the –B or –backup to Save backups of existing files
-g, –showcursorUse the -g or –showcursor to Show cursor in file browser
-R, –restrictedUse the -R or –restricted to enable Restricted mode
-L, –nonewlinesUse the -L or –nonewlines Don’t add newlines to the ends of files
–helpDisplay a help message and exit.


Below are some examples of how to run and use the nano on Ubuntu Linux…

If you want to view an existing file or create a new file that’s not already there, you run the commands below:

If filename.txt isn’t an existing file at that location, a new file will be opened… when you save your changes, a file will be created…

nano filename.txt

This will open a new editor window when you can begin editing the file…

Nano Ubuntu Command

At the bottom of the editor windows, there are basic shortcuts you can use the save, replace and spell check using nano editor…

If you open an exiting file and want to search for a particular text and go to it, you use the command shortcut below:

ctrl + w

They type in the search term you’re searching for and press Enter… The cursor will move to the first match text in the file… To move the the next match, you type the command shortcut below:

alt + w

If you’re not logged in as root, or don’t have write access to the file you wish to edit, then run sudo with the nano command on file that requires root access…

sudo nano filename.txt

To save the changes you’ve made to a file, type the shortcut below:

Ctrl + o

If the file you changed doesn’t already exist, it will be created once you save it…

If you want to exit nano, type the shortcut below:

Ctrl + x

If the changes you made to a file are now saved before exiting,  you’ll be asked whether you want to save the changes…

When you run nano with the –help option, you’ll see the help text below:

Usage: nano [OPTIONS] [[+LINE[,COLUMN]] FILE]...

To place the cursor on a specific line of a file, put the line number with
a '+' before the filename.  The column number can be added after a comma.
When a filename is '-', nano reads data from standard input.

Option		GNU long option		Meaning
 -A		--smarthome		Enable smart home key
 -B		--backup		Save backups of existing files
 -D		--boldtext		Use bold instead of reverse video text
 -E		--tabstospaces		Convert typed tabs to spaces
 -F		--multibuffer		Read a file into a new buffer by default
 -G		--locking		Use (vim-style) lock files
 -H		--historylog		Log & read search/replace string history
 -I		--ignorercfiles		Don't look at nanorc files
 -K		--rebindkeypad		Fix numeric keypad key confusion problem
 -L		--nonewlines		Don't add newlines to the ends of files
 -M		--trimblanks		Trim tail spaces when hard-wrapping
 -N		--noconvert		Don't convert files from DOS/Mac format
 -O		--morespace		Use one more line for editing
 -P		--positionlog		Log & read location of cursor position
 -Q 	--quotestr=	Quoting string
 -R		--restricted		Restricted mode
 -S		--smooth		Scroll by line instead of half-screen
 -T <#cols>	--tabsize=<#cols>	Set width of a tab to #cols columns
 -U		--quickblank		Do quick statusbar blanking
 -V		--version		Print version information and exit
 -W		--wordbounds		Detect word boundaries more accurately
 -X 	--wordchars=	Which other characters are word parts
 -Y 	--syntax=		Syntax definition to use for coloring
 -a		--atblanks		When soft-wrapping, do it at whitespace

That’s it!

Congratulations! You’ve learned how to use the nano command text editor to view and create files…

You may also like the commands below:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.