It's undeniable that, for new Linux users, using a terminal is a scary thing. But more frightening is still editing files at the terminal, with editors like Vim and GNU Emacs - very difficult for beginners. For example, even getting rid of Vim is a difficult task for many people.

Instead of complicating the problem, you can go back to the basics with a simple Linux editor: Nano. A lot of people love this tool, thanks to the simple interface, the powerful shortcuts that it includes, as well as common features like searching and numbering lines. This tutorial will show you how to use the Nano editor.

Open Nano on Linux

Nano comes pre-installed on most Linux distributions, so you don't need to install it. To run Nano, open a terminal and type the following:

 nano 

This command will open a blank file for you to begin writing.

Picture 1 of Basic guide to Nano editor

If you want to open a file, type:

 nano /folder/filename 

Replace '/ folder / filename' with the location of the file you are trying to edit.

Picture 2 of Basic guide to Nano editor

You can also do this with a file that doesn't technically exist. Nano will create a blank file with the file name specified at the location you provide.

Nano also allows you to open a file at a specific row or column. To do so, type the following:

 nano +line-number,column-number filename 

Replace 'line-number' and 'column-number' with the appropriate number of lines and columns, 'filename' with the name of the file. For example:

 nano +4,12 file.txt 

Nano will open the selected file at the position you given, ready for you to start editing.

Use Nano keyboard commands

As a terminal editor, you cannot use the mouse to navigate the Nano application. You will need to use keyboard shortcuts to open, save and close files as you like.

Picture 3 of Basic guide to Nano editor

Some of these shortcuts are listed constantly at the bottom of the Nano window, but for reference, here are some common commands you can use.

  1. Ctrl + G : Open the Nano help menu.
  2. Ctrl + O : Save the open file. Nano will ask you to confirm the file name when doing this, so just press Enter to confirm.
  3. Ctrl + C : Remove any pending orders.
  4. Ctrl + X : Exit Nano. This will also prompt you to see if you want to save the file, if you have made any changes to it. Press Enter to confirm if you want to save changes.
  5. Ctrl + W : Open search box. Enter here to locate certain sections of text.
  6. Ctrl + K : Delete the current text line.
  7. Ctrl + _ (underline): Move to certain lines. Enter the line number and press the Enter button to confirm.
  8. Ctrl + (backslash): Find and replace text. Enter the text you want to find instead, then press Enter .

There are other commands you can try. You can learn more from the Nano help menu ( Ctrl + G ). One of the most useful nano commands is text checking. This requires you to install an additional package, so if you use a Linux distribution based on Debian or Ubuntu, open a terminal and type:

 sudo apt install spell 

After installation, open Nano and press Ctrl + T This will start a spell check for your document.

Picture 4 of Basic guide to Nano editor

If you locate any text that is deemed incorrect, the tool will prompt you to correct it. Make changes, then press Enter to save changes.

Edit the file from the Linux terminal

Nano is very simple and once you start using it, it's pretty easy to get to grips with everything. Although the more advanced text editors offer better features, the Nano retains its position thanks to its strengths - editing files without creating any inconvenience or problems. what.

If you don't like Nano and are looking for a better alternative, you can try some of the best Linux editors like Vi or Scribes instead.

3.5 ★ | 2 Vote | 👨 371 Views

Above is an article about: "Basic guide to Nano editor". Hope this article is useful to you. Don't forget to rate the article, like and share this article with your friends and relatives. Good luck!

« PREV POST
NEXT POST »