This guide walks you through setting up a Raspberry Pi (headlessly) using Raspberry Pi Imager, enabling SSH, configuring Wi-Fi, setting up VNC Viewer, fixing common issues, and using essential commands.
π₯ 1. Installing Raspberry Pi OS Using Raspberry Pi Imager
β Step 1: Download Raspberry Pi Imager
- Download from the official site.
- Install and launch it.
β Step 2: Flash the OS to the MicroSD Card
- Insert a microSD card (β₯16GB).
- Open Raspberry Pi Imager and select:
- Choose OS β Raspberry Pi OS (Recommended)
- Choose Storage β Select your SD card
βοΈ Configure Wi-Fi and SSH (Optional but recommended)
- Click the βοΈ (Settings) icon:
-
Set:
- Hostname
- Wi-Fi SSID & Password
- Enable SSH
- Hostname
Save & click Write to flash.
π οΈ Step 3: Manual Headless SSH & Wi-Fi Setup (If Not Done Above)
- Open the boot partition on the SD card.
- Create empty
ssh
file:
touch /boot/ssh
- Create
wpa_supplicant.conf
:
nano /boot/wpa_supplicant.conf
Paste:
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="Your_WiFi_Name"
psk="Your_WiFi_Password"
key_mgmt=WPA-PSK
}
- Save & eject. Insert into Pi and power on.
π» 2. Connect to Raspberry Pi via SSH
π Find the IP Address
- With monitor:
hostname -I
- Headless:
ping raspberrypi.local
π SSH from PC
ssh pi@<Raspberry_Pi_IP>
# Example:
ssh pi@192.168.1.100
- Default user:
pi
- Password:
raspberry
π 3. Update the Raspberry Pi
sudo apt update && sudo apt upgrade -y
π₯οΈ 4. Enable & Configure VNC
Enable VNC Server:
sudo raspi-config
- Go to Interfacing Options β VNC β Enable
- Exit & reboot:
sudo reboot
Install VNC Server (if needed)
sudo apt install realvnc-vnc-server realvnc-vnc-viewer -y
Start:
vncserver
π 5. Connect via VNC Viewer
- Download: VNC Viewer
- Enter your Raspberry Pi IP (e.g.
192.168.1.100
)
- Login:
- Username:
pi
- Password:
raspberry
- Username:
π§― 6. Fix: βCannot currently show the desktopβ
Fix 1: Set a Virtual Display
sudo nano /boot/config.txt
Uncomment or add:
hdmi_force_hotplug=1
hdmi_group=2
hdmi_mode=82
Then:
sudo reboot
Fix 2: Restart VNC
sudo systemctl restart vncserver-x11-serviced
# or
vncserver
Fix 3: Reinstall Desktop
sudo apt install --reinstall raspberrypi-ui-mods
sudo reboot
π οΈ 7. Essential Raspberry Pi Commands
π System Update
sudo apt update && sudo apt upgrade -y
π System Info
uname -a # Kernel
vcgencmd measure_temp # CPU Temp
df -h # Disk
free -m # RAM
βοΈ Services
sudo systemctl status vncserver-x11-serviced
sudo systemctl restart vncserver-x11-serviced
π Networking
ip a
ping google.com
π File Ops
ls
cd /path/to/folder
mkdir new_folder
rm -r folder_name
π Reboot/Shutdown
sudo reboot
sudo shutdown -h now
π 8. Set Static IP (Optional)
sudo nano /etc/dhcpcd.conf
Add:
interface wlan0
static ip_address=192.168.1.150/24
static routers=192.168.1.1
static domain_name_servers=8.8.8.8 8.8.4.4
Save and reboot.
π¦ 9. Install Useful Software
sudo apt install python3 python3-pip git nodejs npm -y
β‘ 10. Enable GPIO for Projects
sudo raspi-config
- Go to Interfacing Options β Enable GPIO
Install libraries:
sudo apt install python3-gpiozero python3-rpi.gpio -y
Test:
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
print("GPIO Ready!")
π 11. Optional: Web Server Setup (Apache)
sudo apt install apache2 -y
sudo systemctl status apache2
Access from browser:
http://<Raspberry_Pi_IP>
project files, or embed code repos.
Top comments (0)