Forrest logo
back to the gpg2 tool

gpg2:tldr:dbe3f

gpg2: Encrypt a specified file for a specified recipient, writing the output to a new file with `.gpg` appended.
$ gpg2 --encrypt --recipient ${alice@example-com} ${path-to-doc-txt}
try on your machine

This command uses GPG (GNU Privacy Guard) to encrypt a file using public-key cryptography. Let's break down the command:

  • gpg2: This is the command to invoke the GPG utility.

  • --encrypt: This option tells GPG that we want to encrypt the file.

  • --recipient ${alice@example-com}: This option specifies the recipient's public key to use for encryption. In this case, the recipient's email address is ${alice@example-com}.

  • ${path-to-doc-txt}: This is the file path of the document (in this case, doc.txt) that you want to encrypt. Note that you need to replace ${path-to-doc-txt} with the actual path to the file on your system.

To summarize, the command gpg2 --encrypt --recipient ${alice@example-com} ${path-to-doc-txt} encrypts the specified document file (doc.txt) using GPG and the public key of the recipient specified by their email address.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the gpg2 tool