Operating System - HP-UX
1834930 Members
2706 Online
110071 Solutions
New Discussion

Re: Script to change permission.

 
SOLVED
Go to solution
ben_43
Frequent Advisor

Script to change permission.

As a user how do i change all the files and directories under my home directory to 644 and 755 respectively with one command?

Thanks
Ben.
6 REPLIES 6
Bill McNAMARA_1
Honored Contributor
Solution

Re: Script to change permission.

with the -R option of chmod.

Later,
Bill
It works for me (tm)
Pete Randall
Outstanding Contributor

Re: Script to change permission.

Or use find (i.e. find . -type d -exec chmod 755 {} \;)

Pete

Pete
Pete Randall
Outstanding Contributor

Re: Script to change permission.

and "find . -type f -exec chmod 644 {} \;"

Pete

Pete
ben_43
Frequent Advisor

Re: Script to change permission.

Thanks.
Ben
Pete Randall
Outstanding Contributor

Re: Script to change permission.

Or find with xargs (i.e. find . -type f -print | xargs chmod 644) to avoid spawning a separate process for each.

Pete

Pete
Rory R Hammond
Trusted Contributor

Re: Script to change permission.

If you wanted to find all of the 644 files and change them to 755 you could
find /home/ben -perm -644 -exec chmod 755 {} \;

Using find this way would avoid changing permission on thing in your path that you might not want people to see
like /home/ben/sercret that had permission of 600.

All of the other examples didn't seem to address this issues

rory
There are a 100 ways to do things and 97 of them are right