Raspberry Pi Fresh Install Must-Dos, Must-Haves, and Nice-to-Haves #raspberrypi


Disclaimer: These are just quick notes that can be considered to adopt when you install a fresh Raspberry Pi. It is far and far from a solid, sound, or even correct summary. Use it at your own risk. We don't assume any damages or bad things happen to your raspberry pi.

Change default user (assume XNAME is your preferred user name)

(Method 1) #Add user delete pi (source)

sudo adduser XNAME
sudo adduser XNAME sudo
sudo adduser XNAME video
uncheck auto login to pi
sudo reboot
# login as XNAME
sudo deluser pi

(Method 2) #Add user XNAME, reduce Pi admin (source)

sudo adduser XNAME
sudo adduser XNAME sudo
sudo adduser XNAME adm
sudo adduser XNAME video
sudo deluser pi sudo sudo deluser pi adm sudo mv /etc/sudoers.d/010_pi-passwd /etc/sudoers.d/010_pi-passwd.org sudo visudo (check if needed to use # to comment out pi user line)

# Run sudo without password (source)
# sudo visudo and add the following line
# ?? echo "$USER ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/dont-prompt-$USER-for-password

Update and upgrade all

sudo apt update
sudo apt upgrade
sudo apt dist-upgrade
sudo apt autoremove

Useful Tools

# EXFAT filesystem

sudo apt install -y exfat-utils
sudo apt install -y midori
# correct raspiberry camera awb
# append to /boot/config.txt
# mouse wireless floating fix
sudo vi /boot/cmdline.txt
usbhid.mousepoll=0 (append at the end)
# mouse wireless floating fix on LibreElec
sudo vi /media/pi/System/cmdline.txt
usbhid.mousepoll=0 (append at the end)
# find temperature in mC
cat /sys/class/thermal/thermal_zone0/temp
# adjust audio volume for AV Jack (source)
alsamixer > F6 > select AV > up, up, up
# conky
sudo apt install -y conky
wget -O /home/pi/.conkyrc https://raw.githubusercontent.com/novaspirit/rpi_conky/master/rpi3_conkyrc
sudo cp ./conky.sh /usr/bin/.
sudo cp ./conky.desktop /etc/xdg/autostart/.
# remove spaces in file names
for f in */* ; do mv "$f" "${f// /_}"; done
# headless RPI VNC resolution settings (source here)
sudo vi /boot/config.txt
comment out: #dtoverlay=vc4-fkms-v3d
set framebuufer w: framebuffer_width = 1920 set framebuufer h: framebuffer_height = 1080
# setup static ip address (source here)
# on the RPI side: 
sudo vi /etc/dhcpcd.conf
# find the eth0 and ensure
static ip_address=192.168..../24
domain... =
dns... =
# then restart
# --------^-v-------------------------------
# on the Windows 10 side
# find the connecting ethernet device properties
> Edit > Manual IP address > IP4
> IP = 192.168.0....
> Prefix Length = 24
> Gateway =
> DNS =
# save and try it now
# firefox
sudo apt install firefox-esr
# install Sys V banner and figlet
sudo apt install sysvbanner # then run "banner test"
sudo apt install figlet
# fortune command
sudo apt install fortune-mod # run "fortune"
# to create your own
vi myfortune # fill with quotes separated by a line with %
strfile -c % myfortune myfortune.dat
# test it by fortunte myfortune
# to be permanently included: 
sudo cp myfortune* /usr/share/games/fortunes/ #two files only
# to be automatically invoked in a new terminal
add "fortune" to the end of ./.bashrc file
# YT-DL (source)
sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl
youtube-dl -U
# mypaint
sudo apt install mypaint
# kodi on raspi OS
sudo apt install kodi
sudo kodi # must sudo; otherwise mouse/kbd don't work
# UTube DL (source)
sudo apt install snapd
sudo reboot
sudo snap install youtube-dl
youtube-dl (weblink)
# change window manager (source)
sudo aptitude install x-window-system xfce4 xfce4-themes icewm fluxbox gnome
sudo update-alternatives --config x-window-manager
# add a system start up script
crontab -e
@reboot (script)
# install full xscreensaver (source)
sudo apt-get install xscreensaver xscreensaver-data-extra xscreensaver-gl-extra
# a good screensaver = Polytopes 
# install Freenove project code (no source)
# first enable I2C in raspi-config > Interace Options > I2C (enable)
sudo apt install wiringpi
git clone --depth 1 https://github.com/freenove/Freenove_RFID_Starter_Kit_for_Raspberry_Pi
mv Freenove_RFID_Starter_Kit_for_Raspberry_Pi/ Freenove_Kit/
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb
gpio -v
gpio readall
# install OpenMediaVault and Share (source)
wget -O - https://github.com/OpenMediaVault-Plugin-Developers/installScript/raw/master/install | sudo bash
# copy entire text file to clipboard via xclip
sudo apt install xclip
xclip -sel c < the.text.file

# install Brother print driver (specifically Brother HL-L2300D) (source)

sudo apt install printer-driver-brlaser
sudo service cups restart
http://localhost:631 (and login with linux credential)
# add a printer (seelct USB connect printer, set names and share)
# for Brother HL-L2300D, select DCP-1510 series, using brlaser v4 (grayscale)
# note: dont select HL-L2300D driver; sometimes it does not work
# run a test page 

Pi Zero Wifi Setup(source.20201112)

# edit wpa_supplicant.conf and add the followings:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev


Timelapse (source)

raspistill -t 10000 -tl 2000 -o pic%04d.jpg
# use Kdenlive to build video (source - 20201109)

# just a tip on building ffmpeg (not used)

git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
# "INSTALL.md" to make ffmpeg
sudo ./configure
sudo make 
sudo make install
# convert to mp4
ffmpeg -r 5 -i pic%04d.jpg -c:v libx264 video-file.mp4
# or 
ffmpeg -framerate 10 -pattern_type glob -i "*.png" out.mkv

SAMBA (source)

sudo apt install -y samba samba-common-bin
mkdir ~/xtmp
chmod 777 ~/xtmp
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.org
sudo vi /etc/samba/smb.conf
# add the followings at the end of samba.conf file
netbios name = XNAME
server string = My File Center
workgroup = WORKGROUP

path = /home/XNAME/xtmp
comment = No comment
create mask=0777
directory mask=0777
# add samba user and restart server
sudo smbpasswd -a "XNAME"
sudo service smbd restart

Mount Windows Samab Share (source - 20201109)

sudo mount -t cifs -o username= ///folder /mnt/folder

Automount Ext-HD (SOURCE)

#collect HD info

#edit /etc/fstab and add the lines
sudo vi /etc/fstab
# add the followings:
# external usb drives
UUID=88E0F8B0E0F8A61A /mnt/araw auto nofail,uid=1001,gid=1001,noatime 0 0
UUID=1EC01C01C01BDE39 /mnt/ashw auto nofail,uid=1001,gid=1001,noatime 0 0
UUID=EAE47E21E47DF065 /mnt/avrg auto nofail,uid=1001,gid=1001,noatime 0 0
UUID=D2384D2C384D10C1 /mnt/amm auto nofail,uid=1001,gid=1001,noatime 0 0
UUID=AA97-B501 /mnt/amdl auto nofail,uid=1001,gid=1001,noatime 0 0
# save and reboot


#setup Apache (source here)

sudo apt install apache2 -y 
#setup Apache login secure website (source here)
# install util file 
sudo apt install apache2-utils
# create user(s) 
sudo htpasswd -c /etc/apache2/.htpasswd USER1 # enter USER1 passwd x 2, passwd file created  
cat /etc/apache2/.htpasswd #check the users are created 
# config apache2 security feature
sudo vi /etc/apache2/sites-enabled/000-default.conf 
# add the following lines literally, before </VirtualhHost> tag 
    <Directory "/var/www/html">
        AuthType Basic
        AuthName "Restricted Content"
        AuthUserFile /etc/apache2/.htpasswd
        Require valid-user
# save and retart apache2 and check the login 
sudo service apache2 restart

Wordpress (source)(php-gd source)

# copy and paste into command line 
# install apache2
sudo apt install apache2 -y
# install php
sudo apt install php -y
sudo apt install php-gd -y
# install MariaDB
sudo apt-get install mariadb-server php-mysql -y
sudo service apache2 restart 
# download WordPress
sudo rm /var/www/html/* 
sudo wget http://wordpress.org/latest.tar.gz
sudo tar xzf latest.tar.gz
sudo mv /var/www/html/wordpress/* /var/www/html/.
sudo rm -rf /var/www/html/wordpress /var/www/html/latest.tar.gz
sudo chown -R www-data: /var/www/html/.
# setup WordPress DB
sudo mysql_secure_installation

	Enter - no root password yet

	Y = remove anonymous users
	Y = disallow root login remotely 
	Y = remove test database and access to it 
	Y = reload privilege tables now 

sudo mysql -uroot -p
	create database wordpress;
(open a browser) -> http://localhost 
	English (US)
	(your root passwd)
	(host IP address)
	[Run the install]
(open another browser) -> http://localhost/wp-admin 
	fill out the blanks
	* go to Settings / General -> wordpress URL = 192.168.??.??
	* go to Settings / General -> site URL = 192.168.??.??
	* go to Settings / Permalinks -> "Post name" 
(back to OS)
sudo a2enmod rewrite
sudo vi /etc/apache2/sites-available/000-default.conf
# add the following 3 lines after line 1:
	<Directory "/var/www/html">
	AllowOverride All
sudo service apache2 restart
# Install RapidWP or GridMe Theme (look good)

Direct Eithernet with Windows 10 (source)

# Connect directly with an ethernet cable.
# If both IP addresses are on the same subnet,
# you are good to go and ssh it
# to copy files to windows


# install syncthing (source)
sudo apt install syncthing
vi ~/.config/syncthing/config.xml
# change to
syncthing (then ctrl-c to end)
# Making it a service
# sudo service syncthing start
crontab -e (and add the following line)
@reboot /usr/bin/syncthing

Allow Headless RPi VNC Server (source)

sudo raspi-config
-> Advanced Options -> Resolution
Select anything but the default (e.g. 1920 x 1080) -> Ok
and reboot

Add a second virtual remote realVNC desktop (source)

sudo vi /etc/systemd/system/vncvirtualdesktop.service
# and insert the followings:
Description=Start VNC Server Virtual Desktop

ExecStart=/bin/su pi -c '/usr/bin/vncserver -randr=1280x1024'
ExecStop=/usr/bin/vncserver -kill :1

# and save, exit, and enable the service
sudo systemctl enable vncvirtualdesktop.service
# and reboot and VNC to x.x.x.x:1 (the :1 display)

Octopi Setup

# obtain (Octopi image)
# write to SD card and edit wifi file at /boot folder

# notepad++ /boot/octopi-wpa-supplicant.txt
# uncomment Network = {...} and uncomment Country = US
# also add scan_ssid=1 inside {...} if wifi ssid is hidden (source)
# after installed on rpi, boot, login: pi/raspberry
# change password by "passwd" command
# then you can login remotely via the web interface http://ip_address

3.5" Screen Driver (NOTE: use 2019-09-26 Buster Full Image + MHS35B-show script) (source)

sudo rm -rf LCD-show
git clone https://github.com/goodtft/LCD-show.git
chmod -R 755 LCD-show
cd LCD-show/
sudo ./MHS35B-show
# rotate screen e.g. 270 degrees
sudo ./rotate.sh 270
# switch to HDMI
sudo ./LCD-hdmi

Timelapse and Zips

# Timelapse first
mark=`date +%F-%H`
mkdir $tlhome/$mark
chmod 777 $tlhome/$mark
raspistill -t 5000 -tl 1000 -o $tlhome/$mark/$mark-%04d.jpg
sleep 60
# Zip at the end
zip -r $zipfile $tlhome/$mark
if test -f "$zipfile"; then
	rm -r $tlhome/$mark

Hidden SSID Wifi Connection

# edit wpa_supplicant file and mod/add below

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
        ssid="your hidden SSID"
        psk="your password"

Minimal Raspberry Pi Lite + Pixel Desktop (source)

# install Raspi OS Lite 
sudo apt install raspberrypi-ui-mods
# configure everything (locale, keyboard, passwd,...)

PIR Sensor Test Program

import RPi.GPIO as GPIO
import time
PIN = 4
X = 0
GPIO.setup(PIN, GPIO.IN)         #Read output from PIR motion sensor
	print "starting"
	while True:
		if i==0:                 #When output from motion sensor is LOW
			X += 1
			print "No motion",X, "sec"
		else:               #When output from motion sensor is HIGH
			print "something moving",i
			X = 0
except KeyboardInterrupt: 
	print "out"

MMM Config File

/* Magic Mirror Config Sample
 * By Michael Teeuw https://michaelteeuw.nl
 * MIT Licensed.
 * For more information on how you can configure this file
 * See https://github.com/MichMich/MagicMirror#configuration

var config = {
	address: "localhost", 	// Address to listen on, can be:
							// - "localhost", "", "::1" to listen on loopback interface
							// - another specific IPv4/6 to listen on a specific interface
							// - "", "::" to listen on any interface
							// Default, when address config is left out or empty, is "localhost"
	port: 8080,
	basePath: "/", 	// The URL path where MagicMirror is hosted. If you are using a Reverse proxy
					// you must set the sub path here. basePath must end with a /
	ipWhitelist: ["", "::ffff:", "::1"], 	// Set [] to allow all IP addresses
															// or add a specific IPv4 of :
															// ["", "::ffff:", "::1", "::ffff:"],
															// or IPv4 range of --> use CIDR format :
															// ["", "::ffff:", "::1", "::ffff:"],

	useHttps: false, 		// Support HTTPS or not, default "false" will use HTTP
	httpsPrivateKey: "", 	// HTTPS private key path, only require when useHttps is true
	httpsCertificate: "", 	// HTTPS Certificate path, only require when useHttps is true

	language: "en",
	logLevel: ["INFO", "LOG", "WARN", "ERROR"],
	timeFormat: 24,
	units: "metric",
	// serverOnly:  true/false/"local" ,
	// local for armv6l processors, default
	//   starts serveronly and then starts chrome browser
	// false, default for all NON-armv6l devices
	// true, force serveronly mode, because you want to.. no UI on this device

	modules: [
			module: "alert",
			module: "updatenotification",
			position: "top_bar"
			module: "clock",
			position: "top_left"
			disabled: true,
                	module: 'mmm-moon-phases',
                	position: 'bottom_left',
			disabled: true,
			module: 'MMM-PIR-Sensor', 
				position: "top_center", // Remove this line to avoid having an visible indicator
				config: {
					sensorPin: 4,
					powerSavingDelay: 30, // Turn HDMI OFF after 60 seconds of no motion, until motion is detected again
					preventHDMITimeout: 4, // Turn HDMI ON and OFF again every 4 minutes when power saving, to avoid LCD/TV timeout
					supportCEC: true, 
					presenceIndicator: "fa-eye", // Customizing the indicator
					presenceOffIndicator: "fa-eye", // Customizing the indicator
					presenceIndicatorColor: "#f51d16", // Customizing the indicator
					presenceOffIndicatorColor: "#2b271c" // Customizing the indicator
			// disabled: true,
			module: "MMM-Wallpaper",
			position: "fullscreen_below",
			config: {
				source: "/r/EarthPorn",
				slideInterval: 15 * 1000,
				maximumEntries: 30,
		// {
			// disabled: "true",
			// module: "MMM-PoemOfTheDay",
			// position: "Top_right",
			// config: {
				// textLimit: 1000,
				// lineLimit: 10,
				// languageSet: ["en"],
				// updateInterval: 30 * 1000
			// }
		// },
			module: 'MMM-MWWordOfTheDay',
			position: 'top_right',
			config: {
				updateInterval: 120000,
				headerText: "Word of the day"

  		module: 'MMM-Reddito',
  		position: 'top_right',
  		config: {
    			updateInterval: 3600000,
    			headerText: "Reddito",
    			subreddit: "news",
    			sortby: "hot", //hot, new, or top
    			showCount: "25", //Max 25
    			width: "300px",
    			height: "20em",
    			marquee: true,
    			marqueeSpeed: "30000",
    disabled: true,
    module: "MMM-HTMLSnippet",
    position: "top_left",
        config: {
	html: '',
        width: "800px",
        height: "1024px",
        backgroundColor: "#000",
        updateInterval: 3600000, // in milli seconds

			disabled: true, 
			module: 'MMM-ImageSlideshow',
			position: 'bottom_right',
			config: {
				fixedImageWidth: '400',
				randomizeImageOrder: 'true',
				imagePaths: ['modules/MMM-ImageSlideshow/XPIX']
		//disabled: true,
		module: "currentweather",
		position: "top_left",
		config: {
			location: "Pasadena",
			locationID: "5381396", 
			units: 'imperial',
			updateInterval: '3600000',
			appid: "616d28e9ad2143ac01c8f27387d0eff9"
	{	//disabled: true,
		module: "weatherforecast",
		position: "top_left",
		header: "5-Day Weather Forecast",
		config: {
			maxHeight: "100%",
			location: "Pasadena",
			locationID: "5381396", 
			appid: "616d28e9ad2143ac01c8f27387d0eff9",
			units: 'imperial',
			updateInterval: '3600000',
			initialLoadDelay: '500',
			iconTable: {
				    '01d': 'wi-day-sunny',
				    '02d': 'wi-day-cloudy',
				    '03d': 'wi-cloudy',
				    '04d': 'wi-cloudy-windy',
				    '09d': 'wi-showers',
				    '10d': 'wi-rain',
				    '11d': 'wi-thunderstorm',
				    '13d': 'wi-snow',
				    '50d': 'wi-fog',
				    '01n': 'wi-night-clear',
				    '02n': 'wi-night-cloudy',
				    '03n': 'wi-night-cloudy',
				    '04n': 'wi-night-cloudy',
				    '09n': 'wi-night-showers',
				    '10n': 'wi-night-rain',
				    '11n': 'wi-night-thunderstorm',
				    '13n': 'wi-night-snow',
				    '50n': 'wi-night-alt-cloudy-windy'

		disabled: true,
    		module: "MMM-EyeCandy",
    		position: "top_center",
    				config: {
        				maxWidth: "75%",       // Sizes the images. Retains aspect ratio.
        				style: '49',            // Style number or use ownImagePath to override style
        				ownImagePath: 'https://1.bp.blogspot.com/-8e1xukL78TM/VpwfzzYFKCI/AAAAAAABHHI/ou3T2WvZXgo/s1600/Franchesca%2BDel%2BCarpio%2Bwith%2BPy%2B-%2BPy25%2BStudio%2B%252827%2529.jpg',      // ex: 'modules/MMM-EyeCandy/pix/YOUR_PICTURE_NAME.jpg', or internet url to image

			module: "calendar",
			header: "US Holidays",
			position: "top_left",
			config: {
				calendars: [
						symbol: "calendar-check",
						url: "webcal://www.calendarlabs.com/ical-calendar/ics/76/US_Holidays.ics"					}
			module: "compliments",
			position: "lower_third"
			disabled: true, 
			module: "currentweather",
			position: "top_right",
			config: {
				location: "New York",
				locationID: "", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
			module: "weatherforecast",
			position: "top_right",
			header: "Weather Forecast",
			config: {
				location: "New York",
				locationID: "5128581", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
			module: "newsfeed",
			position: "bottom_right",
			config: {
				feeds: [
						title: "New York Times",
						url: "https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml"
				showSourceTitle: true,
				showPublishDate: true,
				showDescription: true,
				lengthDescription: 500,
				reloadInterval: 3600000,
				broadcastNewsFeeds: true,
				broadcastNewsUpdates: true
				module: 'calendar_monthly',
				position: 'top_left',
				config: {
						// The config property is optional
						// Without a config, a default month view is shown
						// Please see the 'Configuration Options' section for more information

/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {module.exports = config;}

Windows 10 powershell batch rename (source.20201118)

Dir *.jpeg | rename-item -newname {  $_.name  -replace ".jpeg",".jpg"  }