The sources for my code all belong to the unix group group1:
> ls -l *c
-rw-r--r-- 1 user1 group1 4976 Nov 9 13:42 commands.c
-rw-r--r-- 1 user1 group1 2347 Nov 9 13:42 env_list.c
-rw-r--r-- 1 user1 group1 2468 Nov 9 13:42 job_list.c
-rw-r--r-- 1 user1 group1 4453 Nov 9 13:42 jobs.c
-rw-r--r-- 1 user1 group1 3278 Nov 9 13:42 smash.c
-rw-r--r-- 1 user1 group1 2151 Nov 9 13:42 variable.c
gcc belongs to group2:
> ls -l gcc
-rwxrwsr-x 1 toolsusr group2 72 Dec 30 2008 /usr/intel/pkgs/gcc/4.3.2/bin//gcc
For some reason, when I compile, all of the targets are marked as belonging to group2. However, when I compile a similar project, the targets remain under group1.
How can I control the group (and while I’m at it, any other permissions) of the generated files?
I am using gcc 4.3.2 and this version of Linux: x86-64_linux_2.6.5_ImageSLES9SP3-3
Take a look at the stick bit of the directory you are compiling in. If set, it will make all of the files written to that directory have the same group of the directory itself. If it is not set, they will have the default group of the user who is writing the file (the user who ran gcc).
You can use
to add the sticky bit to a directory.
Comment:
It’s not the sticky bit, but rather the setguid bit: