Chapter 3 #
Initial Installation #
This chapter will show you how to perform an initial installation of the software that is to be used on your new Raspberry Pi computer.
The installation depends on the previous chapter as to whether you have purchased the optional monitor or not so this will be divided into two sections.
If you have followed chapters 1 and 2 it means you have purchased a Raspberry Pi computer so **welcome **to the world of Raspi and LINUX, the operating system that is used in the Raspberry Pi computer. In chapter 5 of this eBook I have a list of common and not so common Linux commands.
Raspberry Pi Imager #
Prior to setting up the computer you will need the software.
At https://www.raspberrypi.org/downloads/ there is a program called “Raspberry Pi Imager” that is used to install the software you have chosen to your SD-Micro card or SSD drive****. This program is available for L****INUX****, ****MAC and ****W****indows****.**** ****T****h****is**** program should be downloaded to your main computer ****(desktop or laptop)****, NOT the Raspberry Pi.****
**** When you install and run the above program the main menu will show 2 buttons:
Choose OS and Choose SD card****. Clicking ****Choose OS**** will show you ****9**** Operating Systems, including:****
***At the top is “Raspberry Pi OS (32-bit) Desktop, formally called Raspian. This is the recommended version. *This version contains the most used applications and the file size is approximately 1,136 MB in size.
The next option is Raspberry Pi OS (other). Clicking this option will show you the 2 other versions.
Lite, which as the name implies it is lite without all of the Graphical User Interface (GUI)**** applications,**** and ****the file weighs in at ONLY 434 MB. This is the version to be used when the computer is in Headless Mode(see below for definition).****
Full, which offers 35,000 programs available for your use****.**** Naturally this will take more space on your SD card**** at approximately 2,530 MB**** ****
If you do not have a monitor I would suggest using the Lite version.
Next is LibreELEC which is a Kodi Entertainment Center distribution. I have not used this so I can not comment on it. When clicking on the arrow it will show you 3 different options based on the model computer you have. You could install it and try it and if it is not of use to you, you can write another version to the SD-card.
****Next on the list is Ubuntu. ****This is another popular Linux Distribution. ****Here will be 8 options for you to try. They are:
Ubuntu 20.10 Desktop 32 bit, for models 2, 3, 4 & 400
Ubuntu 20.10 Server 32 bit, for models 2, 3, 4 & 400
Ubuntu 20.10 Desktop 64 bit, for models 4 & 400
Ubuntu 20.10 Server 64 bit, for models 4 & 400
Ubuntu 20.04.1 LTS**** Server ****32 bit, for models 2, 3 & 4****
Ubuntu 20.04.1 LTS Server 64 bit, for models 3 & 4****
Ubuntu Core 18 32 bit for models 2, 3 & 4
Ubuntu Core 18 64 bit for models 3 & 4
The 20 in the above names indicates the year of the edition and the 04 or the 10 indicates the year and month it was distributed. They are currently on a 6 month schedule as April and October.
When you select a version of software you want to use it will download it and write it to the device of your choice. This could be a micro-SD card or a USB memory stick. In chapter 4 I will show you how you can boot your Raspberry Pi computer from a USB memory stick.
When I first started using the Raspi Imager program I was having a lot of**** problems and**** errors so I gave up on it. In the mean time I did a****n**** upgrade to version 1.4 which is now what I am using. I just started using it again and found that it works as advertised. I recently used it to write Ubuntu to both a ****micro-SD card ****and**** a USB memory stick****. ****As Ubuntu 20.10 ha****d**** just come out I decided to try it in my new model 4 – 8gb Raspi. First ****I used the 32 bit version, which downloaded and installed to the micro-SD card but when I tried to install it in the model 4 computer it was not able to do so. I then used the 64 bit version and it installed to the micro-SD card AND to the computer. It booted up fine when I restarted the computer.****
The program I had been using prior to finding the Imager program is called balenaEtcher and is available for free download and installation on your main computer at https://www.balena.io/etcher/. It is available for all 3 operating systems. In order to use this program you will need to download the Raspberry Pi OS (raspios) or other operating system of your choice to your main computer from https://www.raspberrypi.org/downloads/raspberry-pi-os/. The program will ask where the file is located that you want to write, where you want to write it to and then click the button to proceed with the writing.
For additional software available**** to download and try on your new Raspberry Pi visit ****https://www.raspberrypi.org/downloads/****. I also have NOT tried any of these. ****I am sure that they will not harm your Raspberry Pi computer or they would not be made available. You can always wipe the SD-micro card and install something else on it.****
Now that you have the software written to the SD-micro card or SSD drive**** ****before removing it from the host computer you should open a file manager and find the boot directory. In there create an empty file named ssh**** by using the command **touch ssh**. Just that, nothing in the file and NO extension. This will allow you to use the Secure Shell ssh to access your new Raspberry Pi computer from another computer on your network.****
Setup with monitor. #
Configuring your computer. #
****If you do not live in the UK and you use special characters in your password, I.E. shift+1 or shift+3 I would suggest that you go to tab “Localisation” first and select “Set Keyboard”. I have an unbranded keyboard so I selected Dell 101-key PC, which seems to work OK. ****
You can now go to the “System” tab and make the required changes here. The most important one ****would be to “Change Password”. Make other changes as you require. On the “Display” tab I have disabled all of the options. On the “Interfaces” tab I have “SSH” Enabled. With this enabled you can access your Raspberry Pi computer from another computer. On the “Performance” tab I have GPU Memory set to 16.
Static Address #
In the upper right of the screen are 2 arrows, 1 pointing up and the other**** pointing down. When you right click on this icon a new dialog will open. Here you can set a static IP address. The reason you would want to do this is because every time the computer is rebooted the router can set a new IP address. In the Configure box will be options to set the interface or SSID. If interface is selected, the next box will have options for "eth0", which is the interface for Ethernet connection or "wlan0" which is for the WiFi connection.**** ****
The above paragraph only applies if NO WiFi has been set up. When I set up the WiFi that icon changed to looking like a fan. The rest of the paragraph applies as my network consists of 2.4G and 5.0G so I set it to 5.0G. You can now follow the rest of this chapter.
In the box for IPv4 I have entered "192.168.1.141/24" because my home private IP address starts with 192.168.1 so I set 141/24 for my model 4 Raspberry Pi computer. The newest computer I have I set the last to 142. For my model 2 I used 121 and for my 2 model 3s I used 131 and 132. You can use any number from 100 to 254**** in this last position.**** The numbers below 100 and 255 are reserved for the router to set DHCP addresses.****
In the box for Router I entered 192.168.1.1, which can be found on your router. It may be the same or it may be different where the next to last digit is a 0****. Then in the box for DNS Servers I entered 18.104.22.168 which is the **D**omain **N**ame **S**erver for Google.****
I have all of my Raspberry Pi computers connected to Ethernet not WiFi so I did not bother with the SSID or wlan0.****
Setup without monitor. #
Now I will show you how to set up your new Raspberry Pi without a monitor. This is known as being in Headless Mode. You will connect to the Raspberry Pi from another computer which I will call the host, which will be either a desktop or a laptop and will be connected via Secure Shell known as ssh.
Headless Mode #
This section will explain what is meant by Headless Mode.
It means the Raspi is **NOT **connected to a monitor, keyboard or mouse. So you ask "How do I interact with the computer?"
You connect to the Raspi computer from another computer. It could be a desktop or laptop which is running Linux, MAC or Windows.
- The way this is done is by using a program called Secure Shell or ssh. On Linux it is built in to the operating system.
Follow the sections from above to download and copy the operating system (OS) to a SD-micro card. I would recommend that the Lite version be downloaded as the other 2 will require a monitor. Your host will be your monitor but it will be in text mode on a terminal.
Finding your computer's IP address that has been set by the router. #
There are several ways to find the IP address of your Raspberry Pi computer.
- If you have access to to your router at 192.168.0.1, 192.168.1.1 or 192.168.1.254 from your web browser then check under the Status tab for Lan Status and then DHCP clients list. This should show you the address of your Raspberry Pi computer.**
- If you are running Linux on your host computer you can enter "sudo nmap -sn 192.168.X.0/24" and this will show all computers, cell phones and other devices connected to your network where the X is either a 0 or a 1.**
- If you are running one of the other operating systems the nmap program can be downloaded form: https://nmap.org/download.html. As I switched to Linux from Windows over 20 years ago and have never used a Mac I can't verify if or how this will work on those systems.
Now to gain access to your Raspberry Pi computer enter "ssh pi@IP-Address" found above. It will then ask for your id (Pi) and password** (****raspberry****)** and then bring you to the command line interface (CLI). I would suggest you now enter the following 2 commands:**
- sudo apt update This will check for updates of the software installed on the computer. If it says all packages are up to date then you are good to go to step 2. If it says "xx packages require updating** then enter this command: **"****sudo apt upgrade"**** It will then do it**s** thing and when it is done proceed to next.**
- sudo raspi-config ** This will open a screen as above so follow the instructions in "Configuring your computer" to proceed.** However the 2 above paragraphs about the different icons will NOT apply and you will need to follow the below instructions.**
Set a static IP address:** #
Why you would want to do this? As you are now accessing the computer via ssh you will want to have a static IP address that you can remember and the router will NOT keep changing it. The command to use if you are using the latest version (Buster) of the raspios operating system is: sudo nano /etc/dhcpcd.conf. nano is a text edit program that is included with most Linux distributions** including raspios**. The above command will open a file that contains: **
# Example static IP configuration:
#interface eth0 (This is the Ethernet connection)**
The numbers on lines 2 and 4 might be different than what I show as these numbers are what are used on my system and the line numbers will not be shown.**
The first thing you will need to do is remove the # from lines 1, 2, 4 and 5. Then on line 2 if your network has a 0 as the third position change the 1 to 0. Also on line 2 change the 131 to a number of your choice between 100 and 254. On line 4 change the 1 to 0 if required. **
Add a new user. #
**Why would you want to add a new user? This will provide more security to your system as "pi" is used as the default user with a password of "raspberry" and if someone gained access to your system(your children perhaps) they could do damage to it. If you do have children/spouse that will be using the system then create a new account for them. As I don't have children and my spouse is NOT interested in the computer I just change the new user to my first name.
To add a user just enter the command: sudo adduser new_name. It will then ask for a password and some other questions that can be left blank.
Now to access the system enter ssh newname@new ip address where it will ask for your password tat was set in the above step**.**
If you are the only user and/or don't want to enter a password every time this can be accomplished by:
- On your host computer enter ssh-keygen -t rsa****. For more information about this command visit **https://www.ssh.com/ssh/keygen/
- Now enter ssh-copy-id your-name@new IP address. Now when you log in it will not ask for a password.
** Now that you have a new user you can delete the "pi" user using the following command: sudo userdel -r pi. This will also delete home directory and the files for the pi user. This will further increase the security of your system if someone tries to hack it using pi as user.
This chapter has shown you how to perform an initial installation on your new Raspberry Pi computer whether you are using a monitor or not.