List GPG keys with gpg --list-keys
In this step, you will learn how to list GPG keys using the gpg --list-keys
command. GPG (GNU Privacy Guard) is a powerful tool for encrypting and signing data. Keys are fundamental to GPG, acting as your digital identity.
Before we list keys, let's make sure the GPG directory exists. The default location for GPG files is ~/.gnupg
.
Open your terminal if it's not already open. You can do this by clicking the Xfce Terminal icon on the left side of the desktop.
Now, let's check if the ~/.gnupg
directory exists using the ls
command. ls
lists files and directories.
Type the following command and press Enter:
ls ~/.gnupg
You might see output similar to this:
openpgp-revocs.d private-keys-v1.d pubring.kbx pubring.kbx~ trustdb.gpg
This output shows the contents of the ~/.gnupg
directory, indicating it exists and contains some default GPG files. If you see an error like "No such file or directory", it means the directory doesn't exist yet. Don't worry, GPG will create it when needed.
Now, let's list the GPG keys. We'll use the gpg --list-keys
command.
Type the following command and press Enter:
gpg --list-keys
If you haven't generated any keys yet, the output will be empty or show a message indicating no keys are found. This is expected if this is your first time using GPG.
gpg: keybox '/home/labex/.gnupg/pubring.kbx' created
If you had keys, the output would look something like this (details will vary):
/home/labex/.gnupg/pubring.kbx
------------------------------
pub rsa2048 2023-01-01 [SC]
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
uid [ultimate] Your Name <[email protected]>
sub rsa2048 2023-01-01 [E]
This output provides information about your public keys, including the key type, creation date, key ID, and the user ID associated with the key.
Understanding how to list keys is the first step in managing your GPG identities.
Click Continue to proceed to the next step.