Setting Up A New Raspberry Pi

Steps I do when I am setting up a new Raspberry Pi.

If using the official LCD screen, for some unknown reason, it still defaults to an upside-down orientation when hooked up. This is simple to fix. Edit /boot/config.txt and add the following line:


The 2 rotates it 180º (the most likely choice for most display cases). 1 would be 90º, and 3 would be 270º.

Go into raspi-config and enable ssh so you can access it from remote. Also, set you locale settings. Set the wifi-country, and choose your SSID config if you plan to use WiFi.

Patch it:

apt update ; apt upgrade 

Change the password for the pi and root accounts.

passwd pi
sudo passwd root 

Create your own user if you don’t want to use the pi username (their document says the command is adduser, but I use useradd):

useradd -g users -G $( grep pi /etc/group | cut -f 1 -d ':' | egrep -v "^pi$" | tr '\n' ',' | sed -e "s/,$//" ) -m sgarrett

That is one long line. It assigns the same groups to the new user account as the user pi has so you will already be set up with most of the system permissions you need.

Don’t forget to set a password for the account:

passwd sgarrett

Add a config to /etc/sudoers.d so you don’t have to enter your password to elevate your privileges:

cd /etc/sudoers.d ; sed -e "s/^pi/sgarrett/" 010_pi-nopasswd > 010_sgarrett-nopasswd ; chmod 0440 010_sgarrett-nopasswd

Set up the screen to have a cooler font and color.

Set up SMB shares:

Install the SAMBA suite and some useful tools.

apt install samba samba-testsuite smb4k smbc smbclient smbmap

Then, add the accounts you want to the samba password file:

smbpasswd -a sgarrett

Users are tracked in a separate database for samba, so a user has to be created in that database. PAM and SAMBA will synchronize when you change your password.

Edit the SAMBA config file /etc/samba/smb.conf to your own tastes. At a minimum, you will probably want to change the read only flag for the [homes] share to no so you can write to your home directory when you mount the share.

If you plan to mount shares from a Mac, you might want to add the appropriate settings.

Announcing services via mDNS (avahi-daemon)

I find it useful to have my services (ssh, sftp, samba, etc) announced via Bonjour (mDNS) so I can browse for the services, especially on ephemeral VMs that I create for testing and do not set up DNS for. This is where the Avahi service comes in.

First, install the avahi-daemon package:

apt install avahi-daemon

Then copy the ssh and sftp service files into avahi’s configuration:

cp /usr/share/doc/avahi-daemon/examples/ssh.service /usr/share/doc/avahi-daemon/examples/sftp-ssh.service /etc/avahi/services/

Then restart the service:

systemctl restart avahi-daemon

1 thought on “Setting Up A New Raspberry Pi”

Leave a Comment