On most Linuxes, at least as the out of the box default, a user's primary group is the same as their username, so this wouldn't be a problem since the group ownership of a new file would be for a group that no one will ever be in.
When servers are configured for new users to have a primary group that is shared, then we have the umask
environmental variable to prevent any problems. This is what sets the default permissions of new files, and can be set per user. So user A might set his umask
to 077, and then any new files he creates will have permissons of 700, meaning group members won't be able to do anything with it.
To expand on this a little, your umask is normally set as part of your initialization script - that is, the scripts that run when you log into a user account. You have two sets - your global profile script, which is most commonly /etc/profile
or /etc/bashrc
, and your local, which are stored under your home directory as .bashrc
or .profile
(the actual scripts used depend on your shell, these are just common for bash). When you log in, the relevant global script runs first, then the local script runs, and can override anything done by the global. So under .bashrc
(or equivalent) you would simply have to append to the script, umask 077
to set the value to 077. You can also just run umask 077
to set the umask for the current session only.