Nano is the most known text editor that comes by default with the Linux distributions, especially with the Debian-based distributions. Nano is the GNU Nano text editor used to edit text files on Linux distributions.
It is the replacement of the Pico text editor and introduced some new features. These new features include syntax coloring, auto-indentation, and file locking.
Nano text editor comes pre-installed on Debian’s latest version. If it is not installed, then install it with the methods explained in the next sections of this blog. This article also explains the basic shortcut keys and commands to use the nano text editor following the outline:
- What are the Installation Methods of Nano Text Editor on Debian
- Method 1: Install the Nano Text Editor from Debian’s Package list
- Method 2: Install the Nano Text Editor from its Source Code
- What are the Basic Shortcut Keys of the Nano Text Editor
- What are the Commands to Use the Nano Text Editor
- How to Uninstall Nano on Debian
Let’s start the post with the installation methods of the nano text editor.
What are the Installation Methods of Nano Text Editor on Debian?
The nano text editor can be installed by two different approaches, either by using Debian’s package list or by downloading it from its official website.
Method 1: Install the Nano Text Editor from Debian’s Package list
To install the nano text editor from the default package list of Debian, launch the terminal and run the command:
$ sudo apt install nano -y
When the execution of the above command is completed, the package of Nano text editor will be installed. To display the installed version of the nano text editor, run the command:
$ nano --version
Method 2: Install the Nano Text Editor from its Source Code
Another method is to download the source code package from its official website and install it by compiling its binaries with the next-mentioned steps.
Step 1: Download the Source Code Package
First download the nano source code package with the wget or curl command utility as shown:
$ sudo wget https://nano-editor.org/dist/v7/nano-7.2.tar.gz
Confirm the downloading with the ls command:
$ ls
Step 2: Extract the Package
After downloading, extract the package with the “xvf” options of the tar command:
$ tar -xvf nano-7.2.tar.gz
Step 3: Navigate to the Extracted Directory
Now enter the extracted directory of the nano text editor with the following command:
$ cd nano-7.2
Step 4: Configure the Binaries
Configure the source code binaries by running the command:
$ ./configure
Step 5: Compile the Binaries
When the configuration is completed, then compile the configured binaries with the command:
$ sudo make
Step 6: Install Nano
Finally, install the Nano text editor by executing the command:
$ sudo make install
The nano text editor has been installed and this method will make sure that the latest version of the nano text editor should be installed. Restart the terminal and find out the installed version of the nano text editor with the command:
$ nano --version
What are the Basic Shortcut Keys of the Nano Text Editor?
The basic usage shortcut keys for the nano text editor are explained in the next-mentioned table.
Shortcut Keys | Explanation |
---|---|
CTRL+S | It is used to save the file |
CTRL+Q | It is used to start the backward search |
ALT+DEL | It is used to delete the current line of the file |
CTRL+J | It is used to justify the paragraph of the file |
CTRL+G | It is used to display the help desk of the nano text editor |
What are the Commands to Use the Nano Text Editor?
To use the nano text editor by running the commands, first, use the below-mentioned general syntax to open or create a file:
$ nano filename
For example, create a file with the “myFile” name, the command should be:
$ nano myFile
Now write some text as shown in the figure below:
Save the file and exit the nano text editor by pressing the CTRL+X. To view the file, use the cat command:
$ cat myFile
The edited text has been displayed on the screen which is written by using the nano text editor.
How to Uninstall Nano on Debian?
To uninstall and remove the nano text editor with its configuration files, execute the next command:
$ sudo apt purge nano -y
This is all about the installation and usage of the nano text editor on Debian.
Conclusion
The Nano text editor can be installed either by running the command “sudo apt install nano -y” or by downloading its source package from its official website. The second method is recommended to install the latest release of the Nano text editor.
The Nano or the GNU Nano is the text editor and is also known as the replacement of the Pico text editor on Linux distributions.
It comes pre-installed on Debian but if its package is missing, then it can be installed by the explained installation methods for the Nano text editor in this post.