Many times, working in command line, many times we have to create and edit files. Also working in the server by ssh, we also need to create and edit files. There are many command line text editor available to do these type of work. Vim and Emacs are the most popular command line text editor but they are difficult for the new users. There is also one text editor available for that.
Nano or GNU Nano is a simple and user friendly text editor for Unix and Linux systems which provides command line interface. Nano provides all basic features like text editing, search and replace, go to line and column number, auto-indentation, feature toggles and filename tab completion. Most of hosting providers and linux distribution comes preinstalled with Nano text editor.
In this article, we will discuss on how to install and use Nano text editor in Linux. Before we start, make sure you have basic knowledge of Terminal or CMD. If you are working in remote server, make sure you have already connected with server through ssh connection.
Nano text editor comes pre-installed on macOS and most Linux distros. If you want to check if it is installed on your system or not, use this command.
You will see bellow response, if you have already Nano text editor installed.
You can also install Nano text editor with bellow commands.
Debian based Linux system
sudo apt-get install nano
Fedora and CentOS Linux system
sudo yum install nano
Most of commands for Nano text editor are like:
nano [OPTION]... [FILE]
To create or edit existing files, use bellow command.
If file is already exist, it will open for edit, other wise new file will create when you save the file.
Run the command nano in the Terminal and bellow window will appear. At the bottom of the window, there are some shortcuts available. All the shortcuts with
^ (caret) signs indicates
CMD key while some shortcuts with
M- (Meta key) indicates
Here are some Standard commands for Nano text editor:
CTRL + G shortcut displays all shortcuts and help text.
If you want to find some text, first press
CTRL + W key, then input the search keyword. Press
ENTER to find the first matched text. Then press
ALT + W to go to next matched text.
To replace text, first press
CTRL + \ to enter the text that you want to replace with keyword and hit
ENTER. This will ask to replace the first matched text with
To select the text, first press
ALT + A key, this will start selecting. Now press
ARROW KEYS to move the cursor to select text and then press
ALT + 6 key to copy or
CTRL + K to cut the selected text. Press
CTRL + U to paste the copies text.
CTRL + _ to go the specific number line.
To save the file with changes, press
CTRL + O. If you want to exit Nano text editor, press
CTRL + X shortcut. If there are some changes, it will ask to save changes with
CTRL + C to get Cursor's current position or cancel the current active shortcut.
If you want to scroll to the next page, press
CTRL + Y or previous page with
CTRL + V.
There are also some options you can pass to do following changes.
This is the basic shortcuts you can use the GNU nano text editor. For more information about Nano visit the official nano documentation page. I hope this article will help you.
Also if you have any question, feel free to comment in the bellow comment section.
Failed to listen on 127.0.0.1:8000 (reason: Address already in use)Laravel is the most popular and open-sou...
Django - How to Create Custom Login PageWithin this article we will look at how...
Python String Zfill Method ExamplePython zfill() is an inbuilt python stri...
How to Merge two Collections in LaravelLaravel collection class Illuminate\Supp...
Laravel Eloquent Has One of Many Relationship Tutorial with ExampleLaravel provides eloquent relationship w...