Raspberry Pis are some of the most reliable SBCs out there for hobbyist electrical projects and lightweight self-hosting. Here are 5 commands or utilities that every Pi user should know.
Check your temperature
Heat is the enemy of every PC out there, and Raspberry Pis can be more vulnerable to it than most. By default, they don't come with any kind of active cooling, and the only passive cooling you get is air moving over the CPU.
Even when you add a case with a fan, they're usually small. If you're running your Pi to the max, heat will quickly become an issue.
Sydney Louw Butler/How-To Geek
To keep an eye on how hot your Raspberry Pi is running, enter the following command in the terminal:
Ideally, you want to keep temperatures below 80C, and you may experience a safety shutdown if you go above 85C.
If you do run your Pi above the ideal temperature, you may find that the CPU throttles to reduce the load and help cool things down. You can run the following command:
If the command returns 0x0, then you're in good shape. If it returns anything else, you are or have experienced throttling, either due to heat or insufficient power.
Schedule a job using cron
If you're using your Raspberry Pi for any kind of self-hosting or homelab, you need to be able to schedule jobs that will run automatically.
Systemd is more fully featured and modern, but can be a bit more involved than I normally like. However, if you need more advanced functions it is the better option.
For example, I've used cron to automatically create backups of my Minecraft world. If you had a script that you wanted to run once a week, cron would be a good option.
To start, run:
Then, add the job you want to the file that opens. So if I wanted to run a script located in my user folder at every 2 AM, I'd enter 0 2 * * * /home/pi/script.shand then save it.
There are 5 "slots" in each cron entry. The first is minutes, the second is hours, the third is days, the fourth is months, and the fifth is day of the week.
So, if you wanted to run something at 4:15 am every Sunday, you'd enter:
It takes some getting used to, but once you have the hang of cronjobs, they're quick and easy to set up.
Monitor your resource usage with htop
Raspberry Pis aren't loaded with a ton of extra system resources, so it is important to keep an eye on what applications and services you have running.
One of the best and simplest applications for that job is htop, which is a command-line resource monitor . With it, you can view the activity of your CPU (including each core independently) and your RAM usage.
Htop also displays helpful information like which user a given task belongs to and what the process ID is, which can be helpful if you want to end or pause it later.
There are a number of things you can do with it, but the three controls I use the most often are:
Make remote connections with SSH
Not every Raspberry Pi is set up with a mouse, keyboard, and monitor all the time, and if it isn't, SSH is essential.
SSH allows you to remotely control one computer from another using just the command line, and is essential for some secure file transfer technologies—like SFTP and SCP —to work.
To enable SSH on your Pi and start it immediately, open a terminal and enter:
Then, double-check that it started correctly by running:
Now you'll be able to connect to the Pi over SSH from any device on the local area network.
Explore your network with nmap
If you're using your Raspberry Pi for homelabbing, self-hosting, or anything similar, you'll often need information about other devices on your local area network.
One of the most well-rounded network tools available is nmap, short for network mapper.
Nmap allows you to query local computers (including phones) to get their IP addresses, determine which operating system they're running, and sometimes even identify services running on them.
To install nmap, enter the following in the terminal:
One of the most basic things you can do—and still one of the most helpful—is a quick network scan to identify devices and their respective IP addresses.
So, if my router had the IP address 192.168.0.1, then I'd run:
If your router had the IP 10.0.0.1, then you'd need to run:
Nmap is an extremely capable program. If you're self-hosting or doing anything with networking, I'd recommend skimming the manual to learn more of the ins and outs.
Despite its diminutive size and limited resources, a Raspberry Pi can be a capable computer for self-hosting lightweight services. These commands are some of the most useful. Once you're familiar with them, you can start trying out any one of the huge number of Raspberry Pi projects out there.
