?
Solved

Keep OWNER of a new file/directory

Posted on 2011-09-19
2
Medium Priority
?
568 Views
Last Modified: 2012-06-21
Hey Guys!

I need to keep ownership of new files or directories created by any user.

Example:
I have:
drwxr-xr-x 2 apache apache 1 Sep 19 11:17 /var/www/htdocs/website/

So, I need that when any user creates a new file or directory that inherit owner and group.

The group I resolved by setting sgid, so the group is inherit but the OWNER I dont know.

I do not like to create a shellscript and run it every 5 minutes thru crontad. It's a poor solution...

Some hint?
0
Comment
Question by:tbsoares
2 Comments
 
LVL 21

Expert Comment

by:Papertrip
ID: 36560769
using chown in a script is the only way to accomplish this in Linux.  setuid is ignored on directories.
0
 
LVL 38

Accepted Solution

by:
wesly_chen earned 2000 total points
ID: 36570707
You can change the group permission to "writeable" then "apache" daemon can manipulate the files without be the owner of that files.

Just make sure all the user have
umask 002
  in there ~/.bashrc, ~/.profile or ~/.cshrc  file
   So all the the created files are group writeable.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Fine Tune your automatic Updates for Ubuntu / Debian
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses
Course of the Month13 days, 11 hours left to enroll

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question