How to create new files as root user from the Raspberry Pi OS Desktop

Sometimes, you want to be able to edit and create system files on Raspberry Pi OS. I’ll show you how to do this using pcmanfm, the file system browser you already know on the Raspberry Pi.

First, you’ll need to open the file browser in super user mode

Click on Raspberry Pi OS Menu, and here click the “Run …” command:

Raspberry Pi OS Menu, showing the run command.
The Raspberry Pi OS Menu. The Run command is near the bottom

Run pcmanfm as root (sudo pcmanfm) by typing “sudo pcmanfm” (without the quotes) in the dialog which opens, and clicking on OK:

Run command dialog on Raspberry Pi OS
The run command, preparing to run pcmanfm as root

A new window opens, showing you the contents of the /home/pi directory:

pcmanfm screenshot with super user rights
pcmanfm, the file manager running as super user

Note: you should see this icon, just under the “File” menu. It indicates that you are using pcmanfm as user root, and should therefore be extra careful (since root can edit / delete / move any file! even files which are critical for a normal system operation).

Root mode indicator

As an example, if you wish to create a new configuration file for PiControl, you could navigate to the following directory on your Raspberry Pi:

/etc/picockpit-client/apps/com.picockpit/picontrol/modules

Showing the configuration directory for PiCockpit’s PiControl. Note, if you have a fresh installation of PiCockpit, you’ll only see core.json. The other modules were created by me for test and demonstration purposes (remote control experiments).

Tip: you can also copy & paste the path I’ve given above, and hit the enter key to navigate to the directory.

Raspi Berry’s helpful Raspberry Pi tips

right-click into the empty area next to the existing files, and select “New File…”.

Creating a new file with Raspbian OS
Raspberry Pi OS menu for a right-click to create a new file

For example, if you want a new file “ssh-server.json”, you’ll type:

A dialog asks for the name for the new file.
creating a new file as root user with pcmanfm
ssh-server.json is now created in this folder.

Using the menus of pcmanfm you can also delete files, copy and move them.

You can learn more about pcmanfm here.

I hope this helps new users needing to edit system files as root on the Raspberry Pi 🙂

Leave a Comment