Basic linux admin
& Docker

Lecture 26

Dr. Colin Rundel

Duke Virtual Computing Manager



Getting Started

Connecting

rundel@tbBook [~]$ ssh cr173@vcm-26406.vm.duke.edu
The authenticity of host 'vcm-26406.vm.duke.edu (67.159.94.29)' can't be established.
ED25519 key fingerprint is SHA256:7Ukmob4JBk3K3Vd2PnlZjy8vgZFN90lmUvs5961kePA.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'vcm-26406.vm.duke.edu' (ED25519) to the list of known hosts.

cr173@vcm-26406.vm.duke.edu's password:
Welcome to Ubuntu 20.04.6 LTS (GNU/Linux 5.4.0-146-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

 * Introducing Expanded Security Maintenance for Applications.
   Receive updates to over 25,000 software packages with your
   Ubuntu Pro subscription. Free for personal use.

     https://ubuntu.com/pro
New release '22.04.2 LTS' available.
Run 'do-release-upgrade' to upgrade to it.

cr173@vcm-26406:~$

Determining Distribution

This does not work 100% of the time but is generally pretty reliable,

Ubuntu / Debian

cr173@vcm-26406:~$ cat /etc/*-release

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.1 LTS"
NAME="Ubuntu"
VERSION="18.04.1 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.1 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

Fedora / RHEL

cr173@algebra2 [~]$ cat /etc/os-release

NAME="Fedora Linux"
VERSION="35 (MATE-Compiz)"
ID=fedora
VERSION_ID=35
VERSION_CODENAME=""
PLATFORM_ID="platform:f35"
PRETTY_NAME="Fedora Linux 35 (MATE-Compiz)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:35"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f35/system-administrators-guide/"
SUPPORT_URL="https://ask.fedoraproject.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=35
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=35
PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
VARIANT="MATE-Compiz"
VARIANT_ID=matecompiz

System Details

Filesystem Hierarchy Standard

Ubuntu

cr173@vcm-26406:~$ tree -d -L 1 /

/
├── bin
├── boot
├── dev
├── etc
├── home
├── lib
├── lib64
├── media
├── mnt
├── opt
├── proc
├── root
├── run
├── sbin
├── srv
├── sys
├── tmp
├── usr
└── var

Fedora

cr173@algebra2 [~]$ tree -d -L 1 /
/
├── bibtex
├── bin -> usr/bin
├── boot
├── custom-bib
├── data
├── dev
├── doc
├── dvips
├── etc
├── fonts
├── geometry
├── home
├── lib -> usr/lib
├── lib64 -> usr/lib64
├── lost+found
├── media
├── mnt
├── opt
├── pdftex
├── proc
├── proj
├── root
├── run
├── sbin -> usr/sbin
├── source
├── srv
├── sys
├── tex
├── tmp
├── usr
├── var
├── web
└── xdvi

Secondary, Tertiarty, etc.

Secondary

cr173@algebra2 [~]$ tree -d -L 1 /usr
/usr
├── bin
├── etc
├── games
├── include
├── lib
├── lib64
├── libexec
├── local
├── sbin
├── share
├── src
└── tmp -> ../var/tmp

Tertiarty

cr173@algebra2 [~]$ tree -d -L 1 /usr/local
/usr/local
├── bin
├── etc
├── games
├── include
├── lib
├── lib64
├── libexec
├── sbin
├── share
└── src

Secondary hierarchy for read-only user data; contains the majority of (multi-)user utilities and applications. Should be shareable and read-only
Tertiary hierarchy for local data, specific to this host.

From Wikipedia Filesystem Hierarchy Standard

Installing packages with apt (Ubuntu, Debian, etc.)

Update the package list

cr173@vcm-26406:~$ apt update

Reading package lists... Done
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)```

Update the package list

cr173@vcm-26406:~$ sudo apt update

Hit:1 http://archive.linux.duke.edu/ubuntu focal InRelease
Get:2 http://archive.linux.duke.edu/ubuntu focal-updates InRelease [114 kB]
Hit:3 https://falcon-dl.oit.duke.edu/ubuntu focal InRelease
Get:4 http://archive.linux.duke.edu/ubuntu focal-backports InRelease [108 kB]
Get:5 http://archive.linux.duke.edu/ubuntu focal-security InRelease [114 kB]
Get:6 http://archive.linux.duke.edu/ubuntu focal-updates/main amd64 Packages [1,711 kB]
Get:7 http://archive.linux.duke.edu/ubuntu focal-updates/main i386 Packages [628 kB]
Get:8 http://archive.linux.duke.edu/ubuntu focal-updates/main Translation-en [320 kB]
Get:9 http://archive.linux.duke.edu/ubuntu focal-updates/restricted amd64 Packages [917 kB]
Get:10 http://archive.linux.duke.edu/ubuntu focal-updates/restricted Translation-en [131 kB]
Get:11 http://archive.linux.duke.edu/ubuntu focal-updates/universe amd64 Packages [916 kB]
Get:12 http://archive.linux.duke.edu/ubuntu focal-updates/universe i386 Packages [676 kB]
Get:13 http://archive.linux.duke.edu/ubuntu focal-updates/universe Translation-en [204 kB]
Get:14 http://archive.linux.duke.edu/ubuntu focal-updates/universe amd64 c-n-f Metadata [20.4 kB]
Get:15 http://archive.linux.duke.edu/ubuntu focal-security/main i386 Packages [416 kB]
Get:16 http://archive.linux.duke.edu/ubuntu focal-security/main amd64 Packages [1,383 kB]
Get:17 http://archive.linux.duke.edu/ubuntu focal-security/main Translation-en [239 kB]
Get:18 http://archive.linux.duke.edu/ubuntu focal-security/restricted amd64 Packages [859 kB]
Get:19 http://archive.linux.duke.edu/ubuntu focal-security/restricted Translation-en [122 kB]
Get:20 http://archive.linux.duke.edu/ubuntu focal-security/universe i386 Packages [547 kB]
Get:21 http://archive.linux.duke.edu/ubuntu focal-security/universe amd64 Packages [696 kB]
Get:22 http://archive.linux.duke.edu/ubuntu focal-security/universe Translation-en [122 kB]
Get:23 http://archive.linux.duke.edu/ubuntu focal-security/universe amd64 c-n-f Metadata [14.1 kB]
Fetched 10.3 MB in 3s (4,100 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
1 package can be upgraded. Run 'apt list --upgradable' to see it.

Installing R

cr173@vcm-26406:~$ sudo apt install r-base
[sudo] password for cr173:

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  build-essential bzip2-doc cpp cpp-9 dpkg-dev fakeroot fontconfig fontconfig-config fonts-dejavu-core g++ g++-9 gcc gcc-9 gcc-9-base gfortran gfortran-9 icu-devtools
  libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan5 libatomic1 libauthen-sasl-perl libblas-dev libblas3 libbz2-dev libcairo2 libcc1-0
  libdata-dump-perl libdatrie1 libdpkg-perl libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libencode-locale-perl libfakeroot libfile-basedir-perl
  libfile-desktopentry-perl libfile-fcntllock-perl libfile-listing-perl libfile-mimeinfo-perl libfont-afm-perl libfontconfig1 libfontenc1 libgcc-9-dev libgfortran-9-dev
  libgfortran5 libgl1 libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0 libgomp1 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 libice6
  libicu-dev libio-html-perl libio-socket-ssl-perl libio-stringy-perl libipc-system-simple-perl libisl22 libitm1 libjbig0 libjpeg-dev libjpeg-turbo8 libjpeg-turbo8-dev libjpeg8
  libjpeg8-dev liblapack-dev liblapack3 libllvm12 liblsan0 liblwp-mediatypes-perl liblwp-protocol-https-perl liblzma-dev libmailtools-perl libmpc3 libmpfr6 libncurses-dev
  libncurses5-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 libpcre16-3 libpcre2-16-0 libpcre2-32-0 libpcre2-dev libpcre2-posix2 libpcre3-dev libpcre32-3 libpcrecpp0v5 libpixman-1-0 libpng-dev libpng-tools libquadmath0
  libreadline-dev libsensors-config libsensors5 libsm6 libstdc++-9-dev libtcl8.6 libthai-data libthai0 libtie-ixhash-perl libtiff5 libtimedate-perl libtk8.6 libtry-tiny-perl
  libtsan0 libubsan1 liburi-perl libvulkan1 libwayland-client0 libwebp6 libwww-perl libwww-robotrules-perl libx11-protocol-perl libx11-xcb1 libxaw7 libxcb-dri2-0 libxcb-dri3-0
  libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcomposite1 libxcursor1 libxfixes3 libxft2 libxi6
  libxinerama1 libxkbfile1 libxml-parser-perl libxml-twig-perl libxml-xpathengine-perl libxmu6 libxpm4 libxrandr2 libxrender1 libxshmfence1 libxss1 libxt6 libxtst6 libxv1
  libxxf86dga1 libxxf86vm1 make mesa-vulkan-drivers perl-openssl-defaults pkg-config 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 xdg-utils zip zlib1g-dev
Suggested packages:
  cpp-doc gcc-9-locales debian-keyring g++-multilib g++-9-multilib gcc-9-doc gcc-multilib autoconf automake libtool flex bison gdb gcc-doc gcc-9-multilib gfortran-multilib
  gfortran-doc gfortran-9-multilib gfortran-9-doc libcoarrays-dev libdigest-hmac-perl libgssapi-perl liblapack-doc bzr icu-doc libcrypt-ssleay-perl liblzma-doc ncurses-doc
  readline-doc lm-sensors libstdc++-9-doc tcl8.6 tk8.6 libauthen-ntlm-perl libunicode-map8-perl libunicode-string-perl xml-twig-tools make-doc 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
The following NEW packages will be installed:
  build-essential bzip2-doc cpp cpp-9 dpkg-dev fakeroot fontconfig fontconfig-config fonts-dejavu-core g++ g++-9 gcc gcc-9 gcc-9-base gfortran gfortran-9 icu-devtools
  libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan5 libatomic1 libauthen-sasl-perl libblas-dev libblas3 libbz2-dev libcairo2 libcc1-0
  libdata-dump-perl libdatrie1 libdpkg-perl libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libencode-locale-perl libfakeroot libfile-basedir-perl
  libfile-desktopentry-perl libfile-fcntllock-perl libfile-listing-perl libfile-mimeinfo-perl libfont-afm-perl libfontconfig1 libfontenc1 libgcc-9-dev libgfortran-9-dev
  libgfortran5 libgl1 libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0 libgomp1 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 libice6
  libicu-dev libio-html-perl libio-socket-ssl-perl libio-stringy-perl libipc-system-simple-perl libisl22 libitm1 libjbig0 libjpeg-dev libjpeg-turbo8 libjpeg-turbo8-dev libjpeg8
  libjpeg8-dev liblapack-dev liblapack3 libllvm12 liblsan0 liblwp-mediatypes-perl liblwp-protocol-https-perl liblzma-dev libmailtools-perl libmpc3 libmpfr6 libncurses-dev
  libncurses5-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 libpcre16-3 libpcre2-16-0 libpcre2-32-0 libpcre2-dev libpcre2-posix2 libpcre3-dev libpcre32-3 libpcrecpp0v5 libpixman-1-0 libpng-dev libpng-tools libquadmath0
  libreadline-dev libsensors-config libsensors5 libsm6 libstdc++-9-dev libtcl8.6 libthai-data libthai0 libtie-ixhash-perl libtiff5 libtimedate-perl libtk8.6 libtry-tiny-perl
  libtsan0 libubsan1 liburi-perl libvulkan1 libwayland-client0 libwebp6 libwww-perl libwww-robotrules-perl libx11-protocol-perl libx11-xcb1 libxaw7 libxcb-dri2-0 libxcb-dri3-0
  libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcomposite1 libxcursor1 libxfixes3 libxft2 libxi6
  libxinerama1 libxkbfile1 libxml-parser-perl libxml-twig-perl libxml-xpathengine-perl libxmu6 libxpm4 libxrandr2 libxrender1 libxshmfence1 libxss1 libxt6 libxtst6 libxv1
  libxxf86dga1 libxxf86vm1 make mesa-vulkan-drivers perl-openssl-defaults pkg-config 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 xdg-utils zip zlib1g-dev
0 upgraded, 202 newly installed, 0 to remove and 0 not upgraded.
Need to get 158 MB of archives.
After this operation, 914 MB of additional disk space will be used.
Do you want to continue? [Y/n]

Removing R

cr173@vcm-26406:~$ sudo apt remove r-base

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  fontconfig fontconfig-config fonts-dejavu-core gfortran gfortran-9 icu-devtools libblas-dev libblas3 libbz2-dev libcairo2 libdatrie1 libdrm-amdgpu1 libdrm-intel1
  libdrm-nouveau2 libdrm-radeon1 libfile-basedir-perl libfile-desktopentry-perl libfile-mimeinfo-perl libfontconfig1 libfontenc1 libgfortran-9-dev libgfortran5 libgl1
  libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0 libgraphite2-3 libharfbuzz0b libice6 libicu-dev libio-stringy-perl libipc-system-simple-perl libjbig0 libjpeg-dev
  libjpeg-turbo8 libjpeg-turbo8-dev libjpeg8 libjpeg8-dev liblapack-dev liblapack3 libllvm12 liblzma-dev libncurses-dev libncurses5-dev libnet-dbus-perl libpango-1.0-0
  libpangocairo-1.0-0 libpangoft2-1.0-0 libpaper-utils libpaper1 libpciaccess0 libpcre16-3 libpcre2-16-0 libpcre2-32-0 libpcre2-dev libpcre2-posix2 libpcre3-dev libpcre32-3
  libpcrecpp0v5 libpixman-1-0 libpng-dev libpng-tools libreadline-dev libsensors-config libsensors5 libsm6 libtcl8.6 libthai-data libthai0 libtie-ixhash-perl libtiff5 libtk8.6
  libvulkan1 libwayland-client0 libwebp6 libx11-protocol-perl libx11-xcb1 libxaw7 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-render0
  libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcomposite1 libxcursor1 libxfixes3 libxft2 libxi6 libxinerama1 libxkbfile1 libxml-parser-perl libxml-twig-perl
  libxml-xpathengine-perl libxmu6 libxpm4 libxrandr2 libxrender1 libxshmfence1 libxss1 libxt6 libxtst6 libxv1 libxxf86dga1 libxxf86vm1 mesa-vulkan-drivers pkg-config 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 xdg-utils zip zlib1g-dev
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  r-base
0 upgraded, 0 newly installed, 1 to remove and 1 not upgraded.
After this operation, 62.5 kB disk space will be freed.

and all of its dependencies

cr173@vcm-26406:~$ sudo apt autoremove

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  fontconfig fontconfig-config fonts-dejavu-core gfortran gfortran-9 icu-devtools libblas-dev libblas3 libbz2-dev libcairo2 libdatrie1 libdrm-amdgpu1 libdrm-intel1
  libdrm-nouveau2 libdrm-radeon1 libfile-basedir-perl libfile-desktopentry-perl libfile-mimeinfo-perl libfontconfig1 libfontenc1 libgfortran-9-dev libgfortran5 libgl1
  libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0 libgraphite2-3 libharfbuzz0b libice6 libicu-dev libio-stringy-perl libipc-system-simple-perl libjbig0 libjpeg-dev
  libjpeg-turbo8 libjpeg-turbo8-dev libjpeg8 libjpeg8-dev liblapack-dev liblapack3 libllvm12 liblzma-dev libncurses-dev libncurses5-dev libnet-dbus-perl libpango-1.0-0
  libpangocairo-1.0-0 libpangoft2-1.0-0 libpaper-utils libpaper1 libpciaccess0 libpcre16-3 libpcre2-16-0 libpcre2-32-0 libpcre2-dev libpcre2-posix2 libpcre3-dev libpcre32-3
  libpcrecpp0v5 libpixman-1-0 libpng-dev libpng-tools libreadline-dev libsensors-config libsensors5 libsm6 libtcl8.6 libthai-data libthai0 libtie-ixhash-perl libtiff5 libtk8.6
  libvulkan1 libwayland-client0 libwebp6 libx11-protocol-perl libx11-xcb1 libxaw7 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-render0
  libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcomposite1 libxcursor1 libxfixes3 libxft2 libxi6 libxinerama1 libxkbfile1 libxml-parser-perl libxml-twig-perl
  libxml-xpathengine-perl libxmu6 libxpm4 libxrandr2 libxrender1 libxshmfence1 libxss1 libxt6 libxtst6 libxv1 libxxf86dga1 libxxf86vm1 mesa-vulkan-drivers pkg-config 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 xdg-utils zip zlib1g-dev
0 upgraded, 0 newly installed, 140 to remove and 1 not upgraded.
After this operation, 749 MB disk space will be freed.
Do you want to continue? [Y/n]

Updating & Upgrading

cr173@vcm-26406:~$ sudo apt update

Hit:1 http://archive.linux.duke.edu/ubuntu focal InRelease
Hit:2 http://archive.linux.duke.edu/ubuntu focal-updates InRelease
Hit:3 http://archive.linux.duke.edu/ubuntu focal-backports InRelease
Hit:4 http://archive.linux.duke.edu/ubuntu focal-security InRelease
Hit:5 https://falcon-dl.oit.duke.edu/ubuntu focal InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
1 package can be upgraded. Run 'apt list --upgradable' to see it.
cr173@vcm-26406:~$ sudo apt upgrade

Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  libfribidi0
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 standard security update
Need to get 24.2 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n]

Aside - Conflicts

...
update-initramfs: deferring update (trigger activated)
amd64-microcode: microcode will be updated at next boot
Setting up intel-microcode (3.20180807a.0ubuntu0.18.04.1) ...
update-initramfs: deferring update (trigger activated)
intel-microcode: microcode will be updated at next boot
Setting up kmod (24-1ubuntu3.1) ...

*Configuration file '/etc/modprobe.d/blacklist.conf'
* ==> Modified (by you or by a script) since installation.
* ==> Package distributor has shipped an updated version.
*   What would you like to do about it ?  Your options are:
*    Y or I  : install the package maintainer's version
*    N or O  : keep your currently-installed version
*      D     : show the differences between the versions
*      Z     : start a shell to examine the situation
* The default action is to keep your current version.
**** blacklist.conf (Y/I/N/O/D/Z) [default=N] ?
Setting up initramfs-tools-core (0.130ubuntu3.6) ...
Setting up linux-headers-4.15.0-43-generic (4.15.0-43.46) ...
Setting up initramfs-tools (0.130ubuntu3.6) ...

...

Package Details

cr173@vcm-26406:~$ apt show r-base

Package: r-base
Version: 3.6.3-2
Priority: optional
Section: universe/math
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Dirk Eddelbuettel <edd@debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 62.5 kB
Depends: r-base-core (>= 3.6.3-2), r-recommended (= 3.6.3-2)
Recommends: r-base-html, r-doc-html
Suggests: elpa-ess, r-doc-info | r-doc-pdf
Homepage: http://www.r-project.org/
Download-Size: 9,308 B
APT-Manual-Installed: yes
APT-Sources: http://archive.linux.duke.edu/ubuntu focal/universe amd64 Packages
Description: GNU R statistical computation and graphics system
 R is a system for statistical computation and graphics.  It consists
 of a language plus a run-time environment with graphics, a debugger,
 access to certain system functions, and the ability to run programs
 stored in script files.
...

Package Contents

cr173@vcm-26406:~$ dpkg -L r-base

/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/r-base
/usr/share/doc/r-base/README.Debian
/usr/share/doc/r-base/copyright
/usr/share/doc/r-base/changelog.Debian.gz

File -> Package

cr173@vcm-26406:~$ dpkg -S /usr/bin/R

r-base-core: /usr/bin/R
cr173@vcm-26406:~$ dpkg -L r-base-core

/.
/etc
/etc/R
/etc/R/Makeconf
/etc/R/Renviron.site
/etc/R/Rprofile.site
/etc/R/ldpaths
/etc/R/repositories
/etc/ld.so.conf.d
/usr
/usr/bin
/usr/bin/R
/usr/bin/Rscript
/usr/lib
/usr/lib/R
/usr/lib/R/SVN-REVISION
/usr/lib/R/bin
/usr/lib/R/bin/BATCH
/usr/lib/R/bin/COMPILE
/usr/lib/R/bin/INSTALL
/usr/lib/R/bin/LINK
/usr/lib/R/bin/R
/usr/lib/R/bin/REMOVE
/usr/lib/R/bin/Rcmd
/usr/lib/R/bin/Rd2pdf
/usr/lib/R/bin/Rdconv
/usr/lib/R/bin/Rdiff
...

Package Manager Comparison

Ubuntu / Debian RHEL Fedora Requires root
Install apt install yum install dnf install Yes
Install Local dpkg -i pkg.deb yum install pkg.rpm dnf install pkg.rpm Yes
Remove apt remove yum remove dnf remove Yes
Update apt update yum check-update dnf check-update Yes
Upgrade apt upgrade
apt full-upgrade
yum upgrade dnf upgrade Yes
Clean Deps. apt autoremove yum autoremove dnf autoremove Yes
Reinstall apt install --reinstall yum reinstall dnf reinstall Yes
Details. apt show yum info dnf info No
Dependencies apt show yum deplist dnf repoquery
--requires
No
Pkg -> Files dpkg -L rpm -qf rpm -qf No
Files -> Pkg dpkg -S rpm -ql rpm -ql or
dnf repoquery -l
No

Upgrading R

The R project maintains separate package repositories with the latest version of R - see distribution specific instructions here - the version bundled with your distribution of choice is often very outdated.

sudo apt update -qq
sudo apt install --no-install-recommends -y software-properties-common dirmngr
wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
cr173@vcm-26406:~$ cat /etc/apt/sources.list

...
deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/
# deb-src https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/
...

Updating & Upgrading

cr173@vcm-26406:~$ sudo apt update

Hit:1 http://archive.linux.duke.edu/ubuntu focal InRelease
Get:2 http://archive.linux.duke.edu/ubuntu focal-updates InRelease [114 kB]
Hit:3 http://archive.linux.duke.edu/ubuntu focal-backports InRelease
Get:4 http://archive.linux.duke.edu/ubuntu focal-security InRelease [114 kB]
Hit:5 https://falcon-dl.oit.duke.edu/ubuntu focal InRelease
Hit:6 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ InRelease
Get:7 http://archive.linux.duke.edu/ubuntu focal-updates/main amd64 Packages [1,711 kB]
Get:8 http://archive.linux.duke.edu/ubuntu focal-updates/universe amd64 Packages [916 kB]
Fetched 2,854 kB in 1s (2,551 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
22 packages can be upgraded. Run 'apt list --upgradable' to see them.
cr173@vcm-26406:~$ sudo apt upgrade

Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  libfribidi0 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
22 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 standard security update
Need to get 47.9 MB of archives.
After this operation, 3,829 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.linux.duke.edu/ubuntu focal-updates/main amd64 libfribidi0 amd64 1.0.8-2ubuntu0.1 [24.2 kB]
Get:2 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ r-cran-lattice 0.20-45-1.2004.0 [1,134 kB]
Get:3 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ r-cran-matrix 1.4-1-1.2004.0 [4,303 kB]
Get:4 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ r-cran-survival 3.2-13-1cran1.2004.0 [6,614 kB]
Get:5 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ r-cran-spatial 7.3-11-2focal0 [127 kB]
Get:6 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ r-cran-rpart 4.1.16-1.2004.0 [910 kB]
Get:7 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ r-cran-nnet 7.3-17-1.2004.0 [112 kB]
Get:8 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ r-cran-nlme 3.1.157-1.2004.0 [2,250 kB]
Get:9 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ r-cran-mgcv 1.8-40-1cran1.2004.0 [3,021 kB]
Get:10 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ r-cran-mass 7.3-56-1.2004.0 [1,117 kB]
Get:11 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ r-cran-kernsmooth 2.23-20-1cran1.2004.0 [89.7 kB]
Get:12 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ r-cran-foreign 0.8.82-1.2004.0 [238 kB]
Get:13 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ r-cran-codetools 0.2-18-1cran1.2004.0 [90.0 kB]
Get:14 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ r-cran-cluster 2.1.3-1.2004.0 [543 kB]
Get:15 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ r-cran-class 7.3-20-1.2004.0 [87.8 kB]
Get:16 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ r-cran-boot 1.3-28-1cran1.2004.0 [619 kB]
*Get:17 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ r-base-core 4.1.3-1.2004.0 [25.9 MB]
*Get:18 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ r-base 4.1.3-1.2004.0 [44.6 kB]
Get:19 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ r-recommended 4.1.3-1.2004.0 [2,780 B]
Get:20 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ r-base-dev 4.1.3-1.2004.0 [4,484 B]
Get:21 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ r-base-html 4.1.3-1.2004.0 [91.8 kB]
Get:22 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ r-doc-html 4.1.3-1.2004.0 [582 kB]
...

System dependencies

cr173@vcm-26406:~$ R

R version 4.1.3 (2022-03-10) -- "One Push-Up"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

...

> install.packages("curl")
  Installing package into ‘/usr/local/lib/R/site-library’
  (as ‘lib’ is unspecified)
  trying URL 'https://cloud.r-project.org/src/contrib/curl_4.3.2.tar.gz'
  Content type 'application/x-gzip' length 793345 bytes (774 KB)
  ==================================================
  downloaded 774 KB
  
  * installing *source* package ‘curl’ ...
  ** package ‘curl’ successfully unpacked and MD5 sums checked
  ** using staged installation
  Package libcurl was not found in the pkg-config search path.
  Perhaps you should add the directory containing `libcurl.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'libcurl' found
  Package libcurl was not found in the pkg-config search path.
  Perhaps you should add the directory containing `libcurl.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'libcurl' found
  Using PKG_CFLAGS=
  Using PKG_LIBS=-lcurl
* ------------------------- ANTICONF ERROR ---------------------------
* Configuration failed because libcurl was not found. Try installing:
*  * deb: libcurl4-openssl-dev (Debian, Ubuntu, etc)
*  * rpm: libcurl-devel (Fedora, CentOS, RHEL)
*  * csw: libcurl_dev (Solaris)
* If libcurl is already installed, check that 'pkg-config' is in your
* PATH and PKG_CONFIG_PATH contains a libcurl.pc file. If pkg-config
* is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
* R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
* --------------------------------------------------------------------
  ERROR: configuration failed for package ‘curl’
  * removing ‘/home/cr173/R/x86_64-pc-linux-gnu-library/4.1/curl’

Installing libcurl4-openssl-dev

cr173@vcm-26406:~$ sudo apt install libcurl4-openssl-dev

Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  libcurl4-doc libidn11-dev libkrb5-dev libldap2-dev librtmp-dev libssh2-1-dev libssl-dev
The following NEW packages will be installed:
  libcurl4-openssl-dev
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 321 kB of archives.
After this operation, 1,541 kB of additional disk space will be used.
Get:1 http://archive.linux.duke.edu/ubuntu focal-updates/main amd64 libcurl4-openssl-dev amd64 7.68.0-1ubuntu2.7 [321 kB]
Fetched 321 kB in 0s (2,051 kB/s)
Selecting previously unselected package libcurl4-openssl-dev:amd64.
(Reading database ... 126123 files and directories currently installed.)
Preparing to unpack .../libcurl4-openssl-dev_7.68.0-1ubuntu2.7_amd64.deb ...
Unpacking libcurl4-openssl-dev:amd64 (7.68.0-1ubuntu2.7) ...
Setting up libcurl4-openssl-dev:amd64 (7.68.0-1ubuntu2.7) ...
Processing triggers for man-db (2.9.1-1) ...

Success

cr173@vcm-26406:~$ R
...
> install.packages("curl")
 Installing package into ‘/home/cr173/R/x86_64-pc-linux-gnu-library/4.1’
 (as ‘lib’ is unspecified)
 trying URL 'https://cloud.r-project.org/src/contrib/curl_4.3.2.tar.gz'
 Content type 'application/x-gzip' length 793345 bytes (774 KB)
 ==================================================
 downloaded 774 KB
 
 * installing *source* package ‘curl’ ...
 ** package ‘curl’ successfully unpacked and MD5 sums checked
 ** using staged installation
 Found pkg-config cflags and libs!
 Using PKG_CFLAGS=-I/usr/include/x86_64-linux-gnu
 Using PKG_LIBS=-lcurl
 ** libs
 rm -f curl.so callbacks.o curl.o download.o escape.o fetch.o form.o getdate.o handle.o ieproxy.o init.o interrupt.o multi.o nslookup.o reflist.o split.o ssl.o typechecking.o utils.o version.o winidn.o writer.o
 gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c callbacks.c -o callbacks.o
 gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c curl.c -o curl.o
 gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c download.c -o download.o
 gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c escape.c -o escape.o
 gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c fetch.c -o fetch.o
 gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c form.c -o form.o
 gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c getdate.c -o getdate.o
 gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c handle.c -o handle.o
 gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c ieproxy.c -o ieproxy.o
 gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c init.c -o init.o
 gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c interrupt.c -o interrupt.o
 gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c multi.c -o multi.o
 gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c nslookup.c -o nslookup.o
 gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c reflist.c -o reflist.o
 gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c split.c -o split.o
 gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c ssl.c -o ssl.o
 gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c typechecking.c -o typechecking.o
 gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c utils.c -o utils.o
 gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c version.c -o version.o
 gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c winidn.c -o winidn.o
 gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c writer.c -o writer.o
 gcc -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o curl.so callbacks.o curl.o download.o escape.o fetch.o form.o getdate.o handle.o ieproxy.o init.o interrupt.o multi.o nslookup.o reflist.o split.o ssl.o typechecking.o utils.o version.o winidn.o writer.o -lcurl -L/usr/lib/R/lib -lR
 installing to /home/cr173/R/x86_64-pc-linux-gnu-library/4.1/00LOCK-curl/00new/curl/libs
 ** R
 ** inst
 ** byte-compile and prepare package for lazy loading
 ** help
 *** installing help indices
 ** building package indices
 ** installing vignettes
 ** testing if installed package can be loaded from temporary location
 ** checking absolute paths in shared objects and dynamic libraries
 ** testing if installed package can be loaded from final location
 ** testing if installed package keeps a record of temporary installation path
 * DONE (curl)

What is libcurl4-openssl-dev?

cr173@vcm-26406:~$ apt show libcurl4-openssl-dev

Package: libcurl4-openssl-dev
Version: 7.68.0-1ubuntu2.7
Priority: optional
Section: libdevel
Source: curl
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Alessandro Ghedini <ghedo@debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 1,541 kB
Provides: libcurl-dev, libcurl-ssl-dev, libcurl3-dev, libcurl3-openssl-dev, libcurl4-dev
Depends: libcurl4 (= 7.68.0-1ubuntu2.7)
Suggests: libcurl4-doc, libidn11-dev, libkrb5-dev, libldap2-dev, librtmp-dev, libssh2-1-dev, libssl-dev (>= 1.1), pkg-config, zlib1g-dev
Conflicts: libcurl4-gnutls-dev, libcurl4-nss-dev, libssl-dev (<< 1.1), libssl1.0-dev
Homepage: http://curl.haxx.se
Download-Size: 321 kB
APT-Manual-Installed: yes
APT-Sources: http://archive.linux.duke.edu/ubuntu focal-updates/main amd64 Packages
*Description: development files and documentation for libcurl (OpenSSL flavour)
* libcurl is an easy-to-use client-side URL transfer library, supporting DICT,
* FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S,
* RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET and TFTP.
 .
 libcurl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP
 form based upload, proxies, cookies, user+password authentication (Basic,
 Digest, NTLM, Negotiate, Kerberos), file transfer resume, http proxy tunneling
 and more!
 .
 libcurl is free, thread-safe, IPv6 compatible, feature rich, well supported,
 fast, thoroughly documented and is already used by many known, big and
 successful companies and numerous applications.
 .
 This package provides the development files (ie. includes, static library,
 manual pages) that allow one to build software which uses libcurl.
 .
 SSL support is provided by OpenSSL.

What is in libcurl4-openssl-dev?

cr173@vcm-26406:~$ dpkg -L libcurl4-openssl-dev
/.
/usr
/usr/bin
/usr/bin/curl-config
/usr/include
/usr/include/x86_64-linux-gnu
/usr/include/x86_64-linux-gnu/curl
/usr/include/x86_64-linux-gnu/curl/curl.h
/usr/include/x86_64-linux-gnu/curl/curlver.h
/usr/include/x86_64-linux-gnu/curl/easy.h
/usr/include/x86_64-linux-gnu/curl/mprintf.h
/usr/include/x86_64-linux-gnu/curl/multi.h
/usr/include/x86_64-linux-gnu/curl/stdcheaders.h
/usr/include/x86_64-linux-gnu/curl/system.h
/usr/include/x86_64-linux-gnu/curl/typecheck-gcc.h
/usr/include/x86_64-linux-gnu/curl/urlapi.h
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libcurl.a
/usr/lib/x86_64-linux-gnu/libcurl.la
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig/libcurl.pc
/usr/share
/usr/share/aclocal
/usr/share/aclocal/libcurl.m4
/usr/share/doc
/usr/share/doc/libcurl4-openssl-dev
/usr/share/doc/libcurl4-openssl-dev/copyright
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/curl-config.1.gz
/usr/lib/x86_64-linux-gnu/libcurl.so
/usr/share/doc/libcurl4-openssl-dev/NEWS.Debian.gz
/usr/share/doc/libcurl4-openssl-dev/changelog.Debian.gz

Lets try sf

cr173@vcm-26406:~$ R
...
 > install.packages("sf")
 Installing package into ‘/home/cr173/R/x86_64-pc-linux-gnu-library/4.1’
 (as ‘lib’ is unspecified)
 trying URL 'https://cloud.r-project.org/src/contrib/sf_1.0-7.tar.gz'
 Content type 'application/x-gzip' length 3529597 bytes (3.4 MB)
 ==================================================
 downloaded 3.4 MB
 
 * installing *source* package ‘sf’ ...
 ** package ‘sf’ successfully unpacked and MD5 sums checked
 ** using staged installation
 configure: CC: gcc
 configure: CXX: g++ -std=gnu++11
 checking for gdal-config... no
 no
 configure: error: gdal-config not found or not executable.
 ERROR: configuration failed for package ‘sf’
 * removing ‘/home/cr173/R/x86_64-pc-linux-gnu-library/4.1/sf’
 
 The downloaded source packages are in
    ‘/tmp/RtmpAt7DId/downloaded_packages’
 Warning message:
 In install.packages("sf") :
   installation of package ‘sf’ had non-zero exit status

What next?



A bit about libraries

System libraries

These are shared common components that are used by a variety of software on a linux system. For the most part they are a collection of compiled code (typically C / C++) that are stored in a single file.

  • Allows for code reuse

  • Allows for multiple (concurrent) versions

  • Avoids reinventing the wheel

  • Installed in /lib, /usr/lib, /usr/local/lib, etc.

  • Two flavors: static (.a) and dynamic (.so)

libcurl

cr173@vcm-26406:~$ ls -la /usr/lib/x86_64-linux-gnu/libcurl*

-rw-r--r-- 1 root root 1057632 Oct 29 08:10 /usr/lib/x86_64-linux-gnu/libcurl.a
lrwxrwxrwx 1 root root      19 Oct 29 08:10 /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.3 -> libcurl-gnutls.so.4
lrwxrwxrwx 1 root root      23 Oct 29 08:10 /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 -> libcurl-gnutls.so.4.5.0
-rw-r--r-- 1 root root  510408 Oct 29 08:10 /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.5.0
-rw-r--r-- 1 root root     951 Oct 29 08:10 /usr/lib/x86_64-linux-gnu/libcurl.la
lrwxrwxrwx 1 root root      16 Oct 29 08:10 /usr/lib/x86_64-linux-gnu/libcurl.so -> libcurl.so.4.5.0
lrwxrwxrwx 1 root root      16 Oct 29 08:10 /usr/lib/x86_64-linux-gnu/libcurl.so.4 -> libcurl.so.4.5.0
-rw-r--r-- 1 root root  518600 Oct 29 08:10 /usr/lib/x86_64-linux-gnu/libcurl.so.4.5.0

Getting what you want

The following is a basic heuristic of library package naming schemes for these distro families, there are exceptions and edge cases.

These are the names that would then be used with something like apt install or yum install respectively.


Debian Redhat
Dynamic library (.so) lib{name} {name}
Headers lib{name}-dev {name}-devel
Static library (.a) lib{name}-dev {name}-static
Documentation lib{name}-doc {name}-devel

Troubleshooting dynamic libraries

cr173@vcm-26406:~$ ldd /usr/lib/x86_64-linux-gnu/libcurl.so

    linux-vdso.so.1 (0x00007ffd98176000)
    libnghttp2.so.14 => /usr/lib/x86_64-linux-gnu/libnghttp2.so.14 (0x00007f1e3dc60000)
    libidn2.so.0 => /usr/lib/x86_64-linux-gnu/libidn2.so.0 (0x00007f1e3da43000)
    librtmp.so.1 => /usr/lib/x86_64-linux-gnu/librtmp.so.1 (0x00007f1e3d827000)
    libpsl.so.5 => /usr/lib/x86_64-linux-gnu/libpsl.so.5 (0x00007f1e3d619000)
    libssl.so.1.1 => /usr/lib/x86_64-linux-gnu/libssl.so.1.1 (0x00007f1e3d3af000)
    libcrypto.so.1.1 => /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 (0x00007f1e3cf37000)
    libgssapi_krb5.so.2 => /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2 (0x00007f1e3ccec000)
    libldap_r-2.4.so.2 => /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2 (0x00007f1e3ca9a000)
    liblber-2.4.so.2 => /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2 (0x00007f1e3c88c000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f1e3c66f000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f1e3c450000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1e3c05f000)
    libunistring.so.2 => /usr/lib/x86_64-linux-gnu/libunistring.so.2 (0x00007f1e3bce1000)
    libgnutls.so.30 => /usr/lib/x86_64-linux-gnu/libgnutls.so.30 (0x00007f1e3b97c000)
    libhogweed.so.4 => /usr/lib/x86_64-linux-gnu/libhogweed.so.4 (0x00007f1e3b748000)
    libnettle.so.6 => /usr/lib/x86_64-linux-gnu/libnettle.so.6 (0x00007f1e3b512000)
    libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007f1e3b291000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1e3b08d000)
    libkrb5.so.3 => /usr/lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007f1e3adb7000)
    libk5crypto.so.3 => /usr/lib/x86_64-linux-gnu/libk5crypto.so.3 (0x00007f1e3ab85000)
    libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007f1e3a981000)
    libkrb5support.so.0 => /usr/lib/x86_64-linux-gnu/libkrb5support.so.0 (0x00007f1e3a776000)
    libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f1e3a55b000)
    libsasl2.so.2 => /usr/lib/x86_64-linux-gnu/libsasl2.so.2 (0x00007f1e3a340000)
    libgssapi.so.3 => /usr/lib/x86_64-linux-gnu/libgssapi.so.3 (0x00007f1e3a0ff000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f1e3e104000)
    libp11-kit.so.0 => /usr/lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007f1e39dd0000)
    libtasn1.so.6 => /usr/lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007f1e39bbd000)
    libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007f1e399b9000)
    libheimntlm.so.0 => /usr/lib/x86_64-linux-gnu/libheimntlm.so.0 (0x00007f1e397b0000)
    libkrb5.so.26 => /usr/lib/x86_64-linux-gnu/libkrb5.so.26 (0x00007f1e39523000)
    libasn1.so.8 => /usr/lib/x86_64-linux-gnu/libasn1.so.8 (0x00007f1e39281000)
    libhcrypto.so.4 => /usr/lib/x86_64-linux-gnu/libhcrypto.so.4 (0x00007f1e3904b000)
    libroken.so.18 => /usr/lib/x86_64-linux-gnu/libroken.so.18 (0x00007f1e38e35000)
    libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007f1e38c2d000)
    libwind.so.0 => /usr/lib/x86_64-linux-gnu/libwind.so.0 (0x00007f1e38a04000)
    libheimbase.so.1 => /usr/lib/x86_64-linux-gnu/libheimbase.so.1 (0x00007f1e387f5000)
    libhx509.so.5 => /usr/lib/x86_64-linux-gnu/libhx509.so.5 (0x00007f1e385ab000)
    libsqlite3.so.0 => /usr/lib/x86_64-linux-gnu/libsqlite3.so.0 (0x00007f1e382a2000)
    libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f1e3806a000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1e37ccc000)

Python management

cr173@vcm-26406:~$ pip install torch

Command 'pip' not found, but can be installed with:

apt install python3-pip
Please ask your administrator.
cr173@vcm-26406:~$ sudo apt install python3-pip
[sudo] password for cr173:

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libexpat1-dev libpython3-dev libpython3.8-dev python-pip-whl python3-dev python3-wheel python3.8-dev
The following NEW packages will be installed:
  libexpat1-dev libpython3-dev libpython3.8-dev python-pip-whl python3-dev python3-pip python3-wheel python3.8-dev
0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
Need to get 6,651 kB of archives.
After this operation, 25.0 MB of additional disk space will be used.
Do you want to continue? [Y/n]

Package manager vs pip

cr173@vcm-26406:~$ sudo apt install python3-numpy

Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-numpy is already the newest version (1:1.17.4-5ubuntu3).
python3-numpy set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
cr173@vcm-26406:~$ sudo pip install numpy --upgrade

Collecting numpy
  Downloading numpy-1.22.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.8 MB)
     |████████████████████████████████| 16.8 MB 3.6 MB/s
Installing collected packages: numpy
  Attempting uninstall: numpy
    Found existing installation: numpy 1.17.4
    Not uninstalling numpy at /usr/lib/python3/dist-packages, outside environment /usr
    Can't uninstall 'numpy'. No files were found to uninstall.
Successfully installed numpy-1.22.3
cr173@vcm-26406:~$ sudo pip install numpy --upgrade --ignore-installed

Collecting numpy
  Using cached numpy-1.22.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.8 MB)
Installing collected packages: numpy
Successfully installed numpy-1.22.3

Outdated python libraries

cr173@vcm-26406:~$ sudo pip list --outdated
Package             Version     Latest    Type
------------------- ----------- --------- -----
ansible             2.9.6       5.6.0     sdist
apache-libcloud     2.8.0       3.5.1     wheel
argcomplete         1.8.1       2.0.0     wheel
certifi             2019.11.28  2021.10.8 wheel
chardet             3.0.4       4.0.0     wheel
cryptography        2.8         36.0.2    wheel
dbus-python         1.2.16      1.2.18    sdist
distro              1.4.0       1.7.0     wheel
distro-info         0.23ubuntu1 1.0       wheel
dnspython           1.16.0      2.2.1     wheel
entrypoints         0.3         0.4       wheel
GDAL                3.0.4       3.4.2     sdist
httplib2            0.14.0      0.20.4    wheel
idna                2.8         3.3       wheel
Jinja2              2.10.1      3.1.1     wheel
jmespath            0.9.4       1.0.0     wheel
keyring             18.0.1      23.5.0    wheel
launchpadlib        1.10.13     1.10.16   wheel
lazr.restfulclient  0.14.2      0.14.4    sdist
lazr.uri            1.0.3       1.0.6     sdist
MarkupSafe          1.1.0       2.1.1     wheel
netaddr             0.7.19      0.8.0     wheel
netifaces           0.10.4      0.11.0    wheel
ntlm-auth           1.1.0       1.5.0     wheel
oauthlib            3.1.0       3.2.0     wheel
pip                 20.0.2      22.0.4    wheel
PyGObject           3.36.0      3.42.0    sdist
PyJWT               1.7.1       2.3.0     wheel
pykerberos          1.1.14      1.2.4     sdist
PyNaCl              1.3.0       1.5.0     wheel
pywinrm             0.3.0       0.4.2     wheel
PyYAML              5.3.1       6.0       wheel
...

Docker

Docker

Docker can package an application and its dependencies in a virtual container that can run on any Linux, Windows, or macOS computer. This enables the application to run in a variety of locations, such as on-premises, in the public or private cloud. When running on Linux, Docker uses the resource isolation features of the Linux kernel (such as cgroups and kernel namespaces) and a union-capable file system to allow containers to run within a single Linux instance, avoiding the overhead of starting and maintaining virtual machines.

From Wikipedia

Installation - Ubuntu / Debian

# Remove system packages
sudo apt-get remove docker docker-engine docker.io containerd runc

# Utililty Packages
sudo apt-get update
sudo apt-get install \
   ca-certificates \
   curl \
   gnupg \
   lsb-release

# Add apt repo signing key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

# Add apt repo
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
   
# Install Docker
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

Troubleshooting - daemon

$ sudo docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.

This occurs when the docker daemon is not running, this can be fixed by enabling the docker service / daemon,

# Make sure the daemon runs automatically in the future
$ sudo systemctl enable docker

# Start the daemon
$ sudo systemctl start docker

Success

$ sudo docker run hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete 
Digest: sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Troubleshooting - permissions

$ docker run hello-world

docker: Got permission denied while trying to connect to the Docker daemon socket at 
unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.39/containers/create: 
dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.

You must either be root or be a member of the docker group to use docker. Currently, your VM may or may not have a docker group and your account is likely not a member. If you are tired of typing sudo + your password there is an easy fix,

# Make sure the docker group exists
$ sudo groupadd docker

# Add your user to the docker group
$ sudo usermod -aG docker $USER

# Check memberships
$ groups
# If docker is not listed you should log out and log back in

Success

$ docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Getting Started

Getting images

$ docker pull ubuntu

Using default tag: latest
latest: Pulling from library/ubuntu
84ed7d2f608f: Pull complete 
be2bf1c4a48d: Pull complete 
a5bdc6303093: Pull complete 
e9055237d68d: Pull complete 
Digest: sha256:868fd30a0e47b8d8ac485df174795b5e2fe8a6c8f056cc707b232d65b8a1ab68
Status: Downloaded newer image for ubuntu:latest
$ docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              fce289e99eb9        2 weeks ago         1.84kB
ubuntu              latest              1d9c17228a9e        3 weeks ago         86.7MB

Tags (Versions)

$ docker pull ubuntu:18.10

18.10: Pulling from library/ubuntu
d222a4da264e: Pull complete 
fc8aef08d7f5: Pull complete 
dc25173478e9: Pull complete 
860140c5e05a: Pull complete 
Digest: sha256:79c90229315b26cf37b577db41418874de1c22fb80c3827c80ea624dd993d905
Status: Downloaded newer image for ubuntu:18.10
$ docker pull ubuntu:18.04

18.04: Pulling from library/ubuntu
Digest: sha256:868fd30a0e47b8d8ac485df174795b5e2fe8a6c8f056cc707b232d65b8a1ab68
Status: Downloaded newer image for ubuntu:18.04
$ docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              fce289e99eb9        2 weeks ago         1.84kB
ubuntu              18.10               d4452947e3fa        3 weeks ago         73.7MB
ubuntu              18.04               1d9c17228a9e        3 weeks ago         86.7MB
ubuntu              latest              1d9c17228a9e        3 weeks ago         86.7MB

Other sources

DockerHub is not the only source of images - their are many other possible hosts and all you need to provide is a URL along with the image name.

$ docker pull ghcr.io/sta663-sp23/sta663-base:latest
main: Pulling from sta663-sp23/sta663-base
7c3b88808835: Pull complete
912f6b2ba154: Pull complete
dd644c73e3f7: Pull complete
443b00f2b587: Pull complete
7eed48b59675: Pull complete
aaf570891e1e: Pull complete
2b816b5489a9: Pull complete
15173f034c8a: Pull complete
abec7c76a54d: Pull complete
bc643c87ba6a: Pull complete
05c705c824a9: Pull complete
d8d2591a295c: Pull complete
b11dc49aa06d: Pull complete
eac230728938: Pull complete
37972a8150df: Pull complete
Digest: sha256:7c769800b08d698cf4e08dfa48f44eb411486e319a9a195a940304ca078b40cb
Status: Downloaded newer image for ghcr.io/sta663-sp23/sta663-base:latest
ghcr.io/sta663-sp23/sta663-base:latest

$ docker images

REPOSITORY                        TAG       IMAGE ID       CREATED        SIZE
ghcr.io/sta663-sp23/sta663-base   latest    3ad03e2bb895   15 hours ago   4.87GB
ubuntu                            22.04     bab8ce5c00ca   5 weeks ago    69.2MB

Running a container

$ docker run --rm ubuntu cat /etc/os-release

NAME="Ubuntu"
VERSION="18.04.1 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.1 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
$ docker run --rm ubuntu:18.10 cat /etc/os-release

NAME="Ubuntu"
VERSION="18.10 (Cosmic Cuttlefish)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.10"
VERSION_ID="18.10"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=cosmic
UBUNTU_CODENAME=cosmic

$ docker run --rm fedora:latest cat /etc/os-release

Unable to find image 'fedora:latest' locally
latest: Pulling from library/fedora
0be2a68855d7: Pull complete 
Digest: sha256:7b921a4a008ee83c06d2cde9f21d3aa8de4635b0c4ec159f31caee83ad220b21
Status: Downloaded newer image for fedora:latest
NAME=Fedora
VERSION="29 (Container Image)"
ID=fedora
VERSION_ID=29
VERSION_CODENAME=""
PLATFORM_ID="platform:f29"
PRETTY_NAME="Fedora 29 (Container Image)"
ANSI_COLOR="0;34"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:29"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f29/system-administrators-guide/"
SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=29
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=29
PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
VARIANT="Container Image"
VARIANT_ID=container

docker run - Important options

docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]


Option Description
--name Give your container a name
--rm Automatically remove the container when it exits
-i -t Allow for interaction with container (STDIN & tty specifically)
-p host:cont Publish a container’s port
-v host:cont Share filesystems
-e "VAR=VAL" Define environmental variables

Other useful commands

command Description
docker pull NAME[:TAG] Pull docker image (usually from DockerHub)
docker images List docker images
docker rmi IMAGE Remove an image
docker container ls [--all] List (all) docker containers
docker rm CONTAINER Remove a container
docker stop CONTAINER Stop a running container
docker start CONTAINER Start a stopped container
docker attach CONTAINER Attach to a running container
docker commit CONTAINER REPO[:TAG] Create an image from a container
docker rename CONTAINER NAME Rename a container

rocker

+ = Rocker

The rocker project provides a collection of containers suited for different needs. find a base image to extend or images with popular software and optimized libraries pre-installed. Get the latest version or a reproducibly fixed environment.

rocker + rstudio

$ docker pull rocker/rstudio

Using default tag: latest
latest: Pulling from rocker/rstudio
54f7e8ac135a: Pull complete
021dd68904f6: Pull complete
8d3e964cf18d: Pull complete
81bbbedbef33: Pull complete
c7878d347b3f: Pull complete
a7aae3dbd958: Pull complete
da950bb11a69: Pull complete
Digest: sha256:b9e6acea945ca28ec14b3de9925372bdd6c5e3828a8575b34d4247f619b66dd5
Status: Downloaded newer image for rocker/rstudio:latest
$ docker run -e PASSWORD=SECRET --rm -p 8787:8787 rocker/rstudio
...

rocker + rstudio + tidyverse + latex + sf

$ docker pull rocker/geospatial

Using default tag: latest
latest: Pulling from rocker/geospatial
54f7e8ac135a: Already exists
021dd68904f6: Already exists
8d3e964cf18d: Already exists
81bbbedbef33: Already exists
c7878d347b3f: Already exists
a7aae3dbd958: Already exists
da950bb11a69: Already exists
9802011fbe26: Pull complete
334f65727953: Pull complete
e506f9195a59: Pull complete
Digest: sha256:c3158846628b07d4616fafa30ef1d97cdc1b706d1c9aa30d62e7862ffd75703e
Status: Downloaded newer image for rocker/geospatial:latest34d4247f619b66dd5
Status: Downloaded newer image for rocker/rstudio:latest
$ docker run -e PASSWORD=SECRET --rm -p 8787:8787 rocker/geospatial
...

Dockerfile(s)

Common commands

command Description
FROM specify a base image
RUN run commands (e.g. apt or yum), changes saved to image
COPY copy a local file into the image
ENV set environment variables for Dockerfile and image
USER set user to use (affects subsequent RUN, CMD, ENDPOINT)
WORKDIR set the working directory
EXPOSE specify which ports will be used (not published automatically)
CMD specify what (default) action should run when running the image

A tidy example

tidy1/Dockerfile:

FROM ubuntu:22.02

ENV DEBIAN_FRONTEND=noninteractive

RUN apt update
RUN apt install -y r-base
RUN Rscript -e "install.packages('tibble')"

CMD ["R"]

Building

$ docker build -t tidy1 .

Sending build context to Docker daemon  2.048kB
Step 1/6 : FROM ubuntu:18.10
 ---> d4452947e3fa
Step 2/6 : ENV DEBIAN_FRONTEND=noninteractive
 ---> Using cache
 ---> e0d77908f64a
Step 3/6 : RUN apt update
 ---> Running in fa6969a427d9
...
 ---> 979edce6cc0b
Step 4/6 : RUN apt install -y r-base
 ---> Running in 1cc3e97a8258
...
 ---> 87a882be95d7
Step 5/6 : RUN Rscript -e "install.packages('tibble')"
 ---> Running in e9de97c98208
...
Removing intermediate container e9de97c98208
 ---> 5f1666e4e342
Step 6/6 : CMD ["R"]
 ---> Running in 07f9ea769466
...
 ---> 67b0f0ee7f5c
Successfully built 67b0f0ee7f5c
Successfully tagged tidy1:latest

Images

$ docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
tidy1               latest              b29115e0a5d2        29 seconds ago      697MB
ubuntu              18.10               d4452947e3fa        3 weeks ago         73.7MB
ubuntu              latest              1d9c17228a9e        3 weeks ago         86.7MB

$ docker images -a

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
<none>              <none>              598100ea4878        25 seconds ago      697MB
tidy1               latest              b29115e0a5d2        25 seconds ago      697MB
<none>              <none>              75296565d476        56 seconds ago      690MB
<none>              <none>              d82af2f4083b        2 minutes ago       96.3MB
<none>              <none>              6bb4e2b36ade        2 minutes ago       73.7MB
ubuntu              18.10               d4452947e3fa        3 weeks ago         73.7MB
ubuntu              latest              1d9c17228a9e        3 weeks ago         86.7MB

A better tidy example

tidy2/Dockerfile:

FROM ubuntu:21.10

ENV DEBIAN_FRONTEND=noninteractive

RUN apt update \
 && apt install -y r-base \
 && Rscript -e "install.packages('tibble')"

CMD ["R"]

Building

$ docker build -t tidy2 .

Sending build context to Docker daemon  2.048kB
Step 1/4 : FROM ubuntu:18.10
 ---> d4452947e3fa
Step 2/4 : ENV DEBIAN_FRONTEND=noninteractive
 ---> Running in be9c52bb8db9
Removing intermediate container be9c52bb8db9
 ---> e0d77908f64a
Step 3/4 : RUN apt update  && apt install -y r-base  && Rscript -e "install.packages('tibble')"
...
Step 4/4 : CMD ["R"]
 ---> Running in d98129eb112c
Removing intermediate container d98129eb112c
 ---> be418f99be82
Successfully built be418f99be82
Successfully tagged tidy2:latest

Images

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
tidy2               latest              be418f99be82        7 seconds ago       697MB
ubuntu              18.10               d4452947e3fa        3 weeks ago         73.7MB
ubuntu              latest              1d9c17228a9e        3 weeks ago         86.7MB

$ docker images -a
REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
tidy2               latest              be418f99be82        9 seconds ago        697MB
<none>              <none>              7869e0549108        10 seconds ago       697MB
<none>              <none>              e0d77908f64a        About a minute ago   73.7MB
ubuntu              18.10               d4452947e3fa        3 weeks ago          73.7MB
ubuntu              latest              1d9c17228a9e        3 weeks ago          86.7MB

Dangling images

$ docker images -a
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
<none>              <none>              83384d4f0d1c        14 minutes ago      714MB
<none>              <none>              b656b4674ab9        15 minutes ago      209MB
<none>              <none>              c02c49f3aed2        15 minutes ago      96.3MB
<none>              <none>              cff3a89309ff        15 minutes ago      73.7MB
ubuntu              18.10               d4452947e3fa        3 weeks ago         73.7MB
ubuntu              latest              1d9c17228a9e        3 weeks ago         86.7MB
$ docker image prune
WARNING! This will remove all dangling images.
Are you sure you want to continue? [y/N] y
Deleted Images:
deleted: sha256:83384d4f0d1c6989ad492aee44dd44ca0a6aa013c0b80a78294d2d63e13c6d0c
deleted: sha256:ada707994b5f0aacd91d44b221e78fb4674c2f53afed87ac9c8f3db39b993d48
deleted: sha256:b656b4674ab989f57e1dc3dab682bcbfe6b8634206935cb630e09cfcecf5f645
deleted: sha256:8769da78ba480413ba7b3ee505008b88e549214a96238744bc328901367c38c1
deleted: sha256:c02c49f3aed2b3131f4e636745f713aab28ba870e9ec2ac2c0b13b008e9a2fd3
deleted: sha256:095edb1ee39242ed717542420ab9a4911f7cd805713bfd94b321d52d25091eda
deleted: sha256:cff3a89309ffcc08fe80a3558e1c6715574a4ec3ac926bbd49cd90519aa62241

Total reclaimed space: 640.4MB

Course docker images