Three Methods to Edit the boot/config.txt File on Raspberry Pi

You are in the middle of a Raspberry Pi project when you suddenly discover that something is wrong: Repairing means editing the config.txt File that is in the /boat Directory.

But what's the easiest way to access this file while the Raspberry Pi is still running? And if you need to shut down to get the microSD card, how should you edit it? Here is everything you need to know to edit this useful configuration file on the Raspberry Pi.

Why you need config.txt on Raspberry Pi

Formerly known as Raspbian, the standard Raspberry Pi operating system (and most of the alternatives) is based on a few configuration parameters read from the microSD card when the computer boots. These are in config.txt Document found in the /boat Folder.

Such instructions can customize the way the display is recognized and the desktop is presented; config.txt can even be used to overclock your Raspberry Pi (or reset it to default clock settings).

Read More: How To Overclock Raspberry Pi

Both settings are logged in config.txt, as they cannot be changed on a running Raspberry Pi. If the display is not recognized, you will not be able to change any desktop settings.

If the Pi has been overclocked and does not boot or reboot repeatedly, you will not be able to access the raspi-config utility to reset it. Instead, config.txt is provided to give you the option to reset the clock speed of your Raspberry Pi.

It is also possible to change the USB boot mode in the config.txt, as well as the audio settings. For a full range of options, see the official Raspberry Pi documentation.

1. Access config.txt from the Raspberry Pi OS

If you need to edit the config.txt file while the Raspberry Pi OS is running, you should be able to navigate to it. You can find the / boot folder in the root directory of the microSD card. Once you find the config.txt file there, just double-click to open it and edit it in your default text editor.

However, if you plan to edit the file, it is advisable to keep the original. Note that you cannot use the desktop file manager to make a copy of the file because you need root user rights. So you need to open a terminal and make a copy with:

sudo cp /boot/config.txt /boot/backupconfig.txt

Give your copy a meaningful name. Note that if you edit the config.txt file, no changes will be applied until you restart your Raspberry Pi.

2. Edit config.txt remotely

Do you rarely connect a keyboard and monitor to your Raspberry Pi? As long as the computer is on the network, you should be able to edit the config.txt file remotely. To do this, connect via SSH (or VNC or RDP) and navigate to the / boot directory.

To do this, enter the

cd / boot

Command to change the directory to /boat in the Raspberry Pi operating system. Use here


to list the content. You should find it here config.txt. To read or edit the text file, use the nano text editor that comes pre-installed (although others are available).

sudo nano config.txt

After the changes are made, press Ctrl + X and then Yes to save and exit. Remember to restart your Raspberry Pi after making changes.

restart sudo

3. Edit config.txt on your PC

Linux, Windows, and macOS computers should be able to access the config.txt file through the microSD card. This means shutting down your Raspberry Pi (safe to avoid data corruption) and ejecting the SD card. Insert it into your computer's card reader to check its contents.

Edit config.txt on a Linux PC

If you need to edit the config.txt file on a Linux PC, look for the insert disk listed in your default file manager. It should be listed as two devices: the main volume (usually "1.8 GB volume" according to the size of the standard Raspberry Pi OS partition) and boot.

As you may have guessed, this is the volume that you need to access. It is essentially the / boot directory mounted as a drive. Open it to find config.txt. Save any changes you make in your default text editor, then use the Eject Button in the file manager to safely eject the SD card.

Edit config.txt on Windows 10

Inserting the Raspberry Pi's SD card into a Windows computer should result in it being immediately mounted and accessible via Windows Explorer. The device shows two partitions, but only one, boot, will be accessible in Windows.

Select this and then find config.txt. Use Notepad's default text editor to make changes (or an alternative like Notepad ++), save, and exit when you're done.

To safely eject the SD card, right-click the drive in My Computer and select Eject.

Edit config.txt under macOS

If you are using a Mac, you should find that the card will appear on your desktop when it is recognized. Use Finder to browse its contents and search for config.txt (or config without the .txt file extension). Read and edit the file in the TextEdit app and make sure that any changes you made are saved on exit. To eject the card, drag the desktop icon to the trash or right-click it and select Eject.

Whichever method you use to edit the config.txt from the microSD card read on your PC, remember to safely eject the device before returning it to your Raspberry Pi.

Optimize your Raspberry Pi even further

The config.txt file is just one of several options for editing the general configuration of your Raspberry Pi. It is one of the best ways to hack your Raspberry Pi through the boot partition. You are probably already familiar with the raspi-config utility accessed through the terminal. There's even a desktop-based Raspberry Pi configuration tool that you can find in the Settings menu of the Raspberry Pi operating system.

Optimizing the configuration of the Pi can save a lot of time if you get it right. To ensure that the computer is set up as desired the first time an operating system is written to the SD card, you can access an extended menu of options in Raspberry Pi Imager. Here you can adjust options such as specifying the host name, enabling SSH, and configuring WiFi.

How do I set a static IP address on the Raspberry Pi?

If you're using your Raspberry Pi as a media or game server, setting a static IP address makes things a lot easier.

Continue reading

About the author

Christian Cawley
(1488 published articles)

Deputy Editor for Security, Linux, DIY, Programming and Tech Explained and a really useful podcast producer with extensive experience in desktop and software support.

As a contributor to Linux Format Magazine, Christian is a Raspberry Pi tinkerer, Lego lover and retro gaming fan.

By Christian Cawley

Subscribe to our newsletter

Subscribe to our newsletter for tech tips, reviews, free e-books, and exclusive offers!

One more step …!

Please confirm your email address in the email we just sent you.

Leave a Reply

Your email address will not be published. Required fields are marked *