Most Useful Nano Commands and Shortcuts.
Working under any Linux Server involves lots and lots of files configuration. Some use Vi, Vim, or Emacs, yet powerful but somehow tedious to learn.
For those who need a more simple and versatile text editor, there is nano.
GNU nano is a small and friendly text editor. Besides basic text editing, nano offers features like undo/redo, syntax coloring, interactive search-and-replace, auto-indentation, line numbers, word completion, file locking, backup files, internationalization support, and more.
Installing Nano
By default, nano
is pre-installed in most Linux distributions. Use the next commands to check or to install respectively.
Here for Debian/Ubuntu system:
$ nano --version
Output
GNU nano, version 6.2
(C) 1999-2011, 2013-2022 Free Software Foundation, Inc.
(C) 2014-2022 the contributors to nano
Compiled options: --disable-libmagic --enable-utf8
or
$ sudo apt install nano
Our Nano Top Shortcut Keys
Here is the list of all nano
shortcuts available in Linux.
Command |
Action |
Ctrl + O |
Save A File |
Ctrl + _ |
Go to Line X |
Alt + B |
Create a Backup |
Ctrl + X |
Exit file, with prompt |
Alt + U |
Undo an action |
Ctrl + G |
Get Help |
Ctrl + F |
Single character forward shift |
Ctrl + B |
Single character backward shift |
Ctrl + Space |
Move one word forward |
Alt + Space |
Move one work backward |
Ctrl + P |
Move to the preceding line |
Ctrl + N |
Move to the succeeding line |
Ctrl + V |
Move to next page |
Ctrl + Y |
Return to the preceding page |
Ctrl + A |
Move to the Begin of the line |
Ctrl + E |
Move to Concluding line |
Ctrl + W |
To open Search prompt |
Ctrl + T |
To Search Line Number |
Alt + W |
Go to the Next result |
Ctrl + R |
Replace Searched Text |
Alt + 6 |
Cut Text / Line |
Ctrl + K |
Copy Text / Line |
Ctrl + U |
Paste Copied Data |
nano |
To create a new file in the editor |
nano filename.txt |
To open a file in the editor |
Below, is a practical example:
... you want to open a file with the cursor on a specific line and character.
You can do this as such:
$ sudo nano +LineNumber Testing.txt
Replace LineNumber with the exact line number where you want to jump to. This method is very useful when working with large files in which it is difficult to manually travel from line to line.
Of course, there are many shortcut keys that can be used to navigate and do tasks in nano
. The above keys are a few of the useful shortcut keys used in that editor.
How to Move to the End of the Line
This can come in handy when dealing with large files. Click "Ctrl + W", this will evoke the Search option then press "Ctrl+ V". As you can see your cursor has moved to the end of the last line.
That’s all with nano, stay connected with snubmonkey for more exciting and interesting future posts.