Categories :

Raspberry pi – Useful commands

ls #list a directories content
ls -l #list a directories content with details
cd #change directory
cd ~ #users home directory. eg /home/pi/
python #run the python program trailcam
sudo shutdown -r now #reboot the system
sudo shutdown -h now #halt the system
sudo nano /etc/ps rc.local #edit the file rc.local
sudo cp #make a file copy
python3 #run a python3 program

python3 – -version #to find what version of python is being used – – is a double dash no space
ps -ef #list all running processes
ps -ef | grep #show the PID nnn of the running process eg.
sudo kill nnn #kill the PID number nnn to stop the program
sudo raspi-config #Raspberry pi configuration tool
sudo wpa_cli list_networks #to see which network is connected
sudo wpa_cli select_network 0 or 1 (from previous command) #To change which network is connected
sudo ifconfig #show mac address an ip address
sudo df -h #Show disk space
sudo find / -name file.txt # / – directory to run the search (root)
vcgencmd get_throttled # check if the cpu clock is being throttled due to heat. Should return 0

  • Generate a backup of pihome db. run System Configuration Menu>Backup which will generate a file in /var/www eg
  • Install the pihome backup db into clean installation #
  1. copy the zip file to your pc and unzip, it should create a *.sql file
  2. install new image
  3. install updates
  4. copy the sql file back to the pi to say /home/pi
  5. on the pi run
  6. mysql -u root -ppassw0rd maxair < ‘the name of the sql file you copied’
  7. eg /home/pi/maxair_mysql_2021_09-22_11-07-52.sql

Raspberry pi – how to measure CPU and GPU Temperature

  • $ cd /var/www
  • $ sudo nano
  • Enter into the file
# Script:
# Purpose: Display the ARM CPU and GPU  temperature of Raspberry Pi 
# Under GPL v2.x+
# -------------------------------------------------------
echo "$(date) @ $(hostname)"
echo "-------------------------------------------"
echo "GPU => $(/opt/vc/bin/vcgencmd measure_temp | cut -d = -f2)"
echo "CPU => $((cpu/1000))'C"
  • Save the file and change permissions
  • $ sudo chmod +x
  • To run the file
  • $ ./
  • Sample output
Fri 24 Sep 21:58:07 BST 2021 @ maxair
GPU => temp=51.5'C
CPU => 51'C

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.