How to Use Nano command Line Text Editor in Ubuntu Linux

The nano command is an easy-to-use command line text editor for Linux systems.

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.

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.

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.

Syntax:

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.

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

Options:

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 –backup Use the –B or –backup to Save backups of existing files
-g, –showcursor Use the -g or –showcursor to Show cursor in file browser
-R, –restricted Use the -R or –restricted to enable Restricted mode
-L, –nonewlines Use the -L or –nonewlines Don’t add newlines to the ends of files
–help Display a help message and exit.

Examples:

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
 -C
 -D		--boldtext		Use bold instead of

That’s it!

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