When using Linux, many people prefer to use command-line tools over graphical alternatives. One such command-line tool is “Nano”, a simple and easy to use text editor. Text editors are tools that can be used to edit any text-based document. There are many different text editors to choose from and a small number are installed by default in most Linux distributions.
To check if Nano is installed, you can run the command “nano –version”. If you don’t see a version number in response, then you’ll need to install it. The exact command you’ll need to install Nano will vary depending on which distribution you’re using. If you’re using a Debian based system such as Ubuntu, the command is “sudo apt-get install nano”. If you’re using an RPM-based distribution such as CentOS, the command you need is “yum install nano”.
How to use Nano
The first step of using a text editor is opening a document. You can either open Nano just by running the command “nano” or you can specify a filename with “nano [filename]”. If you don’t specify a filename, Nano will open a new file and you will have to name it when you save. If you specify a filename, Nano will open that file if it exists, if the filename doesn’t exist Nano will still open and it will then pre-fill that filename when you go to save the document.
Tip: In Linux distributions, file extensions such as “.txt” don’t make a difference, they’re all just part of the filename. You don’t need to worry about what filetypes Nano can edit, as long as it’s a text-based file it will work just fine. If you do use file extensions for programming languages, Nano can perform some syntax highlighting, making it easier to see what text does what.
Nano has a list of keyboard shortcuts at the bottom that can help you perform functions. The caret symbol “^” in front of the shortcut keys means that you need to press the control key. The most important shortcut keys you need to know are “Ctrl+O” and “Ctrl+X” which save and quit respectively.
Tip: If you try to close a document without saving you will be asked if you want to save, press “Y” or “N” meaning “Yes” and “No” respectively. If you change your mind about wanting to save press “Ctrl+C” to cancel, otherwise, type a filename, or accept the current one, then hit enter to save the document. If you accidentally close Nano with “Ctrl+Z”, don’t worry, you just put the process to sleep, you can re-open it without losing any data by typing the command “fg”.
You can easily get by using Nano with just these tools but there are a few more shortcuts and keys that can be helpful. “Ctrl+G” will open a help document explaining what all the keyboard shortcuts do, you can exit this mode by pressing “q”. “Ctrl+A” and “Ctrl+E” let you skip to the start or end of the line respectively. “Ctrl+W” allows you to search the current document for a string. “PageUp” and “PageDown” will scroll through the document.