Raspberry Pi - Setup and First Steps
How to get a RasPi started
- Raspberry Pi
- Command-Line Configuration
- Restart
- Get IP address
- Install Jenkins on RasPi
- Change Swap-File Size
- Re-issue ssh keys
- Show processes
- Running a Python Script Automatically at Startup
- Autostart Desktop
- OnScreen Keyboard
- Disable Screensaver
- Install RSS-Reader
- ssh tips & tricks
- Starting up a Raspi Zero W without a screen
- Installing Pi-Hole
- Renaming the hostname
Raspberry Pi
Command-Line Configuration
sudo raspi-config
Restart
sudo shutdown -r now
Get IP address
ifconfig
Install Jenkins on RasPi
Change Swap-File Size
sudo /etc/init.d/dphys-swapfile stop
sudo nano /etc/dphys-swapfile
sudo /etc/init.d/dphys-swapfile start
Re-issue ssh keys
Delete key-files and re-create them
sudo rm /etc/ssh/ssh_host_* && sudo dpkg-reconfigure openssh-server
Invalidate keys on client side if successfully connected before:
ssh-keygen -R {ip-address of raspi}
Show processes
ps aux | less
Unresponsive processess can then be stopped via
kill
Running a Python Script Automatically at Startup
Because the Pi can act as a standalone appliance, a common question is how to launch a Python script automatically when the Pi boots up. The answer is to add an entry to the /etc/ rc.local file, which is used for exactly this in the Linux world.
Just edit the file:
sudo nano /etc/rc.local
and add a command to execute your script between the commented section and exit 0. Something like:
python /home/pi/foo.py&
The ampersand at the end will run the script as a background process, which will allow all the other services of the Pi to continue booting up.
Autostart Desktop
mkdir /home/pi/.config/autostart
nano /home/pi/.config/autostart/clock.desktop
[Desktop Entry]
Type=Application
Name=Clock
Exec=/usr/bin/python3 /home/pi/clock.py
[Desktop Entry]
Type=Application
Name=airflow-webserver
Exec=xterm -hold -e '/home/pi/.local/bin/airflow webserver -p 8080'
OnScreen Keyboard
sudo apt-get update
sudo apt-get install at-spi2-core florence
Disable Screensaver
The easiest way to disable screen blanking in the Raspbian GUI is to install xscreensaver then configure it to disabled.
sudo apt-get update
sudo apt-get install xscreensaver
In the [Display Mode] tab, set like this - Mode: [Disable Screen Saver] Source
Install RSS-Reader
sudo apt-get install quiterss
or
sudo apt install akregator
ssh tips & tricks
https://smallstep.com/blog/ssh-tricks-and-tips/
Starting up a Raspi Zero W without a screen
SSH aktivieren: Um den SSH-Zugriff zu aktivieren, erstellen Sie im Verzeichnis der MicroSD-Karte (/boot) eine leere Datei mit dem Namen “ssh” (ohne Dateierweiterung).
WLAN aktivieren: Um den WLAN-Zugriff zu aktivieren, erstellen Sie im Verzeichnis der MicroSD-Karte (/boot) eine Datei mit dem Namen “wpa_supplicant.conf” (die Dateierweiterung hier ist .conf – kein .txt dahinter stellen, sonst funktioniert es nicht) mit folgendem Inhalt:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1
network={
ssid=”
Installing Pi-Hole
curl -sSL https://install.pi-hole.net | bash
Renaming the hostname
sudo nano /etc/hostname