Nano text editor comes up with many powerful features. It allows you to create and edit various files on your Linux based computers or server. It is considered as the most easiest tool for editing. In this tutorial, we will see how to install Nano text editor on Ubuntu.
Nano text editor is suitable for both beginners and advanced users. Nano text editor allows you to copy, paste, select, search and edit the file. Furthermore, there is a bottom bar at the bottom of the editor screen that shows useful shortcuts.
In Nano, you don’t have to switch to an edit mode like Vim. You can directly interact with the text.
Before we learn how to install Nano text editor on Ubuntu, make sure that you have the access to Ubuntu Server.
Now, update your server by running:
sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade && sudo apt-get autoremove
How to Install Nano Text Editor
To install Nano text editor on Debian or Ubuntu server, execute the following command:
sudo apt-get install nano
With this, you have successfully installed the Nano text editor.
How to Use Nano Text Editor?
In this part, we will learn how to operate Nano text editor by opening, closing, searching and replacing text.
Create a New File
nano to open a new blank file. You can press (CTRL+X), text editor will ask whether to save or discard the file. To save modification, press “y”, it will ask you to name the file. Type the name of the file and press enter to save the changes.
Similarly, if you press “n” or “c”, this will discard changes or cancel any changes made in the file respectively.
Opening and Closing the Nano Editor
nano and then the
filename to open Nano to edit a certain file.
However, to open an existing file in another directory, you must include the path where the file is located.
If you want to edit the default
index.php file your website, you can include the path of the default directory of your website and file name with the file extension.
Alternatively, you can also navigate to the default directory of your website and use
nano to edit the
Search and Replace Command
CTRL + W to search in the text. Insert your keyword or string and press Enter. To continue searching for the same keyword, use
ALT + W.
If you are aiming to find and replace a text, press
CTRL+W to enter the text that you want to search and then replace it by pressing
CTRL+R. Now the text editor will take you to the first instance of the text. Now you have two option. Either you can press Y to replace one text or A to replace all the instances.
In case you want to cancel the current process, you can press
CTRL + C to discard any changes.
To select text, move the cursor to the beginning of the text and then press
Alt+a. This command will set mark for selection. Now, with the help of the nudge keyys (arrow keys) move the cursor till the end of the text you want to select. This will highlight the selected text.
In case you want to cancel the selection press
Alt+6 to copy the selected text to the clipboard.
Ctrl+k will cut the entire selection of text.
Now move the cursor to the line and press
Ctrl+k to cut whole lines. To cut multiple lines, press
Nano Text Editor Commands Shortcuts
|CTRL + A||To jump to the beginning of the line.|
|CTRL + E||To jump to the end of the line.|
|CTRL + Y||To scrolls down the page.|
|CTRL + V||To scrolls up the page.|
|CTRL + G||To see the help window that will help you with all the available commands.|
|CTRL + O||To save the file. The Nano text editor will ask you to edit or verify the file name that you want to keep.|
|CTRL + W||This command will help you search for any specified phrase in your text. You can press |
|CTRL + K||This will cut the entire selected line to the cut buffer (similar to clipboard).|
|CTRL + U||It is used to paste the text from the cut buffer into the selected line.|
|CTRL + J||It is used to justify the current paragraph.|
|CTRL + C||It shows the current cursor position in the text (line/column/character).|
|CTRL + R||It opens a file and inserts it at the current cursor position.|
|CTRL + X||To exit Nano text editor. Once you press this command, nano will prompt a save request in case you have made any changes inside file.|
|CTRL + \||It replaces the string or a regular expression.|
|CTRL + T||This command will Invoke the spell checker, if it’s available.|
|CTRL + _||It helps you go to the specified line or column number.|
|ALT + A||To select text. You can combine this command with several other commands to perform certain actions.|
You may also want to check out nano Command Manual.
How to Remove/Uninstall Nano Text Editor from Ubuntu?
Simple Nano Uninstall
To uninstall the Nano text editor, you just need to follow the given instructions:
sudo apt-get remove nano
This will remove just the nano package itself.
Uninstall nano and its dependencies
To uninstall nano and its dependencies, run:
sudo apt-get remove --auto-remove nano
This command removes the nano package and any other dependencies that are no longer required. This will help you free up the space in your machine or server.
Purging your config/data too
If you want to delete your local/config files for nano, you can run:
sudo apt-get purge nano
sudo apt-get purge --auto-remove nano
Caution! Purged config/data can not be restored by reinstalling the package.
We successfully learnt how to install Nano text editor on Ubuntu with it’s uses. We also covered some useful commands and editing tips to improve the workflow while working on Ubuntu Linux.
At the very end, we also covered how to uninstall Nano text editor on Ubuntu.
I hope you would find this tutorial useful. Do put your feedback in the comment section below.
Also, let me know about the topics that you want to learn more about.