1825805 Members
2182 Online
109687 Solutions
New Discussion

chmod for SGID

 
SOLVED
Go to solution
Chern Jian Leaw
Regular Advisor

chmod for SGID

Hi,

I have a filesystem which traverses deep down the hierarchy i.e as follows:
/cpu/processor/doc/proj1/tmp/layout/design

I would like to remove the SGID for all files only, and not directories in this filesystem.

I would like the files to have the following permission settings:
rwxr-xr-x
and not rwxr-sr-x

I did the following:

find . -type -f -exec chmod g-s {} \;

However, the files still have the SGID bit set i.e :
rwxr-sr-x
and some files which were having:
rwxr-xr-x
have now been changed to rwxr--r--

Could somone help me out?
Thanks.
10 REPLIES 10
Devbinder Singh Marway
Valued Contributor

Re: chmod for SGID

where you got chmod g-s try chmod 755
Seek and you shall find
Daimian Woznick
Trusted Contributor

Re: chmod for SGID

In the command above you placed a -f after type. It is not supposed to have a - in front of the f. Sorry if it was a typo.

Also you may want to limit the search to only SGID files. This will limit any messups. Use the perm option with the 2000 permission.

Hope this helps.
Chern Jian Leaw
Regular Advisor

Re: chmod for SGID

Daimian,

Could you tell me how I should use the use the perm opt with 2000 permission?

Could you show me how I could limit the search to just the SGID files?

I'm really in a hurry to get this task done.

Appreciate it if you could help me out.
Andreas Voss
Honored Contributor
Solution

Re: chmod for SGID

Hi,

to find SGID files do:

find . -type f -perm -2000

Regards
jean-yves poch
Advisor

Re: chmod for SGID


for the next time, type :

find . -type f -perm 2755 -exec chmod g-s {} \;

2755 = rwxr-sr-x

for fix your problem type :

find . -type f -perm 745 -exec chmod g+x {} \;
find . -type f -perm 744 -exec chmod g+x {} \;

745 = rwxr--r-x
744 = rwxr--r--

for a file with rigth rwxr-xr-x, the command
chmod g-s give the result rwxr--r-x

for test before execute chmod, type :

find . -type f -perm 745 -exec ls -l {} \;

Good luck

Jean-Yves
pitstop
Chern Jian Leaw
Regular Advisor

Re: chmod for SGID

Andreas,

I did :
find . -type f -perm -2000 -exec chmod 755 {} \;

But it did not work. I need to have the permission mode set to 755 i.e rwxr-xr-x

Could you help me out?
Thanks.
Daimian Woznick
Trusted Contributor

Re: chmod for SGID

The command:

find . -type f -perm -2000 -exec chmod 755 {} \;

will take all the files with the SGID permission set and change the permissions to 755. You may want to use the find with the permission setting 0744 and chmod to 755.

Hope this helps.
T G Manikandan
Honored Contributor

Re: chmod for SGID

#find . -type f -exec chmod 0755{}\;

else
#find . -type f -perm -2000 -exec chmod 0755 {] \;


Make sure that you are in the proper directory.

find . will show only the current directory.
find ./ will traverse directories beneath.

Thanks
T G Manikandan
Honored Contributor

Re: chmod for SGID

sorry

find .
also changes the directories beneath.

Chern Jian Leaw
Regular Advisor

Re: chmod for SGID

HI,

I've tried all the options provided, however, SOME files in SOME directories still have the permissions set to :
rwxr-Sr-x

I really do not understand why aren't all files have the SGID removed.

Unless I do it manually as
#chmod g-s filename
only then it works for some files.

I really do not understand the problem in my script which is causing this problem for some files.

Could someone help me out?
Thanks.