Edit Text Files on Raspberry Pi
Written By: Cherie Tan
Difficulty
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.
From the top left hand corner, the File Manager can be found. Click on the File Manager 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 the file to view it in Text Editor.
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.
Enter the command: cat /boot/config.txt
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
No graphical user interface? With 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
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.