Nano is a user-friendly, simple and WYSIWYG(What You See Is What You Get) text editor, which improves the features and user-friendliness of UW Pico text editor. Unlike vim editor or any other command-line editor, it doesn’t have any mode. It has an easy GUI(Graphical User Interface) which allows users to interact directly with the text in spite of switching between the modes as in vim editor.
Installing Nano Text Editor
Nano is generally by default available in many Linux distributions but in case, it is not installed you may install the same using the following commands.
$sudo apt update
In case of Debian/Ubuntu
$sudo apt install nano
In case of CentOS/Fedora
$yum install nano
Working with Nano Text Editor
1. To create and open a new file.
The above command will open a new file with new_filename as shown in the output. In case the file already exists it will open the same and in case the file is not there in the current directory it will create a new one. At the bottom of the window, there is a list of shortcut keys for nano.
2. To save a file
It will ask you for the filename. In case, you want to save the changes to a new file or want to create a new file then change the name else keep the name same.
As soon as you will press enter key, then In case, you have changed the name of the file then it will save the file with a new name and if not then it will save the changes to the current file.
3. To cut paste in a file. Ctrl+o is used to cut and Ctrl+u is used to paste the text.
- To cut and paste a whole line. Move to the line which you want to cut then press Ctrl+k. Now the line is moved to clipboard, To paste it, go to the position where you want to paste and then press Ctrl+u
- To cut and paste the selected text. Select the text which you want to cut then press Ctrl+k. Now the text is moved to clipboard. To paste it, go to the position where you want to paste and then press Ctrl+u.
4. To search a word in a file. Ctrl+w is used.
It will ask for a word to search for.
Enter the word
It will search for the word and will place the cursor in the first letter of the first occurrence of the word.
5. To enable spell check in nano. First, install the spell check package.
$sudo apt install spell
It will then ask for the password then enter the password. Then press y and then press enter.
- To do spell check first press Ctrl+t
- Now it will ask you to replace the incorrect words
- Enter the word to replace with there
- As soon as you will press the enter key
- How to find time taken by a command/program on Linux Shell?
- Terminal Mail and Linux Security Mail
- Linux Virtualization - Chroot Jail
- Linux Virtualization : Linux Containers (lxc)
- Linux Kernel Module Programming: Hello World Program
- Formatted text in Linux Terminal using Python
- Some useful Linux Hacks
- Daily life Linux Commands
- Basic Linux Commands for day to day life
- Initializing and Cache Mechanism in Linux Kernel
- How to add "graphics.h" C/C++ library to gcc compiler in Linux
- Working with Magic numbers in Linux
- Reset a lost Linux administrative password and Explanation
- dup() and dup2() Linux system call
- Encrypt/Decrypt Files in Linux using Ccrypt
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.