APT: Difference between revisions

From Leo's Notes
This page was last edited on 22 September 2020, at 01:30.
List of commands for common tasks in an apt environment
 
Line 1: Line 1:
APT is the package manager on Debian based Linux distributions and includes {{code|apt-get}} and {{code|dpkg}} and related utilities.
APT is the package manager on Debian based Linux distributions and includes {{code|apt-get}} and {{code|dpkg}} and related utilities.


== Usage ==
==Usage==
{| class="wikitable"
{| class="wikitable"
! Task
!Task
! Command
!Command
|-
|-
| Install a package by name
|Install a package by name
| {{highlight|lang=terminal|code=
|{{highlight|lang=terminal|code=
# apt-get install <package>
# apt-get install <package>
}}
}}
|-
|-
| Remove a package by name
|Remove a package by name
| {{highlight|lang=terminal|code=
|{{highlight|lang=terminal|code=
# apt-get remove --purge
# apt-get remove --purge
# apt-get autoremove <package>
# apt-get autoremove <package>
}}
}}
|-
|-
| Upgrade a package
|Upgrade a package
| {{highlight|lang=terminal|code=
|{{highlight|lang=terminal|code=
# apt-get update
# apt-get update
# apt-get upgrade <package>
# apt-get upgrade <package>
}}
}}
|-
|-
| Search for a package
|Search for a package
| {{highlight|lang=terminal|code=
|{{highlight|lang=terminal|code=
# apt-cache search <package>
# apt-cache search <package>
}}Apt gathers all the commands together, so you can now do:
{{Highlight
| code = # apt search package
| lang = terminal
}}
}}
|-
|-
| List installed packages
|List installed packages
| {{highlight|lang=terminal|code=
|{{highlight|lang=terminal|code=
# dpkg -l
# dpkg -l
}}
}}
|-
|-
| Look for a specific package by name
|Look for a specific package by name
| {{highlight|lang=terminal|code=
|{{highlight|lang=terminal|code=
# dpkg -l <package name>
# dpkg -l <package name>
}}
}}
|-
|-
| Determine which package provided a file
|Determine which package provided a file
| {{highlight|lang=terminal|code=
|{{highlight|lang=terminal|code=
# dpkg -S <path to file>
# dpkg -S <path to file>
}}
}}
Line 45: Line 49:
|}
|}


{{Navbox Linux}}[[Category:Linux]]
== Troubleshooting ==
 
=== Couldn't create temporary file /tmp/apt.conf.* for passing config to apt-key ===
On a clean install of Raspbian Buster, I got:
{{Highlight
| code = # 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
| lang = terminal
}}
It turns out /tmp wasn't configured with the right permissions and only root could write to it. To fix this, run:
{{Highlight
| code = # chmod 1777 /tmp
| lang = terminal
}}<br />{{Navbox Linux}}
[[Category:Linux]]
[[Category:PackageManagement]]
[[Category:PackageManagement]]

Latest revision as of 01:30, 22 September 2020

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