FUNDAMENTALS A Complete Guide for Beginners
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:
[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.
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.
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.
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.
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.
➋ Afterward, select the key_ID and run the following command to remove it:
sudo apt-key del EFE21092
- EFE21092: Key_ID.
When you type your Ubuntu password, the key will be removed.
➌ 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
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.
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’.
After running this command, the key file will be removed from your system.
➍ To verify the removal of the apt-key, now run this command:
ls /etc/apt/trusted.gpg.d/
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’.
➋ Go to the ‘Authentication’ tab of the ‘Software & Updates’ to check the key. Select the key and click the ‘remove’ option.
As soon as you click the remove button, an authentication window will come up.
Type your Ubuntu password and click ‘Authenticate’ to remove the key successfully.
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 |
|
|
Method 2 |
|
|
Method 3 |
|
|
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.
Conclusion
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
Related Articles
- How to Uninstall RPM in Linux [2 Simple Cases]
- How to Uninstall a YUM Package [2 User-Friendly Cases]
- How to Remove a Specific Version Using YUM [2 Easy Methods]
- How to Force Remove a Package Without Dependencies Using Yum [2 Methods]
- How to Remove and Purge a Package Using apt-get [4 Methods]
- How to Remove Package and Dependencies Using dpkg [4 Cases]
<< Go Back to Uninstall Packages in Linux | Package Management in Linux | Learn Linux Basics