Edit Text Files on a Raspberry Pi

Difficulty
Very easy
Steps
5

Learning to edit text files on the Raspberry Pi is an important first step.

In this guide, we will look at how you can edit text files on the Raspberry Pi. You will learn to view text files, edit it from the command line, open text files in the Text Editor from the command line, and use Nano. While a Raspberry Pi 3 Model B+ and its power supply is used here, this guide will work for the other Raspberry Pi boards, too.

By doing so, this will enable you to advance onto further projects.

Step 1  Viewing Text Files

From the top left hand corner, the File Manager can be found. Click on the folder icon.

If you have NOOBS running on your SD card, you should be able to find a file by navigating to /boot/config.txt

Double click on it to view it in Text Editor.

Step 2  Using cat

Often enough, you will also be working with text files directly from the command line. So to do so, open up the Terminal (next to File Manager) at the top left hand corner, and enter cat /boot/config.txt

Step 3  Open Text Files From Command Line

Sometimes, you'll want to be editing text in a friendly graphical environment. To do so, enter the following command xdg-open /boot/config.txt

Step 4  Start Nano

No graphical user interface? No problem. With the text editing app, Nano, you can edit text files just as easily - yes, without needing a GUI..

Test it out for yourself, enter the following in the command line:nano /boot/config.txt

Step 5  Using Nano

Similar to a word processor apart from the absence of a cursor, Nano has cut and paste functionality. To cut lines of text, use CTRL+K and to paste it, use CTRL+U.

To save, press CTRL+O and then enter Y. If you don't want to save but simply exit, use CTRL+X to return to the command line. That's it! Well done, you now know how to edit text files on the Raspberry Pi in a number of ways.