0

is there any way to achieve that every created file inside student's directory will have owner student (chown student ./* is for all old files, but I want new files to be chown student).... By the way I have a Perl and Python on this Server so if there can be some simple script that will check the creating of the file and changes it's owner hmm?

  • you can set a default primary group with chmod g+s directoryName and use POSIX ACL's to give certain users and groups given amounts of access on files/directories within a given directory. If you need to coerce the file owner for some reason (discretionary access controls or quotas probably) then you're probably stuck running a find command in a cronjob or something. – Bratchley Jul 13 '16 at 15:05
1

You could use this

find /folder -not -uid 1050 -exec chown student:studentgroup {} +

means that student have user ID 1050. To get the uid you can use command

id -u username
  • Use -user student instead of -uid 1050. – Satō Katsura Jul 13 '16 at 15:15
  • How to undo this command? i just screw up the access to that folder, noone can access it from remote PC... – Juraj Carnogursky Jul 13 '16 at 15:16
  • You could change access to the folder using chown user:group foldername. It will not change the owners of the files into, but restore the owner and group of the folder. – Konstantin Morenko Jul 13 '16 at 15:20
  • ok so I know what's the problem. the problem is that the folder can have either owner teacher or student... It can be either accessed by the teacher or student... is it possible to make it to be accessed by both the teacher and the student? – Juraj Carnogursky Jul 13 '16 at 15:26
  • You could set permission to read and write for: owner, group of owner and other users, to set read and write permission for everyone user use chmod a+rw foldername. But every user could read and write this folder. – Konstantin Morenko Jul 13 '16 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.