manniru
11/6/2017 - 9:41 PM

Raspberry Pi Cheatsheet

Raspberry Pi Cheatsheet

// ssh
ssh pi@raspberrypi.local

// Make raspberry pi ssh over usb:
// Insert flash drive to my mac
// Add the following to the end of /config.txt:
# Make usb act like ethernet
dtoverlay=dwc2
# Ensure HDMI will work
hdmi_force_hotplug=1
// Add the following to /cmdline.txt, right after rootwait:
modules-load=dwc2,g_ether
// Create a blank file named ssh in the same root directory as config.txt and cmdline.txt

// Install on screen keyboard
// Open Terminal and run:
sudo apt-get install matchbox-keyboard
sudo apt-get update
sudo reboot

// VNC
// SSH into pi and run
sudo apt-get install tightvncserver
// Run tightVNC on the pi to set up password, etc
tightvncserver
// On Mac, press Command + K and enter the following for the server address:
vnc://raspberrypi.local:5901


// SET UP WIFI VIA TERMINAL
// add the following to /etc/network/interfaces
// To join unsecured network (no password), leave out the wireless-key line
auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet dhcp
wireless-power off // prevents wifi from going to sleep
wireless-essid Your-Network-Name
wireless-key Your-Network-Password

// SET UP WIFI WHEN USING NOOBS
// Add wpa_supplicant.conf file to root of boot partition 
// Example wpa_supplicant file: https://gist.github.com/lmjabreu/5677414

// Install NPM on raspberry pi
sudo apt-get update
sudo apt-get install npm

// If NPM says it can't find dependencies for packages:
npm set registry https://registry.npmjs.org/

// Prevent Pi from going to sleep:
sudo nano /etc/modprobe.d/8192cu.conf
// Add the following:
# Disable power management
options 8192cu rtw_power_mgnt=0

// Prevent network adaptor from going to sleep:
nano /etc/network/interfaces
// Add this line below iface wlan0 inet manual
wireless-power off
// Test by running iwconfig

// If pi still "goes to sleep" after running for awhile, try switching router to a quieter channel

// Reboot pi daily at 4:05 am
crontab -u pi -e
// Add this line to crontab:
0 4   *   *   *    /sbin/shutdown -r +5

// Disable logging to reduce writes to the SD card 
// Edit the file /etc/rsyslog.conf and just after the section starting
// ###############
// #### RULES ####
// ###############
// Add the following line.
*.*     ~