Control your Raspberry Pi remotely using PiControl

PiCockpit’s PiControl is a powerful feature which allows you to control your Raspberry Pi remotely from any web-browser, by simply clicking buttons. You will see the state and output of the command. New commands can be added by simply editing a JSON file on your Raspberry Pi – we’ll show you how to do it, and give you some ideas what you can build using PiControl!

What does it look like?

By default three commands are included and immediately available for your Raspi: ( power off, reboot, upgrade client)

Basic commands to control your Pi remotely using a webinterface - from any browser
This PiCockpit PiControl screenshot shows how the commands look like

What can I do with a Raspberry Pi and PiControl?

Here are some things which you can build with it. These ideas will require some research, and possibly coding and/or hardware knowledge on your part; In any case, PiCockpit’s PiControl will help you with the easy-to-use web-interface part of your project and save you tons of time making this work across the Internet 🙂

  • take a snapshot using the Raspberry Pi Camera module and have it mailed to you
  • start your Raspberry Pi Minecraft server, and stop it as well
  • Play a video using omxplayer (you can also set up an infinite loop for the video, and stop the video loop if you want to switch to another video)
  • create an easy control for a stop-motion animation camera, using the Raspberry Pi camera module
  • wake up a local computer in the same network as your Raspberry Pi with Wake on LAN functionality
  • play a sound (as a prank for Halloween, for example)
  • open a door – for example a garage door, by issuing appropriate control commands via Z-Wave, etc.
  • start the SSH service on your Raspberry Pi, and shut it down – a “knock to open” approach for improved security
  • control model trains
  • switch a relais on and off (will require two buttons, or can be done using a “toggle” button)
  • control the TV (switch channels, change volume, …) using an IR LED, for example to simulate activity while you are travelling
  • Launch a rocket from the web interface

We will publish step-by-step instructions for some of these project ideas, so you have an easy guide for getting started with PiControl and remotely controlling your Raspberry Pi.

How can I add additional remote command buttons for the Raspberry Pi with PiControl?

You can easily and securely define your own commands, by simply editing JSON files on your Raspberry Pi. This is done for security reasons – I could have written PiCockpit in a way which would allow you to add commands from the webinterface, but if someone would know your PiCockpit password, they could create any command they wished. Therefore, please follow these simple instructions to create a new JSON file on your Pi.

Note: these instructions are deliberately kept in a way which users who don’t have experience with the command line can follow. If you know how to use the command line, you might find it easier / faster to just create the file and edit it with nano.

First, you’ll need to open the file browser in super user mode (this step keeps your PiCockpit PiControl configuration files safe from any user or application wanting to tamper with them). 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

No worries, we’ll only touch the files you need here 🙂

Open the following directory on your Raspberry Pi:


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

Call the new file ssh-server.json:

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.

right-click the new file, to bring up the context menu. Choose “Geany”:

Context menu showing Geany the programmer's editor on Raspberry Pi OS
Geany is an editor which you can edit the file with
Geany programming editor screenshot
Geany shows the file ssh-server.json – nothing in it yet

Now you can see the new file we just created. It is empty so far.

Let’s create two new commands, one for shutting down the SSH server service, and one for starting it. Enter the following into the text field Geany shows you:

  "name": "SSH commands",
  "icon": "mdi-ssh",
  "handle": "ssh",
  "description": "Control the SSH server",
  "commands": {
    "ssh-stop": {
      "name": "SSH Server off",
      "icon": "mdi-server-minus",
      "description": "Shuts the SSH service down",
      "confirm": true,
      "user": "root",
      "command": ["service", "ssh", "stop"]
    "ssh-start": {
      "name": "SSH Server on",
      "icon": "mdi-server-plus",
      "description": "Starts the SSH service",
      "user": "root",
      "command": ["service", "ssh", "start"]
Adding the text in Geany. Pay attention to the brackets, and document structure and the words have to be spelled correctly for it to work.

At this point we should save the file. You can do this from Geany’s file menu, for example, by selecting Save. (Or use Ctrl + S):

Geany’s file menu

At this point our new commands have not appeared in the webinterface yet. We need to restart picockpit-client for this. Click on the “Run …” command in the Raspberry Pi OS menu, and type “sudo service picockpit-client restart” into the window before clicking on OK:

restarting the picockpit-client service using the run dialog
restarting a service from the Run dialog

Now have a look at your PiControl webinterface:

PiControl webinterface for remote control screenshot
A new button to jump quickly to the new SSH commands appeared
The new commands (buttons) which we added to the webinterface to run remote commands on the Raspi!

If you’ve typed everything correctly, the new commands will appear. If you have made a mistake in your JSON file (e.g. forgot a curly bracket), PiCockpit will simply ignore the “broken” file.

You can now try the commands. If you click on the button SSH SERVER OFF, you’ll be asked whether you really want to run the command. Click on ssh server off here as well, to actually run the command (or click cancel if you don’t want to after all).

A safeguard to keep you from executing dangerous commands by accidentally clicking them

PiCockpit will now run the command, you’ll see progress information – and after it’s finished running, you’ll see the following success indicator:

PiControl has successfully run “service ssh stop” on your Pi.

If you try to connect to your Pi now using SSH, the connection will be refused:

PuTTYNG showing a fatal error.
Network error: connection refused

Start the SSH server back up by clicking “SSH SERVER ON”. Now a connection will be possible again.

Congratulations! You’ve just created your very own set of commands which you can run from the web interface.

Stay on the page while you run commands – the status will currently be cleared if you navigate away. To determine whether the SSH server is running, you could build a PiDoctor test – PiControl is simply for executing remote actions on your Pi.

Raspi Berry’s helpful Raspberry Pi (and PiCockpit) tips

Remember to restart the picockpit-client when you add new commands, or update commands. You can also remove commands you don’t want to have, for example if you want to remove the capability to shut your Raspberry Pi down remotely.

Explanation of the remote command syntax

The file configures a new module for PiControl. It has a .JSON syntax, please make sure that you open and end with curly braces in a correct fashion, as presented in my example.

There is a head, which configures the module itself, and the commands (in the “commands” part). They share some common entries:


The “name” entries are human readable names which are shown to you in the web-interface


The “icon” entries are optional to decorate your buttons and module. These are Material Design Icon names, for example “mdi-ssh”.

You can check out a full list of Material Design Icons here. Simply copy the name of the icon (including the mdi- in the beginning).

Raspi Berry’s helpful Raspberry Pi (and PiCockpit) tips


The “description” entries are optional and allow you to add a bit more information for the command or module.


The “handle” entry is explicit for the module, and has to be unique amongst the modules. In the case of the commands, the handle is implicit. “ssh-stop” and “ssh-start” are the two handles I’ve used for the commands in my example.

You can choose anything as a handle, as long as it does not include the characters “/”, “+”, “$”, “*”. I recommend to stick to basic downcase ASCII characters, and using the “-“. The handle is required.

Your file can, by the way, have a different file name than the handle – I encourage you to use at least related names for the file name and the handle, so you can easily identify the module .JSON file on your hard drive.

Raspi Berry’s helpful Raspberry Pi (and PiCockpit) tips

The commands go into the “commands” block, and have additional configuration possibilities:


If “confirm” is present, and set to true, the PiControl web interface will show a confirmation dialog before actually running the command. This is useful for making sure “dangerous” commands don’t get executed by an accidental tap or click.


If “user” is present, the command will be run as this particular user (as root in our example, to ensure that we have sufficient privileges).

PiControl will run commands as user “pi” by default. You can also set it to other users with less privileges than “pi“.

If you try to run GPIO commands, or play videos using omxplayer, you might have to give your new user additional capabilities. The user pi has these required privileges by default. Usually these privileges are set by adding the user to a special group.

Raspi Berry’s helpful Raspberry Pi (and PiCockpit) tips


This is the actual command which should be run on your Raspberry Pi. Note that you have to replace the spaces in the command compared to as you would run it on the command line. For example,

service ssh start

should be written as:

["service", "ssh", "start"]

PiControl also supports chaining a sequence of commands (e.g. the usual apt-get update, apt-get upgrade sequence). Check out core.json for an example of how that is being done.

Raspi Berry’s helpful Raspberry Pi (and PiCockpit) tips

Conclusion: PiControl for your Raspberry Pi remote control needs

Using PiCockpit and PiControl, it’s really easy to add any remote command you want to run on your Raspi, and be able to control your Pi from a webinterface. For this to work the Raspberry Pi only needs an Internet connection – you do not have to be in the same network.

What would you like to build using PiCockpit and PiControl? Comment below, and I will try to help you with your project 🙂

PiControl screenshot showing buttons to remotely control omxplayer and controlling the Chrome webbrowser using the webinterface
This PiControl screenshot shows a custom module I’ve set up: control Chrome (Chromium), run videos in a loop using omxplayer, show YouTube videos on the Pi

With great power comes great responsibility – be careful of who you give access to to your PiCockpit interface, keep your password and API keys safe. Also make sure to “protect” dangerous commands, as discussed above, so that they don’t get executed by accidentally clicking on them.

Raspi Berry’s helpful Raspberry Pi (and PiCockpit) tips


  1. Max on May 12, 2021 at 5:30 pm

    hello there!
    I want to run the following comand with a picontrol button: cd /home/pi/Sensoren ; python3
    I did it as described and i can press the button but the comand isnt executed and also the process cant be stopped.
    Any advice?

    • raspi berry on July 1, 2021 at 5:22 pm

      remember that picontrol is not a shell – all commands are executed independently. you have to use absolute paths (cd – change directory – is useless in the context of picontrol).

  2. Alex on August 16, 2021 at 6:34 pm

    Starting a python script works fine, example:
    “command”: [“python3”, “/home/pi/do_something.pyc”]
    But I have problems if the script later starts an app with a GUI like Chromium or if Chromium is started directly:
    “command”: [“chromium-browser”] results in “Unable to open X display. “.

    How do I start scripts or apps that require an X display?

    • PiCaptain on August 19, 2021 at 5:08 pm

      I’ve written a bit more about this here:

      basically you need to tell the application which X display to use.
      In the case of Chromium it is done with a flag

      chromium-browser –display=:0 –kiosk

      note, –kiosk starts the browser in kiosk mode. Just throwing that in as an extra information.
      note II: these are two dashes for the parameters – WordPress changes them to a single long dash I believe.

      For other applications you will need to check. Frequently this is done by setting an environment variable.
      Possibly for PiCockpit you would need to write a bash script which sets the variable and then starts the application.
      And then run the bash script.

      If you have any success with this, please share with us.


      • PiCaptain on August 19, 2021 at 5:09 pm

        As image

    • PiCaptain on August 19, 2021 at 5:11 pm
  3. Sri on October 13, 2021 at 1:23 pm

    Hi, just setup a command using your software and infrastructure and it is awesome! Thank you so much for this simple and easy to use software. I wanted a bit of advice if you’re free. Basically, I have my Pi setup to wake my pc from sleep, and your software allowing a simple web interface to wake the pc with an etherwake command is working, however I would like a faster way of executing this one command immediately. Do you think there is any way to make this possible? Currently to just wake my pc, i have to login and then go to my command and then choose the button in the pop-up box, but if there was an api or a shortcut to basically running the command in one click, that would be helpful. Either way, thank you so much for this. Very awesome 🙂

    • PiCaptain on October 23, 2021 at 1:41 pm

      Thanks for the feature suggestion, I’ve added it. We’re planning on doing a wake on lan app some time, maybe it might be a bit more convenient.

  4. Hager on March 31, 2022 at 12:26 pm

    wie kann ich zum Beispiel Abfragen wie (Do you want to continue? [Y/n]) über das Script mit “Y” bestätigen?

    Vielen Dank!

    • Hanno on April 20, 2022 at 7:30 am

      Hallo Herr Hager,

      das ist eine sehr gute Frage! Einige Kommandozeilen Programme wie zum etwa apt-get haben eine bereits integrierte –assume-yes Option, die es ermöglicht sie in einem nicht-interaktivem Modus zu nutzen. Das wird etwa gerne in Skripten ausgenutzt, die ohne Bestätigungen per Hand laufen sollen. Alternativ gibt es das klassische Unix ‘yes‘ Programm mit Sie das selbe Ergebnis erzielen können. Beispielsweise mit:
      yes | sudo apt upgrade
      Abhängig von Ihrem konkretem Anwendungsfall sollte eigentlich eine dieser zwei Möglichkeiten eine gute Lösung darstellen. Ansonsten können Sie uns gerne noch einmal schreiben!

  5. Jaka on March 30, 2023 at 7:32 am

    Hello, can you use RPi terminal from picockpit?

    • raspi berry on April 19, 2023 at 7:48 pm

      not yet, planned for a future release. (as of 19.4.2023)

  6. DGDodo on April 25, 2023 at 10:09 pm

    Not all icons from the mentioned website are available / working.
    How to use newer icons then version 4.9.95, for example ‘mdi-lamps-outline’ ?

    • PiCaptain on May 10, 2023 at 12:33 pm

      we are in the process of updating the frontend code. I’ll share your comment with our developer, possibly they can look into this before the next update to bring the icons to the most recent version.

    • PiCaptain on May 19, 2023 at 11:54 am

      Hi, we’ve updated the frontend, which means now you are able to use all icons up to the newest version of Material Design Icons. We’ll also keep the version of the Font up to date in the future.

  7. […] CLICK HERE: Learn how you can set up your own commands in PiControl. […]

  8. Expanding PiCockpit to 64 Bit Pi OS on August 28, 2023 at 9:32 am

    […] The administrative tools which help you control your Pi are all working. This includes the GPIO, PiControl, PiDoctor, and PiStats apps. Maybe set up your new 64 Bit install with an easy way to toggle your SSH server? Or starting and stopping that media center you have set up? Sending a WoL message? You can find a good introduction into the possibilities our software offers right here. […]

  9. chris l on September 4, 2023 at 11:11 am

    apt-get –just-print upgrade 2>&1 | perl -ne ‘if (/Inst\s([\w,\-,\d,\.,~,:,\+]+)\s\[([\w,\-,\d,\.,~,:,\+]+)\]\s\(([\w,\-,\d,\.,~,:,\+]+)\)? /i) {print “PACKAGE: $1 INSTALLED: $2 AVAILABLE: $3\n”}’

    The above command works just fine with SSH but PiControl has a problem and reports:
    (100) E: Command line option ‘n’ [from -ne] is not understood in combination with the other options.

    I reckon I escaped my JSON correctly as the displayed command in PiControl is the same one I escaped and split spaces into seperate strings.

    “name”: “CISO update commands”,
    “icon”: “mdi-update”,
    “handle”: “CISO”,
    “description”: “CISO install all updates”,
    “commands”: {
    “ciso-updates”: {
    “name”: “CISO Updates”,
    “icon”: “mdi-server-minus”,
    “description”: “Updates the list of all packages in the repository and upgrades all installed packages”,
    “confirm”: true,
    “user”: “root”,
    “command”: [

Leave a Comment