Koozali.org: home of the SME Server

Changing file / directory permissions

Offline ReetP

  • *
  • 3,783
  • +5/-0
Changing file / directory permissions
« on: October 23, 2008, 01:25:46 PM »
A note to self.........

I was trying to change a set of file and directory permissions recursively and couldn't find out how to do it. I kept on getting syntax errors.

Anyway, here is what I got to work in the end :

Change permissions :

find ./ -type d -exec chmod 0755 {} \;
find ./ -type f -exec chmod 0644 {} \;

Change ownership

find ./ -type f -exec chown owner:group {} \;
find ./ -type d -exec chown owner:group {} \;

Hope this may help someone

John
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline Stefano

  • *
  • 10,850
  • +2/-0
Re: Changing file / directory permissions
« Reply #1 on: October 23, 2008, 02:58:46 PM »
A note to self.........

I was trying to change a set of file and directory permissions recursively and couldn't find out how to do it. I kept on getting syntax errors.


changing permissions recursively is not a good idea..

what are you trying to do?

Ciao
Stefano

Offline mmccarn

  • *
  • 2,635
  • +10/-0
Re: Changing file / directory permissions
« Reply #2 on: October 23, 2008, 03:00:11 PM »
While I don't know how to specify different permissions on files vs. directories as you are doing, you can apply file permissions recursively using:
Code: [Select]
chmod -R 0644 *
File ownership can be set recursively using:
Code: [Select]
chown -R user:group *


Offline ReetP

  • *
  • 3,783
  • +5/-0
Re: Changing file / directory permissions
« Reply #3 on: October 27, 2008, 12:09:14 PM »
Quote
While I don't know how to specify different permissions on files vs. directories as you are doing, you can apply file permissions recursively using:
Code: [Select]
chmod -R 0644 *
File ownership can be set recursively using:
Code: [Select]
chown -R user:group *


Yes thanks, I did know that but couldn't suss changing the directory permissions recursively


Quote
changing permissions recursively is not a good idea..

what are you trying to do?

I realised that. I am having a play with Unison file synch to synchronize various bits of data across two servers. I was trying to realign permissions across a range of directories so that they showed the same permissions pre-synch. Because of various historical issues, there are a lot of identical files with different permissions........

A couple of oddities arose :

One of my servers shows files/directories owned by 'user:local' and the other by 'user:shared'

Any one have any ideas about why this occurs ?

Second thing that cropped up was that my windows boxes suddenly started to read & write files as user:user so I must have screwed something somewhere.

I got out of it by going into server manager and changing the user-access to group/group and back to group/everyone

That seemed to sort it out.

Hmmm. Back to the drawing board !

I got out of it by changing the permissions on the ibays.

Thanks for the tips. Anything else gratefully appreciated !
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline ReetP

  • *
  • 3,783
  • +5/-0
Re: Changing file / directory permissions
« Reply #4 on: October 27, 2008, 01:19:19 PM »
As a matter of interest, what SHOULD the default file/directory permissions be ?

Are they listed anywhere ?

B. Rgds
John
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation