Raspberry Pi setup notes
Raspberry Pi setup notes
Written on
Sep 7, 2020
Updated on
Sep 15, 2020
Setting up wireless networking
You will need to define a wpa_supplicant.conf file for your particular wireless network:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 country=<Insert 2 letter ISO 3166-1 country code here> network={ ssid="<Name of your wireless LAN>" psk="<Password for your wireless LAN>" }
Plain Text
Put this file in the boot folder (On Windows is a dedicated drive), and when the Pi first boots, it will copy that file into the correct location in the Linux root file system and use those settings to start up wireless networking.
Connecting via SSH
By default the pi will appear as raspberrypi in your local network. It will also boot with a default user called pi. You can ssh into it by running ssh pi@raspberrypi and using raspberry as password.
Adding a new user
sudo adduser <user>
To give the user sudo privileges:
sudo adduser <user> sudo
Note that you might need to add the user to other specific groups to make use of certain capabilities (e.g. the video group to take pictures with a camera attachment). You can do this with the same command, but replacing sudo with the group of your choosing. Here's a list of all the groups that the default user belongs to (you can use groups <user> to check the which groups a particular user belongs to):
Change Network Hostname
You can change the visible name of the pi on the network (which will also by the name you ssh to and log in your samba server from - more about this later) by using the official configuration tool. First, run sudo raspi-config, then choose the following options:
Alternatively, edit the hostname file by typing sudo nano /etc/hostname
The change will be effective on the next reboot. To reboot the pi, type sudo reboot
Setting up a Samba file server
By setting up a samba file server we can access specific folders on the pi directly via the file explorer, making us able to open files and folders in visual studio code, and generally treat it like a generic folder on our PC.
First, install samba:
sudo apt-get update sudo apt-get upgrade sudo apt-get install samba samba-common-bin
Create the folder you intend to share:
mkdir /home/pi/shared
Open the samba configuration file by running:
sudo nano /etc/samba/smb.conf
Add the entry for the newly created folder to the config file (the entry name between square brackets will be the name of the shared location as it appears on your network):
[shared folder] Comment = Pi shared folder Path = /home/pi/shared Browseable = yes Writeable = yes only guest = no create mask = 0777 directory mask = 0777 Public = yes Guest ok = yes
Plain Text
Then, we need to add a user and password to Samba. Once the user has a local account their corresponding Samba samba user can be added using:
sudo smbpasswd -a <user>
You can view a list of all registered samba users with:
sudo pdbedit -L -v
Finally, restart the samba service:
sudo service smbd restart
You can now access the shared samba folder by navigating to your PI network hostname (eg. \\raspberrypi)
Alternatively, you can map any of the shared folders directly to a drive using the same username / password combination as credentials: