1 C
Texas

Nano – The CLI Text Editor

If you’re running Linux, then having a text editor at hand is extremely crucial as you may need to edit a number of system files. Nano is a powerful text editor for Linux systems. It’s available on most of the Linux distros out there. It’s more preferable to new users than the advanced vi/vim and emacs editor.

Nano offers plenty of features like line numbering, searching, syntax highlight and lots of others. Learning Nano is easy. As the editor is available on all the major Linux distros, you don’t have to worry about other text editors at all.

Installing Nano

In cases, your system may not come up with Nano, or you uninstalled it. You can easily get this text editor for your system. Run the following command(s) according to your Linux distro –

# Ubuntu/Debian

sudo apt install nano

# CentOS/Fedora

sudo yum install nano
- Advertisement -

You can also install Nano from source. Get the latest source code of Nano.

Then, run the following commands –

tar -xvzf nano-3.2.tar.gz

cd nano-3.2/

./configure

make

sudo make install

Nano usage

Let’s fire up Nano.

nano

This is the window of Nano. At the bottom, you’ll notice all the available actions you can perform.

Here’s a short list you need to keep in mind at all cost –

Write out – ^O (Ctrl + O)

Exit – ^X (Ctrl + X)

Search – ^W (Ctrl + W)

In the case of other options, you can easily check them out at the end of the window of Nano.

If you press ^G (Ctrl + G), the help option will pop up.

  • Creating a new file

Fire up Nano –

nano

Type something in there –

Save the file –

You can find out the file on the directory you were in.

 

Note – I’m using Bat as an alternative to the popular “cat” command. Learn more about Bat – a “cat” clone with lots of improvements.

  • Opening file with Nano

Run the following command –

nano ~/.bashrc

You can see that the file is available for reading and editing.

Sometimes, you need to locate to the exact line and column of the file. Use the following command –

nano +line,columns <file>

If you’re in need of editing any system files, make sure that you use “sudo” for avoiding any conflict.

sudo nano <file>
  • Copy and paste

Move the cursor to the place you want to copy the text –

Hold Shift and move the cursor with your arrow keys.

For copying the text, press “M-6” (Alt + 6).

 

For pasting the content, press “Ctrl + U”.

Note that Nano isn’t able to interact with the global system clipboard. The copy and paste are only limited within Nano. If you’re using a terminal emulator, you have to use the emulator’s system of copying and pasting from the lines.

Enjoy!

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article