Operating System - HP-UX
1839233 Members
2903 Online
110137 Solutions
New Discussion

Changing File Permissions

 
SOLVED
Go to solution
Sanjay Verma
Super Advisor

Changing File Permissions

Hi Friends,
I would like to change the file permissions for several files under a specific directory and it's sub / sub-sub directory.

Will appreciate if you can let me know the best way to do this.
Co-operation - The biggest chain reaction
8 REPLIES 8
Karthik S S
Honored Contributor
Solution

Re: Changing File Permissions

Hi,

chmod -R nnnn /dir

ex: chmod -R 0777 /test


Regards,
karthik
For a list of all the ways technology has failed to improve the quality of life, please press three. - Alice Kahn
Michael Tully
Honored Contributor

Re: Changing File Permissions

If you have a file list this can be done quite easily. e.g.

# for i in `cat filelist`
> do
> chmod 555 $i
> done

or using find

# find /mydir -name "file string" | xargs chmod 555

# find /mydir -xdev -type f -perm 666 | xargs chmod 644

It really depends on the files ...
Anyone for a Mutiny ?
twang
Honored Contributor

Re: Changing File Permissions

Change permissions of specific directory recursively:
# chmod -R 505
Change owner of specific directory recursively:
# chown -R user:group
yogesh_4
Regular Advisor

Re: Changing File Permissions

hi ,
# chmod -R xxx dir-name shd slove your problem . xxx indicats file permition which you want to assign.
Sanjay Verma
Super Advisor

Re: Changing File Permissions

I appreciate for all your excellent and quick response. -Sanjay
Co-operation - The biggest chain reaction
Sanjay Verma
Super Advisor

Re: Changing File Permissions

Michael,
I liked the command -
find /mydir -xdev -type f -perm 666 | xargs chmod 644
As I understand about xdev and xargs clearly using the man, but could you pl. explain this in your term?




Co-operation - The biggest chain reaction
V. Nyga
Honored Contributor

Re: Changing File Permissions

Hi Sanjay,

one more tip (you can refer it with 'man chmod'):
-R is recursively for directories and files, so you have to include the x-option (execute) for the dirs.
If you don't want this you can use:
chmod -R g+w /dir
So the permission of group is changed (w is added) for /dis, all sub-dirs and files.
Equal: u for owner, o for world/others
and '-' for permission is deleted.

Regards
Volkmar
*** Say 'Thanks' with Kudos ***
Vitaly Karasik_1
Honored Contributor

Re: Changing File Permissions

by using "xdev" you tell to "find" to stay in current filesystem - usually you use it when you start your search from "/" and don't want to find in your "/var" partition.

Vitaly