APT

From Leo's Notes
Last edited on 22 September 2020, at 01:30.

APT is the package manager on Debian based Linux distributions and includes apt-get and dpkg and related utilities.

Usage

Task Command
Install a package by name
# apt-get install <package>
Remove a package by name
# apt-get remove --purge
# apt-get autoremove <package>
Upgrade a package
# apt-get update
# apt-get upgrade <package>
Search for a package
# apt-cache search <package>
Apt gathers all the commands together, so you can now do:
# apt search package
List installed packages
# dpkg -l
Look for a specific package by name
# dpkg -l <package name>
Determine which package provided a file
# dpkg -S <path to file>

Troubleshooting

Couldn't create temporary file /tmp/apt.conf.* for passing config to apt-key

On a clean install of Raspbian Buster, I got:

# apt-get update
Get:1 https://repos.influxdata.com/debian buster InRelease [4,731 B]
Err:1 https://repos.influxdata.com/debian buster InRelease
  Couldn't create temporary file /tmp/apt.conf.EiuAqc for passing config to apt-key
Get:2 http://archive.raspberrypi.org/debian buster InRelease [32.6 kB]
Get:3 http://raspbian.raspberrypi.org/raspbian buster InRelease [15.0 kB]
Err:3 http://raspbian.raspberrypi.org/raspbian buster InRelease
  Couldn't create temporary file /tmp/apt.conf.pRhbYl for passing config to apt-key
Err:2 http://archive.raspberrypi.org/debian buster InRelease
  Couldn't create temporary file /tmp/apt.conf.wZl0Lq for passing config to apt-key
Reading package lists... Done
W: GPG error: https://repos.influxdata.com/debian buster InRelease: Couldn't create temporary file /tmp/apt.conf.EiuAqc for passing config to apt-key
E: The repository 'https://repos.influxdata.com/debian buster InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://raspbian.raspberrypi.org/raspbian buster InRelease: Couldn't create temporary file /tmp/apt.conf.pRhbYl for passing config to apt-key
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://archive.raspberrypi.org/debian buster InRelease: Couldn't create temporary file /tmp/apt.conf.wZl0Lq for passing config to apt-key

It turns out /tmp wasn't configured with the right permissions and only root could write to it. To fix this, run:

# chmod 1777 /tmp