Raspberry Pi: Shutdown & Reboot Safely – Command
If you don’t want to corrupt the file system on SD card, you should always shutdown and reboot Raspberry Pi correctly (not just by pulling the power cable out).
To shutdown or reboot Raspberry Pi safely through the GUI, simply search the menu for the corresponding buttons.
In this note i will show how to shutdown or reboot Raspberry Pi safely from the command line.
Cool Tip: Check the CPU/GPU temperature of Raspberry Pi! Read more →
Safe Shutdown: When RPi (or any other UNIX-like system) is shutting down or rebooting normally, using the commands from terminal or their GUI equivalents, firstly it tries to exit all processes gracefully by sending SIGTERM signal, notifying them to save their data and exit. After some time it sends SIGKILL to all remaining processes, unmounts all the file systems and finally tells the kernel to issue the ACPI power command.
Shutdown Raspberry Pi
Use any of the commands below to shutdown RPi safely:
When the shutdown process has finished, the green LED blinks several times – after this it is safe to pull the power cable out.
If only the red LED is on, everything is good as it just indicates that the Raspberry Pi is connected to a stable power supply.
Reboot Raspberry Pi
Execute any of the following commands to restart RPi safely:
Turn OFF/ON Power Pin: The pins 5V , 3V3 and GND are directly connected to the power supply and can’t be controlled by software. For example, if on Raspberry Pi shutdown you also want to turn off the cooling fan connected to the 5V and GND pins – programmatically only this can’t be achieved.
How to Shut Down Raspberry Pi via SSH? (And a Bonus Tip)
When you start on Raspberry Pi, even simple actions like shutting down your device might be an issue, especially when using it remotely.
I will answer this question right away, and then give you more tips if you are interested.
A Raspberry Pi can be shut down from SSH using this command:
sudo halt
The device will stop after that, immediately disconnecting the current SSH session.
If you are not familiar with SSH or the command line, I will guide you step-by-step on how to this.
Also, if you need to do this regularly from your computer, don’t miss my tip on how to do this more efficiently.
By the way, if you are new to Raspberry Pi and want a step-by-step guide on how to do anything with it, feel free to check my e-book “Master your Raspberry Pi in 30 days”. It’s a 30-day challenge in which you’ll learn one new skill each day by practicing along the way. You’ll save time, money and start to enjoy any new project you want to try.
Connect to your Raspberry Pi (SSH)
In this first part, I will explain the things you need to access your Raspberry Pi via SSH. You can skip this if you are already connected, but it’s a prerequisite if you want to stop your Raspberry Pi remotely
Make sure SSH is enabled
Before anything else, make sure the SSH service is running.
By default, it’s not the case on Raspberry Pi OS, so you need to enable it.
Here is how to do this.
Raspberry Pi OS Desktop
If you have a desktop version, you can enable SSH like this:
- Open the main menu, and go to Preferences
- Start the Raspberry Pi Configuration tool
- In the “Interfaces” tab, click on “Enable” on the second line (“SSH”)
Click OK to apply the changes.
From now, the SSH service will be started automatically on boot.
Raspberry Pi OS Lite
On Raspberry Pi OS Lite, the easiest way is to use raspi-config to do this:
- Use the following command:
sudo raspi-config - Go to Interface Options
- Then SSH
- And answer yes to the question “Would you like the SSH server to be enabled?”
The SSH server will start directly, and be enabled on boot, so you don’t have to do this each time.
Find your Raspberry Pi IP Address
Before connecting to your Raspberry Pi remotely, you’ll also need the IP address.
On Raspberry Pi OS Desktop, you can get it easily by hovering your mouse over the network icon in the top-right corner.

On Raspberry Pi OS Lite, you can use this command:
ifconfig
The IP Address is on the second line, after the “inet” keyword.
If you need further assistance for this step, I have a dedicated tutorial on the topic here.
Connect to the Raspberry Pi
Once the Raspberry Pi configured, you can now access it via SSH.
As Windows now includes an SSH client, you can use the same command whatever your operating system.
- Open a terminal (or the command prompt on Windows)
- Type the following command:
ssh pi@IP_ADDRESS
Replace IP_ADDRESS with the one you got in the previous step - On the first connection, you might need to accept the Raspberry Pi fingerprint, type “yes” and press Enter.
- Then enter the password (default: raspberry)
That’s it, you are now connected to your Raspberry Pi.
You can follow the next part to stop it from there.
Reminder: Remember that all the members of my community get access to this website without ads, exclusive courses and much more. You can become part of this community for as little as $5 per month & get all the benefits immediately.
Shut down your Raspberry Pi via SSH
Pulling out the power supply, or using the power button of the case, is not the right way to stop a Raspberry Pi. It may corrupt the SD card depending on the processes in progress.
In this part, I will give you three commands to properly shut down the Raspberry Pi, and also a few tips to go further.
The 3 commands you can use to stop a Raspberry Pi
Without further ado, here are the three commands you can use to stop a Raspberry Pi :
- Halt
Probably the one to remember as it’s the shortest one:
sudo halt
There are a few options available, but that are not really useful in our case. So, the simple command like this should be enough. - Poweroff
It’s an alias of halt, you can use it if you prefer, but it’s basically the same one:
sudo poweroff - Shutdown
This one is more interesting as there are several useful options available.
The basic command to stop your Raspberry Pi will be:
sudo shutdown now
Options you may want to try:- Stop the Raspberry Pi in one minute
sudo shutdown
Other users will be notified. - Schedule the Raspberry Pi shutdown at a specified time
sudo shutdown 06:00
You can also use a cron for more options - Cancel scheduled shutdown
sudo shutdown -c
In all cases, you need the administrator privileges to stop the system, so don’t forget to put the sudo command at the beginning if you aren’t already logged as root.
Also, once a shutdown is scheduled, non-administrators can’t log in anymore, they will get an error message:
System is going down. Unprivileged users are not permitted to log in anymore.Create a script to automate this from your computer
In theory, you should be doing this every time you use your Raspberry Pi.
In some cases, it’s not the most convenient way. If your Pi is embedded, you might not want to connect to SSH each time just to stop it.
No problem, you can “automate” this.On Windows
For Windows users, the easiest way is to use Putty in command line:
- Install Putty if you don’t have it yet.
It’s a free SSH client. - Create two new files:
stop-pi.bat
stop-cmd.txt - In stop-pi.bat, paste the following line:
putty.exe -ssh pi@<IP> -pw <PASSWORD> -m stop.txt
Don’t forget to put the IP address and password corresponding to the Raspberry Pi you want to stop. - And in stop-cmd.txt:
sudo shutdown now - Save everything and double-click on stop-rpi.bat
It should shut down your Raspberry Pi directly. You can close the windows opened by the script on your computer.
Not bad, you can now create a shortcut somewhere if you want, and use this each time you want to stop your Raspberry Pi.
On Linux / macOS
On Linux / macOS, it’s almost the same thing, but you’ll need to create a bash script.
Firstly, make sure to generate an SSH key and that you can access your Pi without typing any password.
Then paste this line in a new bash script:
ssh pi@<IP> «sudo shutdown now»You can also use SSH keys on Windows, but it’s a bit more complicated, so Putty is the easiest way.
Turn the Raspberry Pi back on
Unfortunately, there is no way to power the Raspberry Pi back on remotely after this. So, the only thing you need to do is to unplug the power supply and plug it back in.
If there is a power button on your case, using it twice should work.
Unlock the secrets of your Raspberry Pi
As you can see, even the things that seem pretty basic at first glance might take a long time when you are new to Raspberry Pi and Linux. So, trying bigger projects might be frustrating.
My goal on this website is to help you as much as possible, and if you need a boost in your learning, make sure to check my Raspberry Pi boot camp.
It’s a course for anyone who is just starting or want to start, to quickly overcome the first questions and have fun along the way.Frustrated IT Engineer
We all know that you can shutdown your raspberry Pi by pulling the power cable out of the raspberry Pi or by turning the power supply off at the power switch.
However this can create problems by corrupting you SD card resulting in strange things happening when the Raspberry Pi is running or the Raspberry Pi not turning back on again after you powered it off using the above shutdown method.
To make sure this does not happen to you need to use the following commands
In the GUI
In the GUI left click in the bottom left hand corner on the blue cross to display the options menu (Like the start button in windows) go to accessories and then left click on LXterminal to display the terminal window
From the terminal window inside the GUI or direct from the command line
Type in the following command to shut down your Raspberry Pi
sudo shutdown or Sudo halt
(we use sudo command for “run as admin” as the standard account is not an admin)
(You can not shutdown or reboot the raspberry pi with a normal account)
Type in the following command to shut down your Raspberry Pi
(we use sudo command for “run as admin” as the standard account is not an admin)
(You can not shutdown or reboot the raspberry pi with a normal account)
This will then start the shutdown or reboot producer once complete you can then power off your Raspberry Pi
20 удобных команд терминала Raspberry Pi для начинающих

То, с чем сталкиваются многие люди, когда они впервые начинают использовать компьютер Raspberry Pi, — это терминал .
Вы можете превратиться из счастливого пользователя графического интерфейса Windows в черно-зеленый экран в ретро-стиле без кнопок или чего-либо, что можно дважды щелкнуть. Это может быть страшно, так как вы используете графический интерфейс с первого компьютера.
Но есть много маленьких хитростей и команд, которые могут помочь пользователям обрести уверенность в использовании системы.
Здесь нет ничего продвинутого или новаторского — только простые повседневные команды, которые помогут вам ориентироваться и выполнять простые задачи с вашим Raspberry Pi из окна терминала. Со временем вы найдете больше, но это хороший базовый набор для начала.
- Stop the Raspberry Pi in one minute