Skip to content

Instantly share code, notes, and snippets.

@oseme-techguy
Last active February 6, 2025 05:53
Show Gist options
  • Save oseme-techguy/bae2e309c084d93b75a9b25f49718f85 to your computer and use it in GitHub Desktop.
Save oseme-techguy/bae2e309c084d93b75a9b25f49718f85 to your computer and use it in GitHub Desktop.
This fixes the " gpg: WARNING: unsafe permissions on homedir '/home/path/to/user/.gnupg' " error while using Gnupg .
#!/usr/bin/env bash
# To fix the " gpg: WARNING: unsafe permissions on homedir '/home/path/to/user/.gnupg' " error
# Make sure that the .gnupg directory and its contents is accessibile by your user.
chown -R $(whoami) ~/.gnupg/
# Also correct the permissions and access rights on the directory
chmod 600 ~/.gnupg/*
chmod 700 ~/.gnupg
@kankaristo
Copy link

I'm still learning Linux; what is it "go=" in

chmod -R go= ~/.gnupg/

mean?

Unix/Linux file permissions have rights for the user, group, and other. A file is owned by a user and a group, and you can set read, write and execute permissions for the owning user, group, and all other users.

chmod uses u, g, and o as shorthand for "user", "group" and "other" respectively. You can also use a for all users.

Some examples:

  • u=rw sets the permissions to read and write (and removes the execute permission) for the user
  • g+x adds the execute permission for the group, bur doesn't change the other permissions (resd and write stay unchanged)
  • o-w removes the write permission for other users, but doesn't change read and execute permissions
  • a+X adds the execute permission for all users, but only for directories (nor for files); very useful when recursively setting permissions with -R (the execute permission for a directory is needed to be able to list files)

So, go= sets the group and other permissions to an empty list for the group and other users. In other words, it removes all permissions for the group and other users. You could also use go-rwx (a bit more descriptive, but longer).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment