7  Installing and updating software (system and apps)

Keeping the system updated is an important step in any server maintenance, not only Linux. An up-to-date system removes known security risks and provides new versions of the installed software.

Important

Maintaning the system updated is not failproof. A system can be compromised in many ways, some avoidable, others out of our hands. But there is some things we can do to minimize the impact of any security breach:

  1. Always maintain a backup of the necessary data outside the server
  2. Rotate credentials (passwords and keys) periodically
  3. Delete old users

7.1 Software repositories

One difference between a Linux system and a Windows system is that in Linux, every distribution (linux flavours) have its own curated repository from which you can install software. This repository is officially maintained by the distribution and is the recommended place from which install any tool you need. Only in the case that the software you want is not in the official repositories that we will need to install it manually, generallyu foloowing the instructions on the software web page.

7.2 Updating the system

In Ubuntu (the linux distribution the server in this course uses), the tool to install and update the system is apt. As we’ve seen before, we need to have administrative privileges for being able to use it.

To check if there is updates available we use apt update, to install any available update, we use apt upgrade.

victor@aula:~$ sudo apt update
[sudo] password for victor: 
victor@aula:~$ sudo apt upgrade

This will set the system up to the last versions of all installed software.

Tip

In other distributions the command is different from apt:

  • In ArchLinux is pacman
  • In Fedora or RHEL is dfn

7.3 Installing new software

Installing software present in the distribution repositories is straight forward. We use the apt command with the install options. For example, if we want to install R, we can do:

victor@aula:~$ sudo apt install r-base
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  bpfcc-tools bpftrace ieee-data libbpfcc libclang-cpp18 libclang1-18 libllvm18 python3-bpfcc python3-netaddr
  ubuntu-kernel-accessories
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  binutils binutils-common binutils-x86-64-linux-gnu build-essential bzip2 bzip2-doc cpp cpp-13
  cpp-13-x86-64-linux-gnu cpp-x86-64-linux-gnu dpkg-dev fakeroot fontconfig fontconfig-config fonts-dejavu-core
  fonts-dejavu-mono g++ g++-13 g++-13-x86-64-linux-gnu g++-x86-64-linux-gnu gcc gcc-13 gcc-13-base
  gcc-13-x86-64-linux-gnu gcc-x86-64-linux-gnu gfortran gfortran-13 gfortran-13-x86-64-linux-gnu
  gfortran-x86-64-linux-gnu icu-devtools libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl
  libasan8 libatomic1 libauthen-sasl-perl libbinutils libblas-dev libblas3 libbz2-dev libcairo2 libcc1-0
  libclone-perl libctf-nobfd0 libctf0 libdata-dump-perl libdatrie1 libdeflate0 libdpkg-perl libdrm-amdgpu1
  libdrm-intel1 libegl-mesa0 libegl1 libencode-locale-perl libfakeroot libfile-basedir-perl
  libfile-desktopentry-perl libfile-fcntllock-perl libfile-listing-perl libfile-mimeinfo-perl libfont-afm-perl
  libfontconfig1 libgbm1 libgcc-13-dev libgfortran-13-dev libgfortran5 libgl1 libgl1-mesa-dri libgles2 libglvnd0
  libglx-mesa0 libglx0 libgomp1 libgprofng0 libgraphite2-3 libharfbuzz0b libhtml-form-perl libhtml-format-perl
  libhtml-parser-perl libhtml-tagset-perl libhtml-tree-perl libhttp-cookies-perl libhttp-daemon-perl
  libhttp-date-perl libhttp-message-perl libhttp-negotiate-perl libhwasan0 libice6 libicu-dev libio-html-perl
  libio-socket-ssl-perl libio-stringy-perl libipc-system-simple-perl libisl23 libitm1 libjbig0 libjpeg-dev
  libjpeg-turbo8 libjpeg-turbo8-dev libjpeg8 libjpeg8-dev liblapack-dev liblapack3 liblerc4 libllvm20 liblsan0
  liblwp-mediatypes-perl liblwp-protocol-https-perl liblzma-dev libmailtools-perl libmpc3 libncurses-dev
  libnet-dbus-perl libnet-http-perl libnet-smtp-ssl-perl libnet-ssleay-perl libpango-1.0-0 libpangocairo-1.0-0
  libpangoft2-1.0-0 libpaper-utils libpaper1 libpciaccess0 libpcre2-16-0 libpcre2-32-0 libpcre2-dev
  libpcre2-posix3 libpixman-1-0 libpkgconf3 libpng-dev libpng-tools libquadmath0 libreadline-dev libsframe1
  libsharpyuv0 libsm6 libstdc++-13-dev libtcl8.6 libthai-data libthai0 libtie-ixhash-perl libtiff6
  libtimedate-perl libtk8.6 libtry-tiny-perl libtsan2 libubsan1 liburi-perl libvulkan1 libwayland-client0 libwebp7
  libwww-perl libwww-robotrules-perl libx11-6 libx11-data libx11-protocol-perl libx11-xcb1 libxau6 libxaw7
  libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb-sync1
  libxcb-xfixes0 libxcb1 libxcomposite1 libxcursor1 libxdmcp6 libxext6 libxfixes3 libxft2 libxi6 libxinerama1
  libxkbfile1 libxml-parser-perl libxml-twig-perl libxml-xpathengine-perl libxmu6 libxmuu1 libxpm4 libxrandr2
  libxrender1 libxshmfence1 libxss1 libxt6t64 libxtst6 libxv1 libxxf86dga1 libxxf86vm1 lto-disabled-list make
  mesa-libgallium mesa-vulkan-drivers perl-openssl-defaults pkg-config pkgconf pkgconf-bin r-base-core r-base-dev
  r-base-html r-cran-boot r-cran-class r-cran-cluster r-cran-codetools r-cran-foreign r-cran-kernsmooth
  r-cran-lattice r-cran-mass r-cran-matrix r-cran-mgcv r-cran-nlme r-cran-nnet r-cran-rpart r-cran-spatial
  r-cran-survival r-doc-html r-recommended unzip x11-common x11-utils x11-xserver-utils xauth xdg-utils zip
  zlib1g-dev zutty
Suggested packages:
  binutils-doc gprofng-gui cpp-doc gcc-13-locales cpp-13-doc debian-keyring g++-multilib g++-13-multilib
  gcc-13-doc gcc-multilib autoconf automake libtool flex bison gdb gcc-doc gcc-13-multilib gdb-x86-64-linux-gnu
  gfortran-multilib gfortran-doc gfortran-13-multilib gfortran-13-doc libcoarrays-dev libdigest-hmac-perl
  libgssapi-perl liblapack-doc bzr libio-compress-brotli-perl icu-doc libcrypt-ssleay-perl liblzma-doc ncurses-doc
  readline-doc libstdc++-13-doc tcl8.6 tk8.6 libsub-name-perl libbusiness-isbn-perl libregexp-ipv6-perl
  libauthen-ntlm-perl libunicode-map8-perl libunicode-string-perl xml-twig-tools make-doc debhelper elpa-ess
  r-doc-info | r-doc-pdf r-mathlib texlive-base texlive-latex-base texlive-plain-generic texlive-fonts-recommended
  texlive-fonts-extra texlive-extra-utils texlive-latex-recommended texlive-latex-extra texinfo mozilla
  | www-browser mesa-utils nickle cairo-5c xorg-docs-core
Recommended packages:
  luit
The following NEW packages will be installed:
  binutils binutils-common binutils-x86-64-linux-gnu build-essential bzip2 bzip2-doc cpp cpp-13
  cpp-13-x86-64-linux-gnu cpp-x86-64-linux-gnu dpkg-dev fakeroot fontconfig fontconfig-config fonts-dejavu-core
  fonts-dejavu-mono g++ g++-13 g++-13-x86-64-linux-gnu g++-x86-64-linux-gnu gcc gcc-13 gcc-13-base
  gcc-13-x86-64-linux-gnu gcc-x86-64-linux-gnu gfortran gfortran-13 gfortran-13-x86-64-linux-gnu
  gfortran-x86-64-linux-gnu icu-devtools libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl
  libasan8 libatomic1 libauthen-sasl-perl libbinutils libblas-dev libblas3 libbz2-dev libcairo2 libcc1-0
  libclone-perl libctf-nobfd0 libctf0 libdata-dump-perl libdatrie1 libdeflate0 libdpkg-perl libdrm-amdgpu1
  libdrm-intel1 libegl-mesa0 libegl1 libencode-locale-perl libfakeroot libfile-basedir-perl
  libfile-desktopentry-perl libfile-fcntllock-perl libfile-listing-perl libfile-mimeinfo-perl libfont-afm-perl
  libfontconfig1 libgbm1 libgcc-13-dev libgfortran-13-dev libgfortran5 libgl1 libgl1-mesa-dri libgles2 libglvnd0
  libglx-mesa0 libglx0 libgomp1 libgprofng0 libgraphite2-3 libharfbuzz0b libhtml-form-perl libhtml-format-perl
  libhtml-parser-perl libhtml-tagset-perl libhtml-tree-perl libhttp-cookies-perl libhttp-daemon-perl
  libhttp-date-perl libhttp-message-perl libhttp-negotiate-perl libhwasan0 libice6 libicu-dev libio-html-perl
  libio-socket-ssl-perl libio-stringy-perl libipc-system-simple-perl libisl23 libitm1 libjbig0 libjpeg-dev
  libjpeg-turbo8 libjpeg-turbo8-dev libjpeg8 libjpeg8-dev liblapack-dev liblapack3 liblerc4 libllvm20 liblsan0
  liblwp-mediatypes-perl liblwp-protocol-https-perl liblzma-dev libmailtools-perl libmpc3 libncurses-dev
  libnet-dbus-perl libnet-http-perl libnet-smtp-ssl-perl libnet-ssleay-perl libpango-1.0-0 libpangocairo-1.0-0
  libpangoft2-1.0-0 libpaper-utils libpaper1 libpciaccess0 libpcre2-16-0 libpcre2-32-0 libpcre2-dev
  libpcre2-posix3 libpixman-1-0 libpkgconf3 libpng-dev libpng-tools libquadmath0 libreadline-dev libsframe1
  libsharpyuv0 libsm6 libstdc++-13-dev libtcl8.6 libthai-data libthai0 libtie-ixhash-perl libtiff6
  libtimedate-perl libtk8.6 libtry-tiny-perl libtsan2 libubsan1 liburi-perl libvulkan1 libwayland-client0 libwebp7
  libwww-perl libwww-robotrules-perl libx11-6 libx11-data libx11-protocol-perl libx11-xcb1 libxau6 libxaw7
  libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb-sync1
  libxcb-xfixes0 libxcb1 libxcomposite1 libxcursor1 libxdmcp6 libxext6 libxfixes3 libxft2 libxi6 libxinerama1
  libxkbfile1 libxml-parser-perl libxml-twig-perl libxml-xpathengine-perl libxmu6 libxmuu1 libxpm4 libxrandr2
  libxrender1 libxshmfence1 libxss1 libxt6t64 libxtst6 libxv1 libxxf86dga1 libxxf86vm1 lto-disabled-list make
  mesa-libgallium mesa-vulkan-drivers perl-openssl-defaults pkg-config pkgconf pkgconf-bin r-base r-base-core
  r-base-dev r-base-html r-cran-boot r-cran-class r-cran-cluster r-cran-codetools r-cran-foreign r-cran-kernsmooth
  r-cran-lattice r-cran-mass r-cran-matrix r-cran-mgcv r-cran-nlme r-cran-nnet r-cran-rpart r-cran-spatial
  r-cran-survival r-doc-html r-recommended unzip x11-common x11-utils x11-xserver-utils xauth xdg-utils zip
  zlib1g-dev zutty
0 upgraded, 230 newly installed, 0 to remove and 0 not upgraded.
Need to get 224 MB of archives.
After this operation, 770 MB of additional disk space will be used.
Do you want to continue? [Y/n] 

Installing software not present in the repositories can be a little more challenging, but usually the software web page can help us. For example, if we want to install RStudio Server in our remote server, we can check the official instructions for Ubuntu at https://docs.posit.co/ide/server-pro/admin/getting_started/installation/install-rstudio-server.html