Intro to Raspberry Pi OS

Jump to Table of Contents

A Raspberry Pi Adventure

Photo with added visual effects of a Raspberry Pi with jumper wires connection the Pi GPIO header to the JTAG port on a Netgear router

A Raspberry Pi connected to a Netgear router’s JTAG port

This is based on, but not a conversion of, a PowerPoint presentation I created for fellow Makers at the MakerPlace at the Midland Public Library in Midland, Ontario

About the Raspberry Pi

  • A full-blown, credit-card sized computer.
  • Based on a different processor (brains) than a typical laptop or desktop.
  • Is performant enough to be useful but less than a typical desktop, laptop, or modern mobile device (cell phones, tablets, etc).
  • Designed to be easy to use with electronics projects.
  • Created by a U.K. non-profit.
  • Intended to an inexpensive way to learn computing and electronics and especially the combination of those (including robotics).
  • Very popular amongst hobbyists due low price while still being fully functional (even ignoring the appeal of easy electronics integration).
  • Not designed for industrial or mission-critical applications.
A Raspberry Pi in official case with cover removed and being held in a human hand

A Raspberry Pi in official case with cover removed and being held in a human hand

About Raspberry Pi OS

Based on Debian GNU/Linux

  • Is mostly Raspbian: Raspbian is a free operating system based on Debian optimized for the Raspberry Pi hardware. It also, comes with over 35,000 packages, (pre-compiled, easy to install, software)
  • The initial build of over 35,000 Raspbian packages was completed in June of 2012. However, development of Raspbian continues.
  • In additional to Raspbian, Pi OS has a small number of unique meta and ‘utility’ packages, as well as a few specially licensed versions of some commercial software. For details see: https://github.com/RPi-Distro/pi-gen
  • New (beta) 64-bit version is not based on Raspbian according to Wikipedia (https://en.wikipedia.org/wiki/Raspberry_Pi_OS).

Pi CLI (Command Line)

  • We’re going to concentrate on the command line because there a number of operations in Raspberry Pi OS (like most version of Linux) that are faster and easier using a command line, or are only possible use the CLI (command line interface).
  • For a different take you can look at https://magpi.raspberrypi.org/articles/terminal-help, or do a web search – there are many articles on using the command line on the Pi. Of course like most popular topics on the web the hard part is finding a sufficiently relevant, well written, and accurate guide.
  • This presentation isn’t going to try to be a full blown introduction to the Linux command line, but will instead focus on some specific items of particular interest.
  • It is interesting to know that the command line takes less resources (CPU, RAM, and storage) than the desktop.

TUI Package Installation

  • A TUI is a term for an command line application that uses the entire screen, and acts similarly to a GUI but using only text. TUI stands for ‘Text User Interface’ in contrast to a ‘Graphical User Interface’ that you would use on a desktop.
  • In Raspbian and Raspberry Pi OS (32-bit – not sure about the 64-bit version) you can install package called ‘aptitude’ that provides a TUI for package management (installation, removal, etc.)
  • Aptitude installation is slower than plain apt, but has the advantage of a powerful search functionality, as well as being an interactive TUI instead of being a command line. In addition, like apt it is faster than using a GUI, and can be used without a desktop.
  • Once you apt install aptitude you can simply execute the aptitude command on the command line.

Remote Operation of the Raspberry Pi

  • There are two major types of remote operation of the Raspberry Pi, which are:
    • Command Line
    • Desktop
  • Note however, a command line variant can also execute graphical applications, under certain conditions.
  • Command Line remoting consists of two main types:
    • Serial (using one or more of the UARTs on Pi header and physical connection to the controlling host).
    • SSH (Secure SHell), usually OpenSSH but Dropbear is also available.
  • Desktop remoting has a number of flavours but we will only discuss VNC (Virtual Network Computing) protocol remote desktops for this presentation.

VNC For Remote Pi Desktop

  • We’ll start with VNC remote operation of the Pi because information on this type of remoting has been specifically requested.
  • Depending on your situation / requirements there are two basic options with current Raspberry Pi OS:
  • Use the RealVNC server shipped with Raspberry Pi OS and use a RealVNC app the ‘client’ device to control the Pi ‘host’.
  • Instead of the RealVNC server use an open source VNC server and use compatible VNC ‘client’ on the device controlling the Pi ‘host’.
  • The obvious advantage of the RealVNC option is that there is less to do to get it working.
  • There are, however, some issues:
    • There are licensing considerations depending on what type of organization you are (if not an individual for personal use) and how many devices with which you wish to use RealVNC.
    • Much of RealVNC’s functionality require signing up for a RealVNC cloud account, and possibly incurring fees (depending on uses)
  • Because it is the quickest and easiest option for personal use we will use the RealVNC option.

RealVNC For Remote Pi Desktop

  • For non-commercial use only
  • Enable RealVNC Server by:
    1. Navigating to Pi (the Raspberry Icon in the top left corner of the Pi’s screen) | Preferences | Raspberry Pi Configuration and clicking
    2. Clicking on the ‘Interfaces’ tab
    3. Selecting ‘Enable’ beside ‘VNC’
    4. Clicking OK
Top screenshot is the Pi Preferences menu; Bottom screenshot depicts the Pi Preferences Interfaces tab

Author: Jonathon Killing

  • After a little time you will see a Vnc icon beside the network icon on the top right hand side of the screen.
  • Clicking on the Vnc icon will show a window like the one on the next slide.

Pi RealVNC Server Info Screen

  • Make a note of the ‘dotted quad address’ (four numbers, each separated by a dot (.)). You will need this unless you sign up for a vncconnect cloud account and sign in on both the Pi and the connecting computer.
  • Note also the signature and ‘catchphrase’. When you connect from the remote computer, this will help verify you’ve connected to your Pi and not some other Pi (which matters more if you are on a shared network which may have other VNC reachable hosts).
Screenshot of RealVNC (VNCConnect) server info screen including dotted quad (ipv4) address

Using VNC Viewer to Connect to A Pi

Top screenshot is the Pi Preferences menu; Bottom screenshot depicts the Pi Preferences Interfaces tab

Enter your username and password for your Pi, and click ‘OK’

  • On the ‘client’ (connecting) computer you need to install https://www.realvnc.com/en/connect/download/viewer/
  • You then launch ‘vnc viewer’ and enter the ‘dotted quad address’ in the search bar, or, on many networks you can enter the ‘hostname’ of your raspberry pi (if you haven’t changed it, it is ‘raspberrypi’ – obviously there are multiple pi’s on the network you need to change the hostname for connecting by name to work).
  • A confirmation dialogue will pop up if this is the first time connecting, and if you accept, you will see a screen like the one on the right side of this slide.

VNC Session to Pi Using VNC

Screenshot of vnc viewer connected to a Pi desktop

SSH for Command Line Access to A Pi

  • While VNC access is an easy way for beginners to access the Raspberry Pi remotely, the most efficient way to remotely access a Pi is using SSH to use the command line, including launching specific GUI applications (provided one has the necessary configuration on the connecting device (namely an X server).
  • For Windows versions prior to Windows 10 the best way to connect to a Pi for command line use is probably using an application called PuTTY, however this presentation won’t deal with pre-Windows 10 usage as they are all EOL. With an up to date Windows 10 there is now the option to use an OpenSSH client in a PowerShell or Command Prompt sessions.
  • In addition, the Windows Store now has ‘Windows Terminal’ which is a Microsoft-supported open source project that provides a reasonably good, if basic, terminal for PowerShell and Command Prompt (and Windows Subsystem for Linux, but we aren’t covering that here, either). It mean that you can use OpenSSH on Windows to access remote Linux command shells (e.g. bash) and not have your terminal screen become unreadable due to terminal issues.

Using SSH To Connect to the Pi

When using SSH, public/private key authentication is recommended using as setup such as outlined below or in a blog post I wrote about using Pi OS for a server

  1. Open a ‘Windows Terminal’
  2. Assuming you used the command above to generate the SSH key and that your Pi is using the default hostname (otherwise substitute your hostname or IP address): issue the command: scp .ssh\id_rsa.pub pi@raspberrypi:
  3. Then SSH into the Pi (note that if you don’t wish to use public/private key authentication this step is all that is required) using a command such as: ssh pi@raspberrypi
  4. You’ll be prompted to enter your password (which you set during Pi setup): do so.
  5. You should now be at the pi command prompt and see something like: pi@raspberrypi:~$
  6. Execute: mkdir .ssh; chmod 700 .; chmod 700 .ssh; mv id_rsa.pub .ssh/authorized_keys; chmod 600 .ssh/authorized_keys; exit

Connecting to Raspberry Pi with a Keypair

  • If you’ve followed the instructions on the previous slide you can now SSH into your Pi using the keypair you generated with ssh-keygen. You will be prompted for the keypair’s (really the private key’s) password to login instead of the password for your user.
  • To avoid having to enter a password every time you want to SSH into the Pi, you can use the OpenSSH agent to remember the passphrase – this is relatively safe because it still requires the private key and does not transmit the password to the Pi, but using public/private key encryption to authenticate to the Pi.
  • You may also be interested in Microsoft’s Managing OpenSSH Keys Page.
  • With the install of the OpenSSH client a service known as ‘ssh-agent’ should have been installed.
  • To enable have it start on boot and start it now, launch an Administrative PowerShell, and enter
  • Set-Service –Name ‘ssh-agent’ –StartupType ‘Automatic’
  • Start-Service ‘ssh-agent’
  • Now (and once each time you boot), in a Windows Terminal use the command:ssh-add, and then enter key password.

Using SSH to Connect to the Pi, Part III

  • Now you can connect to your Raspberry Pi command line using SSH (ssh pi@raspberrypi).
  • If you also install Xming, VcXsrv, or a more up-to-date fork of VcXsrv you can use ssh –CY pi@raspberrypi “name-of-an-X11-program” (X11 is the protocol used for most GUI applications on Linux) to launch GUI applications.
  • An SSH session could look similar to the screenshot shown on the right.
Screenshot of a Pi OS SSH login screen

Sharing Files from a Pi to Windows

There are a number of guides to installing and configuring Samba that can be found be a web search, but the actual connection from Windows is under-documented, so this presentation will focus on the later and only briefly describe the former.

  1. Install and Configure Samba on the Pi
    1. On the Pi execute sudo apt install samba

    2. Create the folder you want to share (e.g. /srv/shared-folder)

    3. On the Pi execute sudoedit /etc/samba/smb.conf

    4. Create a ‘share’ for the shared folder by adding:

      [shared_folder]
      read only = no
      browseable = yes
      guest ok = no
      path = /srv/shared-folder
      
    5. Restart Samba by executing the command systemctl restart smbd nmbd

    6. For each user who should have access to the share execute: sudo smbpasswd –a username

    7. Connect from Windows (see next slide).

Connecting to Samba from Windows

Make sure Windows 10 File and Printer Sharing is Enabled

Network and Sharing Centre with advanced options circled in red
Windows 10 Control Panel with Network and Sharing Centre circled in red
Advanced Network and Sharing with File and Printer Sharing and Network Discovery enabled

Populate Windows Credentials for the Samba Server

Screenshot of Windows Credential Manager with a Samba credential populated
  • Windows can be finicky about connecting to a Samba share, and can end up in a state where one needs to logout, or even restart the Windows computer for the connection to be successful.
  • A method I have found that seems to work well is to use Windows ‘Credential Manager’ before making any attempt to find or use the Pi or the Samba share.
  • Credential Manager is found in the Control Panel in Windows and is shown on the right in the ‘Windows Credentials’ section.

Using Windows Credential Manager

Screenshot of the credential entry dialogue for Windows Credential Manager
  • In ‘Credential Manager’ select ‘Add a Windows Credential’
  • You will see a screen such as the one on the right.
  • In ‘Internet or network address’ enter the hostname of your Pi (e.g. raspberrypi) or it’s IP address (a hostname is more likely to work well and not change).
  • Then enter the username and password you configured using smbpasswd –a
  • Click OK

Use File Explorer to Map a Network Drive

Screenshot of the dialogue for mapping a network drive
  • Open ‘File Explorer’ (remember we’re assuming Windows 10; earlier versions of Windows may be slightly different). Select the ‘Computer Tab’ and then ‘Map Network Drive’
  • Choose the letter to assign to the network drive
  • In the folder field enter the UNC of the network share. That will look like: \\hostname\shared-folder
  • Make ‘Connect using different credentials’ is unchecked (as in the screenshot to the right) as you’ve already entered your credentials in Credential Manager.
  • Click Finish.

Windows Connected to a Samba Share

A screenshot of Windows connected to a Samba Share

Additional Reading and Videos

Table of Contents

  1. A Raspberry Pi Adventure
    1. About the Raspberry Pi
    2. About Raspberry Pi OS
      1. Based on Debian GNU/Linux
  2. Pi CLI (Command Line)
    1. TUI Package Installation
  3. Remote Operation of the Raspberry Pi
    1. VNC For Remote Pi Desktop
      1. RealVNC For Remote Pi Desktop
      2. Pi RealVNC Server Info Screen
      3. Using VNC Viewer to Connect to A Pi
      4. VNC Session to Pi Using VNC
  4. SSH for Command Line Access to A Pi
    1. Using SSH To Connect to the Pi
      1. Recommended Preparation
      2. Connecting to Raspberry Pi with a Keypair
      3. Using SSH to Connect to the Pi, Part III
  5. Sharing Files from a Pi to Windows
  6. Connecting to Samba from Windows
    1. Make sure Windows 10 File and Printer Sharing is Enabled
    2. Populate Windows Credentials for the Samba Server
    3. Using Windows Credential Manager
    4. Use File Explorer to Map a Network Drive
    5. Windows Connected to a Samba Share
  7. Additional Reading and Videos
  8. Table of Contents