• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

apt-key Command Examples in Linux

by admin

apt-key is a command-line utility that is used to manage the authentication keys that are used to authenticate packages. It is a part of the apt package manager, which manages packages on Debian-based systems.

The apt-key command is used to manage the authentication keys that are used to authenticate packages. These keys are used to verify the integrity and authenticity of the packages that are installed on the system.

Some of the common options for the apt-key command include the following:

  • add: Add a new key to the keyring.
  • adv: Run an advanced key server command.
  • del: Remove a key from the keyring.
  • export: Export one or more keys from the keyring.
  • import: Import one or more keys into the keyring.
  • list: List the keys in the keyring.

Here is an example of how apt-key can be used to add a new key to the keyring:

# apt-key add /path/to/key.asc

This command adds the key stored in the file /path/to/key.asc to the keyring. The key can then be used to authenticate packages. You can learn more about the apt-key command and its options by reading the apt-key man page or by typing apt-key –help at the command prompt.

apt-key Command Examples

1. List trusted keys:

# apt-key list

2. Add a key to the trusted keystore:

# apt-key add {{public_key_file.asc}}

3. Delete a key from the trusted keystore:

# apt-key del {{key_id}}

4. Add a remote key to the trusted keystore:

# wget -qO - {{https://host.tld/filename.key}} | apt-key add -

5. Add a key from keyserver with only key id:

# apt-key adv --keyserver {{pgp.mit.edu}} --recv {{KEYID}}
Note: apt-key is now deprecated (except for the use of apt-key del in maintainer scripts).

Filed Under: Linux

Some more articles you might also be interested in …

  1. comm: Select or reject lines common to two files. Both files must be sorted
  2. ceph Command Examples in Linux
  3. kdialog: command not found
  4. envsubst: command not found
  5. jpegtran for image optimization
  6. lvcreate: command not found
  7. mkfs.btrfs: command not found
  8. lvscan Command Examples in Linux
  9. How to Find and Delete Empty Directories and Files in Linux
  10. How to Setup a sudo Switch to Another User That Has no Password or ssh Key Set in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright