LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-27-2007, 05:08 PM   #1
amg_
LQ Newbie
 
Registered: Nov 2007
Location: louisiana
Posts: 2

Rep: Reputation: 0
creating directories with owner/permissions that stick


i have done this before when setting up squid but can not remember or find the command.
I would like to create directories with owners/permissions that stick. By that i mean:
mkdir /store
chown newowner /store
chmod 770 /store
mkdir /store/1
mkdir /store/2

is it possible (umask?)for /store/1 and /store/2 to end up with newowner and 770 during the mkdir process? Is there a command that will tell /store that every directory created under /store should have newowner and 770?

I have been lurking for a while and found this forum to be very helpful.

Thanks ahead.
 
Old 11-27-2007, 05:36 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,309

Rep: Reputation: 2744Reputation: 2744Reputation: 2744Reputation: 2744Reputation: 2744Reputation: 2744Reputation: 2744Reputation: 2744Reputation: 2744Reputation: 2744Reputation: 2744
Do the mkdirs first, the use the -R switch (recursive) on the chmod & chown cmd. Don't forget the grp owner eg
chown -R owner:grp somedir
 
Old 11-27-2007, 05:40 PM   #3
amg_
LQ Newbie
 
Registered: Nov 2007
Location: louisiana
Posts: 2

Original Poster
Rep: Reputation: 0
thanks for the quick response.

I was looking for something besides a recursive. I remember a swith or a sticky permission of some sort that would say that anything under that certain directory would inherit permissions and owner from the parent.

thanks anyway.
 
Old 11-28-2007, 12:02 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,309

Rep: Reputation: 2744Reputation: 2744Reputation: 2744Reputation: 2744Reputation: 2744Reputation: 2744Reputation: 2744Reputation: 2744Reputation: 2744Reputation: 2744Reputation: 2744
Sounds like your confusing it with the 'sticky' bit. See section 6 here: http://www.zzee.com/solutions/unix-p...s.shtml#setuid
 
Old 11-28-2007, 12:11 AM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 681Reputation: 681Reputation: 681Reputation: 681Reputation: 681Reputation: 681
Yes. The owner of a directory can set the suid and sgid of the directory. Files created by other users will then inherit the owner and group of the parent directory. The permissions on a new file or directory will be masked according to your umask setting.

---
update:
I tried it out with a directory I created on in my home directory. I created it as root and gave it 7777 permissions. A file I created there as a regular user had the group ownership of root but not the ownership. A directory I created there had the group of root but I was the owner.
There may be a capability setting that doesn't allow suid on directories; and maybe there's a good reason why.
---
If you have a directory structure that you want to create, you could use brace expansion to do it, and then use chown and chmod recursively.

mkdir -p store/{1..10}
This will create directory "store" with ten subdirectories "1".."10".

Last edited by jschiwal; 11-28-2007 at 12:48 AM.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a tree command listing permissions/owner for RHEL 3.6? Passions Linux - Software 1 04-18-2007 07:49 PM
/etc/mtab has bad permissions/owner/group on Ubuntu Edgy ImpactDNI Linux - Software 1 11-08-2006 06:56 PM
/dev entries changing their owner and permissions pulsosu Linux - Security 2 04-11-2005 06:19 PM
creating sub-sub directories dominant Linux - Newbie 13 07-23-2004 05:16 PM
got stuck while creating directories chupacabra Linux From Scratch 3 11-21-2002 07:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:29 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration