- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to encrypt and decrypt a file using gpg command on linux
There are many choices on hand to secure your data. However, GPG provides the additional benefit to encrypting your data on a priority basis and transfers them securely over the internet. This article explains about – How to Encrypt and Decrypt a file using GPG command on Linux.
To get more information about GPG, use the following command –
$ gpg -h
The sample output should be like this –
gpg (GnuPG) 1.4.20 Copyright (C) 2015 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Home: ~/.gnupg Supported algorithms: Pubkey: RSA, RSA-E, RSA-S, ELG-E, DSA Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH, CAMELLIA128, CAMELLIA192, CAMELLIA256 Hash: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224 Compression: Uncompressed, ZIP, ZLIB, BZIP2 Syntax: gpg [options] [files] Sign, check, encrypt or decrypt Default operation depends on the input data Commands: -s, --sign [file] make a signature --clearsign [file] make a clear text signature -b, --detach-sign make a detached signature -e, --encrypt encrypt data -c, --symmetric encryption only with symmetric cipher -d, --decrypt decrypt data (default) --verify verify a signature --list-keys list keys --list-sigs list keys and signatures --check-sigs list and check key signatures --fingerprint list keys and fingerprints -K, --list-secret-keys list secret keys --gen-key generate a new key pair --delete-keys remove keys from the public keyring --delete-secret-keys remove keys from the secret keyring --sign-key sign a key --lsign-key sign a key locally --edit-key sign or edit a key --gen-revoke generate a revocation certificate --export export keys --send-keys export keys to a key server --recv-keys import keys from a key server --search-keys search for keys on a key server --refresh-keys update all keys from a keyserver --import import/merge keys --card-status print the card status --card-edit change data on a card --change-pin change a card's PIN --update-trustdb update the trust database --print-md algo [files] print message digests ...............................................................................
While encrypting and decrypting a file, it will ask to Enter passphrase(password) and Repeat passphrase to secure a file
Encrypt a File using GPG
To encrypt a file using GPG, please use the command as shown below –
$ gpg -c abc.txt
In the above command, it is encrypting abc.txt file. To verify it, use the following command –
The sample output should be like this –
abc.txt Final_Url_Weight.csv site_health_depth5.txt abc.txt.gpg FINAL_URL_WEIGHT.db tp_Crawled_few.txt check_ageof_site.py final_url_weight.py extracting_keywors.py final_url_weight_sqlite.py
Decrypt a File using GPG
To decrypt the above file, use the following command –
$ gpg -o abc.txt -d abc.txt.gpg gpg: AES encrypted data Enter passphrase:
Above the command de-crypts the file and stores in same directory.
In the above article, we have learnt – Learn how to Encrypt and Decrypt a file using GPG command on Linux. In our next articles, we will come up with more Linux based tricks and tips. Keep reading!
- Encrypt and Decrypt a string in MySQL?
- How to encrypt and decrypt data in Python
- Encrypt and Decrypt Data in NodeJS
- How to get only the file name using find command on Linux?
- How to Install a Software on Linux Using Yum Command?
- How to Save Command Output to a File in Linux?
- How to send a file as an email attachment using the Linux command line?
- How to grep and replace a word in a file on Linux?
- 10 Netstat Command Examples on Linux
- How to create a CPU spike with bash command on Linux?
- The best way to compress and extract files using the tar command on linux
- How to get hardware information with dmidecode command on linux
- How to replace spaces in file names using bash script on Linux?
- How to resume a partially transferred file over ssh on Linux?
- How to read a file from command line using Python?