Using Nano to edit files
Nano is a simple command line editor that is good for editing configuration files in KDE neon. You simply open up Konsole and point Nano at the file and off you go. The other great thing about it is that it is installed almost everywhere so Nano is already available my NAS as it will be in many Linux distributions by default.
To install Nano on KDE neon open up Konsole and type,
sudo apt install nano
You shouldn't have too though as it is installed by default.
To use Nano you will need to be using the command line. The usual way I use it is to open up Konsole and navigate to the directory where the file I will be editing is with the command,
And then once in the directory where the file is type,
nano <insert filename>
If you are outside your home directory or trying to edit a file where super user privileges are need, you will need to add sudo to the start of the command like,
sudo nano <insert filename>
This is the more typical situation for me.
After opening the file you will be presented with something that probably looks somewhat like the picture at the top of this post. The text will be different (generally there is a lot more of it) but generally everything else will be the same. One thing I do do occasionally is open a file in Nano and find there is nothing inside it. It is usually because I have typed the file name wrong and am accidentally creating a new file.
The simplest way to navigate around a file in Nano is with the arrow keys. Up, down, left and right. There are shortcuts but I generally leave them alone. That is, of course, just me. You can also use keys like Delete and you can paste into files but remember the paste is going to go where the cursor is. Not where your mouse is.
At the base of the Konsole window is where the command shortcuts are. The most commonly used ones are the ones with a little ^ in front of a character. This means press Ctrl plus the character. For instance, if I wanted to stop editing and save my file I would press Ctrl and then while holding it down press X. If I had actually done some editing Nano would then ask me whether I wanted to,
Save modified buffer? (Answering "No" will DISCARD changes.)
This is a yes, no or cancel question and the shortcuts to answer are given beneath the question. Pressing y will cause it to ask you what filename to write and then pressing Enter will save the file and close Nano.
Always create a backup file before editing one!
It is very important to make a backup file before editing one. I usually use Nano to edit configuration files and if you stuff it up there is,
- No going back.
- Your computer may become unusable.
The usual way to backup a file is to move it to another file with dot backup on the end of it. If you are doing multiple edits you may want to add a numeral to the end of that as well so you can keep track of them. But the basic format is.
mv filetobackup filetobackup.backup
That is pretty much it. It may look a little complex but really it isn't and I find it a lot easier than other ways.