Chapter 5 - Configure the operating system¶
In this chapter, you will configure and secure the operating system on your Raspberry Pi. The configuration will be quite advanced but will ensure that the Raspberry Pi will be ready to run the BeeScreens applications in a production environment.
Steps¶
Warning
The following steps are executed on the Raspberry Pi. It is recommended to execute them trough SSH as you'll be able to copy/paste the commands from this tutorial.
Update the software¶
Run the following commands to update the installed softwares to their latest versions.
On the Raspberry Pi, execute the following command(s). | |
---|---|
Reboot the Raspberry Pi¶
At this point, reboot the Raspberry Pi.
On the Raspberry Pi, execute the following command(s). | |
---|---|
Access it again after the reboot.
Set up locales¶
The US English locale is quite the standard in the IT world. You'll set it up on your Raspberry Pi to avoid any issues. You might see some warnings in the following commands but you can ignore them.
Run the following commands to set up locales.
On the Raspberry Pi, execute the following command(s). | |
---|---|
Reload the locales configuration.
On the Raspberry Pi, execute the following command(s). | |
---|---|
Set up keyboard layout¶
By default, the Raspberry Pi OS is configured to use the UK English keyboard layout. If you want to use a different keyboard layout, you will need to change the configuration.
Run the following commands to set up the keyboard layout.
On the Raspberry Pi, execute the following command(s). | |
---|---|
On the Raspberry Pi, execute the following command(s). | |
---|---|
Replace the <layout>
and <variant>
placeholders with the layout and variant that you want to use.
On the Raspberry Pi, execute the following command(s). | |
---|---|
Reload the keyboard configuration.
On the Raspberry Pi, execute the following command(s). | |
---|---|
Set up the hostname¶
The hostname is the name of your Raspberry Pi. It is used to identify the device on the network.
Run the following commands to set up the hostname. Replace the <hostname>
placeholder with the hostname that you want to use.
On the Raspberry Pi, execute the following command(s). | |
---|---|
Set up timezone¶
The timezone is used to display the correct time on the Raspberry Pi. You will set it up to the timezone of your location.
Run the following commands to set up the timezone.
Reload the timezone configuration.
On the Raspberry Pi, execute the following command(s). | |
---|---|
Configure the firewall¶
Configure the firewall to only allow SSH connections from the outside.
On the Raspberry Pi, execute the following command(s). | |
---|---|
Extend the life of the microSD card¶
Run the following commands to tweak and improve the microSD performance:
Set config.txt
boot configuration file¶
Run the following commands to set specific configuration through the config.txt
boot configuration file.
Disable passwordless sudo
¶
By default, any commands using sudo
do not ask for the user's password to be executed. Run the following commands to change this behavior:
Optional: Secure SSH connections¶
A good practice is to secure the SSH connections with SSH key pairs. You won't be able to connect to the Raspberry Pi with a password anymore but you will be able to connect with a SSH keypair that is more secure against brute force attacks.
Create a SSH key pair on your computer with the How to use OpenSSH - Create a SSH keypair guide.
Transfer the SSH public key from your computer to the Raspberry Pi with the How to use OpenSSH - Transfer the public SSH key to a remote host guide.
Update the SSH configuration to only allow connection with public/private key pairs.
On the Raspberry Pi, execute the following command(s). | |
---|---|
Reload the SSH service.
On the Raspberry Pi, execute the following command(s). | |
---|---|
Reboot the Raspberry Pi¶
At this point, reboot the Raspberry Pi.
On the Raspberry Pi, execute the following command(s). | |
---|---|
Check the results¶
Verify everything is working as expected by accessing it again after the reboot.
Summary¶
Congrats! You now have an updated and secure Raspberry Pi.