How to Remove Apt-key in Linux [3 Practical Methods]

A Complete Guide for Beginners Enroll Course Now

Are you looking for a solution to remove the apt-key in Linux? If yes, read this article. Here, I will provide 3 easy methods about how to remove the apt-key from a Linux system. apt-key is basically a part of the apt package manager that manages the apt keys and ensures package authentication. However, if you feel like deleting some keys that are unnecessary, you can do it by following some easy steps. Usually, Debian-based distro like Ubuntu uses this apt-key to remove, add, or manage keys of the packages. Therefore, welcome to this article to all Debian-based distro users.

Process flow chart to remove apt-key in Linux:

explaining 3 methods of removing apt key

[Distro Used Throughout the Tutorial: Ubuntu 22.04.1 LTS]

3 Practical Methods to Remove Apt-key in Linux

In Linux, the apt-key manager is used by the Debian-based derivatives such as Ubuntu, Linux Mint, Kali Linux, etc. to manage keys. However, it is deprecated in the latest version of these distributions. Moreover, you can use the GUI to remove the apt-key. I will discuss every method elaborately in this section so read attentively.

You can read our Comparative Analysis of Methods to distinguish between these two methods and pick one for your needs.

Method 01: Removing Apt-Key Using the “apt-key” Manager

Though this command is the most well-known command in the Linux community to manage keys, it is not recommended for use in the current version of the Linux systems. However, it still works in the current version of Ubuntu. Follow the cases to know the process in detail.

Case 01: Removing Apt-Key Using the key Fingerprint

Fingerprint refers to the 10-block hex string of the key file which varies from key to key. So you can use it to specify the key you want to remove. Now, check the process of removal using the apt-key command with the key fingerprint:

Steps to Follow >

➊ Open the Ubuntu terminal.

➋ Write his command to list the key using the apt-key command:

sudo apt-key list
  • sudo: Permits administrative privileges.
  • apt-key: Manages keys used by apt in Debian-based Linux system.
  • list: Lists the keys.

Checking all the keys

In this picture, you can see all the keys and their fingerprints after typing the password and pressing ENTER. Now select the key fingerprint that you want to remove. Here, I am removing the key shown in the yellow box.

➌ Write this command to remove the selected key:

sudo apt-key del "8439 38DF 228D 22F7 B374  2BC0 D94A A3F0 EFE2 1092"
  • del: Deletes the requested key.
  • “8439 38DF 228D 22F7 B374 2BC0 D94A A3F0 EFE2 1092”: Key fingerprint.

removing apt key using fingerprint

After typing the Ubuntu password, the key will be deleted from the system.

➍ When all the task is done, update the packages by writing this code:

sudo apt update
  • update: Updates all the packages in Linux.

updating packages as well as keys

All the packages and keys have been updated now.

Case 02: Removing Apt-Key Using the “key_ID”

Using key_ID is the easiest way to remove the apt-key. It is the key identification number which is the last 8 characters of the key fingerprint. Hence, it is simpler and more user-friendly ways than using the long 10-block fingerprint. In order to do this process, check the steps below:

Steps to Follow >

➊ Open the Ubuntu terminal.

Check the key list by following Step 02 Case 01 under Method 01.

➋ Afterward, select the key_ID and run the following command to remove it:

sudo apt-key del EFE21092
  • EFE21092: Key_ID.

removing apt key using key_ID

When you type your Ubuntu password, the key will be removed.

After deleting the key, update the packages by following Steps 04 Case 01 under Method 01.

➌ You can check the key list again to verify that the selected key has been removed successfully.

Now run this code to check that:

sudo apt-key list

checking whether the apt key is removed

You can notice in this image that the key is no longer here.

Method 02: Removing Apt-key Directly From the Keyring File

The apt keys are stored in the keyring file. You can find the keyring file in the /etc/apt/trusted.gpg.d location in Ubuntu. After finding the file, you can manually remove the file to remove the apt-key. Here are the steps:

Steps to Follow >

➊ Open the Ubuntu terminal.

➋ Find the keyring file by executing this command:

ls /etc/apt/trusted.gpg.d/
  • ls /etc/apt/trusted.gpg.d/: Lists the keys stored in the /etc/apt/trusted.gpg.d location.

finding the apt key

In this picture, you can see the list of key files in the /etc/apt/trusted.gpg.d/ directory.

➌ Write the following code to remove the key:

sudo rm /etc/apt/trusted.gpg.d/ubuntu-keyring-2018-archive.gpg
  • rm: Command to remove files, directories, and links.
  • /etc/apt/trusted.gpg.d/ubuntu-keyring-2018-archive.gpg: Location of the key file named ‘ubuntu-keyring-2018-archive.gpg’.

removing apt key from keyfile

After running this command, the key file will be removed from your system.

Now, follow Steps 04 Case 01 under Method 01 to update the packages.

➍ To verify the removal of the apt-key, now run this command:

ls /etc/apt/trusted.gpg.d/

checking if the key is removed

You can notice that the key file is successfully deleted from the Linux system.

Method 03: Removing Apt-key Using GUI

Don’t worry if you find it difficult to run code in the terminal. Use this GUI (Graphical User Interface) based approach to complete the removal procedure with just some clicks. Check the steps carefully:

Steps to Follow >

➊ Click ‘Show Applications’ and open ‘Software & Updates’.

opening software updates by clicking 'show applications'

➋ Go to the ‘Authentication’ tab of the ‘Software & Updates’ to check the key. Select the key and click the ‘remove’ option.

removing keyfile by clicking remove option

As soon as you click the remove button, an authentication window will come up.

authentication is needed to remove the keyfile

Type your Ubuntu password and click ‘Authenticate’ to remove the key successfully.

no key is here

Now, you can notice that there is no key. So finally, you are done with the removal procedure.

Comparative Analysis of Methods to Remove Apt-key in Linux

Here, I will explain to you the advantages and disadvantages that each method provides to remove the apt-key in Linux. To find your best pick, go through this table:

Methods Pros Cons
Method 1
  • Provides a straightforward way to remove apt-key.
  • Offers automatic updates.
  • Deprecated in the latest version of Ubuntu.
  • Less control over the key management.
Method 2
  • Direct control over the keys.
  • Much secure.
  • Irreversible method.
  • Manual procedure.
Method 3
  • Less prone to typing mistakes.
  • User-friendly and convenient.
  • Offers limited function.
  • May create security issues.

I hope this table helps you find your best approach to remove the apt-key. If you feel any difficulty understanding the command-based approach, go for method 3. Otherwise, method 2 is great to use. If you are afraid of irreversible methods then pick method 1.


I sincerely hope that this guide aids you in removing the apt-key you intended to do so. Here, 3 approaches have been explored step-by-step. apt-key command is used to manage the keys used by the advanced package tool. Two practical cases involving apt-key (key_ID and key fingerprint) have been described. Additionally, you have the option of deleting the key right from the keyring file. Last but not least, after deleting the key, remember to update the packages. Good luck!

People Also Ask

How do I remove apt-key and repository?
In order to remove a repository using Ubuntu’s old apt-key command, you must first find the keyring file containing the repository’s key and then use the rm command to remove that file.
How to remove repository list in Linux?
To remove the repository list in Linux, run this code with sudo privileges: ‘sudo rm /etc/apt/sources.list.d/<Repo_Filename>.list’.
How to remove a specific repository using apt?
In Ubuntu to remove a specific repository using apt, you will need the repository name then run this code in the terminal ‘sudo add-apt-repository –remove ppa:<PPA_NAME>’.
What is apt-key in Linux?
Apt-key is the command-line tool used to manage authentication keys used by the apt package manager to authenticate software packages downloaded from the repositories. It works like a digital signature.

Related Articles

<< Go Back to Uninstall Packages in Linux | Package Management in Linux | Learn Linux Basics

5/5 - (10 votes)
Mitu Akter Mou

Hello, This is Mitu Akter Mou, currently working as a Linux Content Developer Executive at SOFTEKO for the Linuxsimply project. I hold a bachelor's degree in Biomedical Engineering from Khulna University of Engineering & Technology (KUET). Experiencing new stuff and gathering insights from them seems very happening to me. My goal here is to simplify the life of Linux users by making creative articles, blogs, and video content for all of them. Read Full Bio

Leave a Comment