Skip to content
This repository has been archived by the owner on Jul 8, 2020. It is now read-only.

Updating the Raspberry Pi software and installing additional packages

Brian Innes edited this page Sep 21, 2017 · 7 revisions

Once the Pi has been setup and is on the network you need to ensure all the pre-installed software is up to date. There are also some additional packages that need to be installed.

Updating the installed software

To update the installed software you need command line access to the Raspberry Pi. This can be using a terminal on the desktop or a remote ssh session. You then need to enter the following commands:

sudo apt-get update
sudo apt-get upgrade -y
update-nodejs-and-nodered
sudo systemctl enable nodered.service
sudo reboot

Understanding the commands

Linux is a multi-user operating system, where each user has a set of permissions controlling what they can do on the system. Standard user accounts, such as the pi account which is setup as the default user on Raspbian, does not have system administrator permissions, so there are some tasks that the user pi is not able to do. On linux the sudo command provides a way for a standard user to temporarily get system administrator permissions to run a command. When sudo is used, the command following sudo is run with system administrator privileges. Access to sudo is restricted, but a default install of Raspbian allows the pi user to use sudo.
You should be careful using sudo and only use it when necessary, or you may end up creating situations where standard users may no longer be able to do activities they should normally be able to do.

On many Linux systems there is a package manager that looks after software, including the core operating system and a large collection of additional packages. On Raspbian there is a package manager, which is access using the apt-get command. There is a local cache of all available software packages in the catalog, and the apt-get update command refreshes the local cache by querying the servers hosting the software packages.

The apt-get updrade command compares all the installed packages with the local cache of available packages and will download and update all packages, where a newer version exists. The -y flag tells the command to proceed with the update automatically, otherwise the command will output a list of changes and ask you to confirm you want to make the changes

Sometimes the version of software available in the package manager catalog may not be the latest version available, so you may want to remove the packed managed by the package manager and install the latest versions. Note, that when you install packages manually that package manager will no longer be managing the package and updating it, you will need to do this.

The version of Node.js runtime managed by the Raspbian package is quite old and TobyJnr needs a newer version, so the script update-nodejs-and-nodered will remove the standard package version of Node.js and download and install the latest version. It will also ensure the latest available version of Node-RED is installed on your raspberry Pi. You can run this command at any time to ensure you have the very latest version of Node-RED.

On Linux it is possible to get certain applications, or services, to automatically start when the system starts. The sudo systemctl enable nodered.service command is configuring the system to run Node-RED when the system starts. Other commands that you may find useful:

  • sudo systemctl disable nodered.service - Stop Node-RED starting at boot (does not stop Node-RED if already running, but at next boot it will not be started automatically)
  • sudo systemctl start nodered.service - Start Node-RED if not already running
  • sudo systemctl stop nodered.service - Stop Node-RED if running
  • sudo systemctl restart nodered.service - Stop then start Node-RED

The reboot command will restart the raspberry pi.

Now you are ready to Setup Node-RED