LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 04-17-2006, 08:47 AM   #1
dickohead
Member
 
Registered: Feb 2003
Location: Melbourne, VIC, Australia
Distribution: Ubuntu 6.06
Posts: 101

Rep: Reputation: 15
Setting default permissions for folder


Good evening,

After playing with umask, chmod and chgrp for about an hour and half I have finally given up and am asking for some help.

This is what I have:

/var/www/* owned by www-data, group set to tim and permissions set to 775
or:
drwxrwxr-x www-data tim www


Now when I create a directory under /var/www/ say images, it gets the following permissions:

/var/www/images/* owned by tim, group set to tim and permissions set to 755
or:
drwxr-xr-x tim tim images

I then create a file in the /var/www directory, say index.php, it gets the following permissions:

/var/www/index.php owned by tim, group set to tim, permissions set to 644
or:
-rw-r--r-- tim tim index.php

How do I FORCE the directory of /var/www so that ANYTHING (file or folder) created underneath it by anyone of any group or any username is set to:

owned by www-data, group set to tim, permissions set to 775
drwxrwxr-x

Setting the umask won't cut it because that does every file and only sets permissions not users and groups.....

Surely there has to be someway to specify the default user and group for files under a folder as well as their permissions...?

Last edited by dickohead; 04-17-2006 at 08:48 AM.
 
Old 04-17-2006, 09:55 AM   #2
futhark
Member
 
Registered: Nov 2003
Location: Montréal (Can)
Distribution: FC4
Posts: 110

Rep: Reputation: 15
Quote:
Originally Posted by dickohead
Surely there has to be someway to specify the default user and group for files under a folder as well as their permissions...?
If there is a way of doing that, I'd be happy to know about it. One way I know of setting perms is to use find. To take your case as an example:

cd /var/www
find html -type d -exec chmod 775 {} \+
find html -type f -exec chmod 664 {} \+

That changes permissions on all dirs under and including html to 775. File perms get changed to 664 (I don't advise putting exe perms on files when you don't need to).

Then to change ownership of all files under html:

chown -R tim.www-data html

Where "tim" is the user, "www-data" is the group, "html" is the directory.

Surely you can put these commands in an alias to automate the task.

alias wwwp="find /tmp/test -type d -exec chmod 775 {} \+ && find /tmp/test -type f -exec chmod 664 {} \+ && chown -R tim.www-data /tmp/test"

To build an alias like that, the trick is to write lines separately in an editor, to test them separately and then to combine them into an alias.

Cheers!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting Folder permissions Adriann Mandriva 2 02-15-2006 02:53 AM
newbie needs help setting folder permissions for new users J1015512 Ubuntu 1 10-15-2005 01:57 AM
Default permissions of files and folder maginotjr Slackware 2 07-29-2005 03:52 AM
default files and folder acl permissions Baltasar Fedora 4 08-30-2004 12:50 PM
setting up ftp for default web folder stasjohn Linux - Newbie 6 08-18-2004 07:47 AM


All times are GMT -5. The time now is 06:27 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration