The gzip command itself does not support password protection directly. However, you can achieve password protection by first compressing the file with gzip and then encrypting it using a tool like gpg. Here’s how you can do it:
Compress the file with gzip:
gzip file.txtThis will create a compressed file named
file.txt.gz.Encrypt the gzip file using gpg:
gpg -c file.txt.gzThis command will prompt you to enter a password. It will create an encrypted file named
file.txt.gz.gpg.
To decrypt and unzip the file later, you would use:
Decrypt the file:
gpg file.txt.gz.gpgYou will be prompted to enter the password.
Unzip the decrypted file:
gunzip file.txt.gz
This process effectively password protects your gzip file.
