Most Linux distributions ship with a command-line based text editor, usually
Nano. While both are excellent choices, Vim has a steeper learning curve and can be confusing for beginners. Nano, on the other hand, will feel much more familiar to anyone who has used notepad or other simple text editors in a desktop or other graphical user interface. This is not to say that Nano is not as feature rich as Vim; it is simply more accessible.
In this article, we will cover the basics of using the Nano text editor, as well as installing it and making some standard adjustments to its configuration. This article is primarily intended for people with little to no experience using the Linux command line, but even experienced users may learn a thing or two. We will be using a basic CentOS 8 Linux server distribution to demonstrate the many uses of Nano. Still, these commands and interfaces are mostly the same on all Linux distros by default.
Before we can start creating and editing text files, we need to check and see if nano is installed on our system. We can do that by simply trying to start it:
nano bash: nano: command not found
If the editor started up for you, feel free to skip ahead to the use and configuration sections. In case we do not have it installed, we can install it now. The installation command will be different depending on which family of Linux distributions we are using. We will show the two most popular ones, Red Hat and Debian based systems. We need to be logged in as the root user or a user with sudo permissions to be able to install the new package. If we are logged in as root, we can drop the sudo command and run the rest of the command. We can also use the -y flag to auto-confirm on the installation prompts.
CentOS / RHEL / Fedora
sudo yum install -y nano
Ubuntu / Debian / Mint
sudo apt-get install -y nano
If Nano installed successfully, we will see a large amount of text ending with a confirmation message:
Installed: nano-2.9.8-1.el8.x86_64 Complete!
Since Nano works right out of the box, let’s review its usage and then check out its various configuration options further down in the article.
Using the Nano Editor
To start the Nano editor, we can invoke it using the following command.
We can use the same command along with a filename to create a new file or open an existing one:
- Last updated 4 months ago
Be the first to leave a comment.
You must login to leave a comment