

To continue searching for the same text string, use ALT + W. The command will be like this: sudo nano -w /etc/apache2/nf How to Search and Replace Text If you don’t use this option, nano will wrap the text to fit the display by default. It will open the file in a standard format. Take note that whenever you are opening an important configuration file, it is recommended to use the -w option.

But if there are no changes, you will exit the editor right away. Input Y for Y es, or N for No, then press Enter. If there are changes, it will ask you whether to save them or not.

Meanwhile, if you only execute the nano command without specifying the file name, the Nano text editor will create an empty untitled file and ask for a name when you exit the editor.Īfter running the nano command, a new window will pop up where you can freely edit the file. If you enter a file name and that file is not present in the directory, Nano will create a new file. However, if you are in another folder, and you want to open a file ( demo.txt) in /path/to/directory, you can enter this line instead: nano /path/to/directory/demo.txt Just keep in mind that if you want to open a specific file, you will need to be in the directory where the file is located. The command would look like: nano demo.txt Let’s say we want to open a file named demo.txt. The main syntax to open Nano and to edit a certain file is: nano filename Then, we’ll show you some editing tips and other basic commands that you can use in Nano text editor. In this part, you are going to learn how to open and close files. As soon as the setup ends, you can use it immediately. We can run this command to install Nano text editor on CentOS or RHEL based platforms: yum install nano This means you may be prompted to enter a password in case you are currently not logged in as a root user. Important! The sudo part is meant for running this command as a root user.
