LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   SUSE / openSUSE (https://www.linuxquestions.org/questions/suse-opensuse-60/)
-   -   chmod and symbolic links (https://www.linuxquestions.org/questions/suse-opensuse-60/chmod-and-symbolic-links-630770/)

vm_devadas 03-26-2008 08:55 AM

chmod and symbolic links
 
chmod -R in Solaris will change permissions on subdirs and when encountering a symbolic link, will change the permission on the pointed to file whether it be a file or just a directory and stop. c

hmod -R in SuSE seems to follow symbolic links through the whole directory structure.

Is this a bug in chmod?

tronayne 03-26-2008 09:03 AM

No, -R option "change files and directories recursively" (from the Linux manual page). The Solaris manual page "Recursively descend through directory arguments, setting the mode for each file as described above. When symbolic links are encountered, the mode of the target file is changed, but no recursion takes place."

Keep in mind that Solaris is, pretty much, System V and Linux is, pretty much, GNU (which stands for Gnu's not Unix). GNU utilities don't always work the same way Solaris' do.

vm_devadas 03-27-2008 05:58 AM

Don't care what happens to the symlink permissions. I know that the permissions should change to the pointed to file. But the permissions will continue to change for all files under the link and traverse any other symbolic links encountered.

If there is a Directory space called ABC and in this directory structure there is a symbolic link to /data/mydata for example, and when make chmod permissions for the project space ABC, it will follow the mydata link and change all the permissions on the mydata files

Is there any option to avoid this?

unSpawn 03-27-2008 06:27 AM

Quote:

Originally Posted by vm_devadas (Post 3101826)
Is there any option to avoid this?

Sure. Either don't recurse or use a find script to exclude some part of the tree.

tronayne 03-27-2008 06:32 AM

Well, that's what the -R option seems like it's supposed to do... I'm wondering of I'm reading it correctly that the --preserve-root (fail to operate recursively on `/') option may be what you want (given your example)?

Or, maybe using a combination of find with the -P option (never follow symbolic links), xargs and chmod? Something like
Code:

find -P <path> -type f -print | xargs chmod mode
It would take two passes, one with -type f for files and another with -type d for directories


All times are GMT -5. The time now is 12:59 AM.