Math-Linux.com

Knowledge base dedicated to Linux and applied mathematics.

Home > Linux > Tip of the day > How to encrypt/decrypt a file or directory in Linux?

How to encrypt/decrypt a file or directory in Linux?

All the versions of this article: [English] [français]

encrypt/decrypt file

To encrypt a file:

$ gpg -c filename

To decrypt a file:

$ gpg filename.gpg

encrypt/decrypt directory

To encrypt a directory:

$ gpg-zip -c -o dirname.gpg dirname

To decrypt a directory:

$ gpg-zip -d dirname.gpg

Possible errors

If you see this error below:
can’t connect to `/home/user/.gnupg/S.gpg-agent’: No such file or directory

Then launch gpg agent daemon:

$ gpg-agent --daemon
GPG_AGENT_INFO=/tmp/gpg-Y1AjlZ/S.gpg-agent:2523:1; export GPG_AGENT_INFO;

then you’ll just have to create a symbolic link:

$ cp -fs /tmp/gpg-Y1AjlZ/S.gpg-agent ~/.gnupg/

Any message or comments?

comments powered by Disqus