Pi Lab
Table of contents
Setup Pi imager
- Download the
Raspberry Pi Imagerto the local PC where you plug your SD card- Using command to install:
sudo apt install rpi-imager
- Using command to install:
-
Mac user, spotlight search and run
Raspberry Pi Imager -
Select OS » SD card » Write
- Insert SD card to Pi
- Note:
power supply levelis key to boot up the pi, you might see pi is on but nothing comes up on the monitor
- Note:
First time loading
- Wait until
Cloud-Initfully loaded, then loginDefault login and password: ubuntu * first time login will prompt for password update - Run
sudo touch /etc/cloud/cloud-init.disabledto disablecloud-init
Config network and using Wifi for ssh
- Note: all config files are space sensitive
-
Run below command to config
echo "network: {config: disabled}" > /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg -
Open
01-netcfg.yamlsudo vim /etc/netplan/01-netcfg.yaml -
Add below content to
01-netcfg.yaml, ensure the indent space.network: version: 2 renderer: networkd wifis: wlan0: dhcp4: true dhcp6: true optional: true access-points: "my-wiki-name": password: "**********" -
Run the below commands to enable the wifi network
sudo netplan generate sudo netplan apply reboot
Hostname change & local hosts
- Change hostname run:
sudo vim /etc/hostname - Location for host file:
/etc/hosts
Change to root user
sudo -i
Install net-tools
apt install net-tools
# error: Could not get lock /var/lib/dpkg/lock-frontend
# solution run below command:
sudo killall apt apt-get
Get hostname and IP from the Pi
ifconfig
# Output of network
hostname -I
# Output: hostname: 192.168.0.1
Change users
- Run
sudo -ito change to root, usepasswdto change password - Add new user:
adduser new-user-name - See user privilege:
visudo -
User privilege specification
root ALL=(ALL:ALL) ALL -
Add below to
visudoto give new user with root privilegenew-user-name ALL=(ALL:ALL) ALL
SSH into raspberry PI
ssh pi@192.168.0.1