When using a Raspberry Pi, even simple actions, such as turning it off, can become a problem, especially when using it remotely.
I will answer this question in a moment and give you more tips if you are interested.

This command can be used to disconnect the Raspberry Pi from SSH :
sudo ѕtorDevice
is then stopped and the current SSH session is immediately disabled.

If you don’t know SSH or the command line, I will guide you step by step.
And if you need to do it regularly from your computer, don’t miss my advice on how to do it more efficiently.

By the way, if you are new to raspberry Pi and want detailed instructions on how to do everything with it, check out my ebook “Free Your Raspberry Pi in 30 Days”. This is a 30-day challenge where you learn a new skill each day and practice as you go. You will save time and money and have fun with each new project you try.

Connecting to the Raspberry Pi (SSH)

In this first part, I will explain what you need to do to access your Raspberry Pi via SSH. You can skip this step if you are already connected, but it is essential if you want to stop your Raspberry Pi remotely 🙂 .

Make sure that SSH is enabled

First of all, make sure the SSH service is working.
This is not the default on the Raspberry Pi operating system, so you need to enable it.
Here’s how.

Raspberry Pi OS Desktop

If you have a desktop version, you can enable SSHs as follows

  • Open the main menu and go to “Settings”.
  • Start the Pi Framboise configuration program.
  • In the “Interfaces” tab, on the second line (“SSH”), click the “Activate” button.

Click OK to apply the changes.
From then on, the SSH service will start automatically at startup.

Raspberry Pi OS Lite

In Raspberry Pi OS Lite, the easiest way is to use Raspi-config :

  • Use the following command:
    sudo raspi-config
  • Go to interface settings
  • Then the SSN.
    Error: The file name is not specified. ” alt=”” width=”843″ height=”253″ data-ezsrc=”http://server.digimetriq.com/wp-content/uploads/2021/02/How-to-Shut-Down-Raspberry-Pi-via-SSH-And-a.jpg” data-ez=”” />
  • And answer “Yes” to the question “Do you want the SSH server to be activated?

The SSH server is started directly and is activated at startup, so you don’t have to do this every time.

Error: The file name is not specified. “data-ezsrc=”http://server.digimetriq.com/wp-content/uploads/2020/12/1608398820_992_How-to-Easily-Install-Apps-on-Raspberry-Pi-OS-5.jpg” />

Pike with raspberries sale
: 10% off today. Move to the next step.
I’m here to help you get started with your Raspberry Pi and learn all the skills you need in the right order.

Find the IP address of your Pi Framboise

You will also need an IP address before you can connect to the Raspberry Pi remotely.

On the Raspberry Pi OS desktop, you can easily achieve this by hovering over the network icon in the upper right corner.

On the Raspberry Pi OS Lite, you can use this command:
IP address is on the second line, after the keyword
Error: The file name is not specified. ” alt=”ifconfig” width=”796″ height=”182″ data-ezsrc=”http://server.digimetriq.com/wp-content/uploads/2021/02/How-to-Shut-Down-Raspberry-Pi-via-SSH-And-a.png” data-ez=” />

If you need help with this step, I have a dedicated tutorial on the subject here.

Connecting to Raspberry Pi

Once the Raspberry Pi is set up, you can access it via SSH.
Since Windows now includes an SSH client, you can use the same command regardless of your operating system.

  • Open a terminal (or a command line in Windows).
  • Enter the following command:
    ssh pi@IP_ADDRESSReplace the
    IP_ADDRESS with the one you obtained in the previous step.
  • The first time you log in, you may need to accept Pi’s Raspberry’s fingerprint, type “yes” and press the Enter key.
  • Then enter the password (default: Raspberry).

Error: The file name is not specified. ” alt=””” width=”1024″ height=”576″ data-ezsrc=”http://server.digimetriq.com/wp-content/uploads/2021/02/1612603915_928_How-to-Shut-Down-Raspberry-Pi-via-SSH-And-a.jpg” data-ez=”” />

There, now you are connected to your Crimson Pi.
You can follow the next part to stop it from there.

Deactivate your Raspberry Pi via SSH

Disconnecting the power supply or pressing the button on the case is not the right way to stop the Raspberry Pi. Otherwise, the SD card may be damaged, depending on the processes performed.

In this section, I will give you three commands to properly shut down your Raspberry Pi, as well as some tips on how to proceed.

3 commands you can use to stop the Pi from the raspberry

Without further ado, here are three commands you can use to stop the Raspberry Pi :

  • HaltProbable
    is the one to remember because it is the shortest:
    ѕtorWe offers some options, but they are not very useful in our case. Therefore, a simple command like this should be sufficient.
  • PoweroffThis is
    an alias for stop, you can use it if you want, but it is basically the same alias:
    disable sudo
  • Deactivate
    This option is more interesting because there are several useful options.
    The basic command to shut down your Raspberry Pi would be :
    sudo shutdown nowOptions
    you might want to try:

    • Stop the raspberry Pi in a minute.
      Other users will be notified.
    • Plan to shut down the Raspberry Pi at the specified time.
      sudo shutdown 06:00You
      can also
      use cron for additional options
    • Cancel the scheduled closure
      sudo closure -c

In any case, you must have administrator privileges to shut down the system. So make sure you put the sudo command at the beginning if you are not already logged in as root.

Once the shutdown is scheduled, non-administrators cannot log on; they get the error message: the
system is disabled. Non-privileged users are no longer allowed to log in.

Create a script to automate it from your computer.

In theory, you should do this every time you use a raspberry Pi.
In some cases, this is not the most practical way to do it. If your Pi is embedded, you may not want to connect to SSH every time to stop it.
No problem, you can “automate” this.

Under Windows

For Windows users, the easiest way is to use Putty from the command line:

  • Install putty if you don’t already have it.
    This is a free SSH client.
  • Create two new files:
  • In stop-pi.bat, add the following line:
    putty.exe -ssh pi@ -pw -m stop.
    txt Don’t forget to add
    the IP address and password of the raspberry’s Pi that you want to stop.
  • And in stop-cmd.txt:
    sudo close now
  • Save everything and double-click stop-pee.bat.
    This should shut down your Raspberry Pi immediately. You can close the windows opened by the script on your computer.

Not bad, now you can create a shortcut somewhere if you want and use it every time you want to stop the Raspberry Pi.

Under Linux / MacOS

Under Linux / macOS, it’s almost the same, but you need to create a bash script.
First, make sure you have generated an SSH key and can access your Pi without entering a password.
Then add this line to your new bash script:
ssh pi@ “sudo shutdown now”

You can also use SSH keys in Windows, but that is a bit more complicated, so putty is the easiest way.

Error: The file name is not specified. “data-ezsrc=”http://server.digimetriq.com/wp-content/uploads/2020/12/1607451018_397_How-to-Install-VMWare-ESXi-on-a-Raspberry-Pi-Step.jpg” />

Free your Raspberry Pi in 30 daysAdvantage
: 25% off today. Download the eBook.
Discover the secrets of Raspberry Pi in 30 days.

Put the raspberry Pi back on.

Unfortunately, the Raspberry Pi cannot be turned on remotely after that. Therefore, simply unplug it and plug it back in.

If there is an on/off button on the housing, it should be possible to press it twice.

Discover the secrets of your Crimson Pi.

As you can see, even things that seem simple enough at first can take a lot of time if you are new to Raspberry Pi and Linux. So it can be frustrating to try big projects.

My goal on this site is to help you the best I can. If you need help learning, you should check out my Raspberry Pi Bootcamp. This
course is for anyone just starting out or wanting to start,
to get past the initial questions quickly and have fun.

Frequently asked questions

How do I turn the Raspberry Pi on and off?

As you may have noticed, there is no button to turn the Pi Framboise on and off. Your first reflex is probably to unplug the power cord, but this is strongly discouraged. There are many reasons why pulling the power cord while the operating system is active is a bad idea.

How do I turn off the Raspberry Pi?

Shutting Down and Restarting Pi from the Command Line If you’re using a mouse and keyboard with Raspbian, shutting down is easy – just click the Raspberry icon in the corner and select Shut Down.

How do I turn off my raspberry girl?

Yes, if you go to the HassIO tab, click on the System tab in the upper right corner, under Host system, there is a shutdown option.

how to shutdown raspberry pi via sshhow to shutdown raspberry pi from terminalraspberry pi shutdown scriptraspberry pi power off without shutdownhow to reboot raspberry pi through sshhow to turn on raspberry pi 4 after shutdownshutdown raspberry pi without keyboardrestart raspberry pi through ssh