On Ubuntu install with:
apt-get install gnupg
First generate private and public key:
Generating this key can take some time, because it needs enough randomness.
Store your public key in a file:
gpg -a --export
Although it is not necessary to store this public key, you usually will provide this public key to other people, see for example my public key.
Import public keys from other people by
gpg --import my-friend.pub
Now encrypt a message for my-friend:
gpg -aesr my-friend your-file
These options have the following effect:
-a: create base64 encoded output (“ASCII armored”). This is not necessary, so you can skip this option. If skipped the output is binary.
-s: add signature. This is not necessary. You could drop this option from above.
-r: recipient, here your-friend
Decrypting a file is the easiest part. Just type