Knowledge base dedicated to Linux and applied mathematics.
Home > Linux > Tip of the day > How to encrypt/decrypt a file or directory in Linux?
All the versions of this article: <English> <français>
To encrypt a file:
$ gpg -c filename
To decrypt a file:
$ gpg filename.gpg
To encrypt a directory:
$ gpg-zip -c -o dirname.gpg dirname
To decrypt a directory:
$ gpg-zip -d dirname.gpg
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/