Linux Mint – The nano text editor

How to manage remote IIS on Windows Server 2019

Until now, we have used single purpose commands to achieve very basic goals such as creating empty files and directories. In the Linux Shell, there is more to life than simple commands. There are actually complete programs, which are able to run completely within your shell window. One example is nano, which is a text editor. There are many text editors available (such as vi and emacs), but nano is quite possibly the easiest to learn when starting out. There are two ways to open the nano text editor. The first way is by simply entering the nano command in the terminal.

The nano text editor immediately opens and you are able to start typing. However, when you enter the nano command by itself, you aren’t actually editing a file until you save it. To save the file, press Ctrl + O (the letter O) and you are prompted to save the file. If you simply type the name, such as myfile.txt, the file will be saved to wherever your current working directory is. For example, if your working directory was /home/user/mydocs when you entered the command and you saved the file as myfile.txt, it would create the myfile.txt file underneath /home/user/mydocs.

If you already know the name of the file you want to create and where you’d like to save it, you can type all of it into a single command, as shown in the following command:


nano /home/user/mydocs/anotherfile.txt

With this command, nano will open as normal. However, when you press Ctrl + O in order to save the file, it will default to the path and filename you specified. If the file already existed when you entered that command, the contents of the file would be displayed on your screen, and you’d be able to modify it.

Feel free to play around with the nano text editor as it is very easy (and useful) to learn. Files are edited in nano in much the same way as graphical text editors by pressing the Enter key to move to a new line, the arrow keys to move your insertion point around the document, the Backspace key to delete characters, and the Tab key does exactly what you’d expect. As mentioned earlier, Ctrl + O brings up the save dialog. After you press Ctrl + O, confirm the name you’d like to use and press Enter to finalize the save process. To cut some text in order to paste later, press Ctrl + K to cut the line and then press Ctrl + U to move the line to where the insertion point currently is. To exit nano, press Ctrl + X.

Note

Not all Linux distributions ship nano, especially older distributions or server-based platforms. If your goal is to become a Linux administrator, you should learn another terminal-based text editor as well. A good recommendation is the vi text editor, which is more advanced but very common in the field. You may run into a situation where vi is the only option on the server you are working on.

Comments are closed.