Operating System - HP-UX
1748159 Members
3766 Online
108758 Solutions
New Discussion юеВ

Re: How can I change the permissions only for files/directories

 
SOLVED
Go to solution
bullz
Super Advisor

How can I change the permissions only for files/directories

Hello Guruz

Note: Points will given without fail

1) How can I change the permissions only for files/directories
5 REPLIES 5
TTr
Honored Contributor

Re: How can I change the permissions only for files/directories

> ...only for files/directories

As opposed to what? Unless I am missing something here, the chmod command is used to change the permissions for user owner, group owner or other users. The man page for chmod has a lot of good details, no need to reinvent the wheel here.
James R. Ferguson
Acclaimed Contributor

Re: How can I change the permissions only for files/directories

Hi:

> only for files/directories

What do you mean? All files and subdirectories beneath a starting directory? Only regular files and not subdirectories beneath a starting directory? The permissions of things like symbolic links don't matter and changing them changes the permissions of the object to which they point.

Regards!

...JRF...
Matti_Kurkela
Honored Contributor
Solution

Re: How can I change the permissions only for files/directories

Files only:

find * -prune -type f | xargs chmod 644
or
find * -prune -type f -exec chmod 644 \+

Directories only:

find * -prune -type d | xargs chmod 755
or
find * -prune -type d -exec chmod 755 \+

If you want to process all the sub-directories of the current directory (changing all files in sub-directories or all sub-directories), just remove the -prune option.

Old HP-UX versions may not understand "-exec \+" option, but the version with xargs should work with them too. However, the xargs version will have problems if the filename contains spaces or other special characters.

MK
MK
bullz
Super Advisor

Re: How can I change the permissions only for files/directories

It worked with below one.
Thanx all those who replied.

Files
------
find . -type f -exec chmod 700 {} \;
Direc
------
find . -type f -exec chmod 700 {} \;
bullz
Super Advisor

Re: How can I change the permissions only for files/directories

Cool