Encryption, explained without the jargon
GnuPG (GNU Privacy Guard) is a free tool that can encrypt files and verify digital signatures. Here we use symmetric encryption: one strong passphrase protects a file and is required to unlock it. Later you can explore public-key encryption for exchanging files with other people.
Protecting your own legal documents, creative work, research notes, or backup copies — starting with a harmless sample text file.
Encryption is not anonymity, a replacement for backups, or a way to make unlawful material lawful. The source file remains unencrypted unless you separately manage it. A forgotten passphrase may mean permanent loss of access.
Check GnuPG
Make sure the tool is available before you begin.
command -v gpg
gpg --versionOn a typical full Slackware 15.0 installation, GnuPG is already present. If the command is missing, check that the gnupg package is installed. No root access is needed for the rest of this tutorial.
Make a safe practice folder
We’ll work in a fresh directory with a harmless demonstration note.
mkdir -p "$HOME/darkpc-gpg-lab"
cd "$HOME/darkpc-gpg-lab"
printf "Hello from DarkPC!\n" > sample-note.txt
cat sample-note.txtAll following commands assume that you remain inside ~/darkpc-gpg-lab. We use a simple sample note, not real private information.
Encrypt your first file
Give GnuPG a file and a strong passphrase.
gpg --symmetric --cipher-algo AES256 --output sample-note.txt.gpg sample-note.txtGnuPG will ask for a passphrase through a terminal or pinentry dialog. Choose a long, unique passphrase. Do not type it directly into a shell command or post it in screenshots.
ls -lh sample-note.txt*You should see both the original sample-note.txt and an encrypted sample-note.txt.gpg. GnuPG does not automatically remove the original.
Restore and verify
Learn to decrypt safely without overwriting your original.
gpg --output restored-note.txt --decrypt sample-note.txt.gpgEnter your passphrase if requested. GnuPG may temporarily cache it in gpg-agent, so a repeated command may not prompt again.
cmp sample-note.txt restored-note.txt && echo "Success: the files match"If the files are identical, cmp prints nothing, followed by the success message from echo. This checks our practice workflow without changing the originals.
What about several files?
GnuPG encrypts file contents; you can bundle multiple files into an archive first.
tar -czf sample-archive.tar.gz sample-note.txt
gpg --symmetric --cipher-algo AES256 --output sample-archive.tar.gz.gpg sample-archive.tar.gzAn encrypted archive can contain several files, but the unencrypted .tar.gz is still on disk. For this exercise, leave it in the practice folder so you can inspect how the process works.
gpg --output recovered-archive.tar.gz --decrypt sample-archive.tar.gz.gpg
tar -tzf recovered-archive.tar.gzThe last command lists archive contents without extracting them. For real documents, choose a safe extraction location and inspect filenames first.
If something doesn't work
“gpg: command not found”
Check the installed GnuPG package and your PATH. A full Slackware installation normally includes it. Ask an administrator before installing packages on shared machines.
No passphrase prompt on a text console?
GnuPG 2 uses gpg-agent and a pinentry program. On a local terminal you can try the command below, then repeat the encryption command. If your setup lacks a console pinentry program, install/configure a compatible one using trusted Slackware packages.
export GPG_TTY="$(tty)"This only sets a session environment variable; it does not change the file or disable passphrase protection.
Decrypt command prints a warning about cached passwords
GnuPG may cache a passphrase briefly in its agent. Do not assume another command will always require you to type the passphrase again. Lock your account when stepping away.
“File exists” when restoring
Choose a new output filename. Avoid overwriting your original documents. Do not add --yes just to silence a safety prompt.
Five habits worth keeping
- Practise on copies and harmless sample files first.
- Use a long, unique passphrase and keep a secure recovery plan.
- Verify decryption before relying on an encrypted backup.
- Remember that originals and unencrypted archives remain readable.
- Keep your Slackware system and GnuPG packages updated.
You made and recovered an encrypted file without changing system settings. That's one more useful Unix skill in your toolkit. 🦍