LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices

Reply
 
Search this Thread
Old 08-11-2005, 03:41 AM   #1
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Rep: Reputation: 49
chmod + umask for a whole dir tree


If I would want to change the permission in a whole directory tree (many many subdirs everywhere, and file), let's say I want directories to have 755 and regular files to have 644. IIRC I can use umask to mask away some bits and then do a chmod.

My questions are: can I make umask differ between directories and file. And should I do a chmod 777 after making the umask.

Or am I out riding my bike in the wrong park?
 
Old 08-11-2005, 04:41 AM   #2
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 61
In such a case, what I usually do is:
find dir/ -type d -exec chmod XXX {} \;
find dir/ ! -type d -exec chmod XXX {} \;

Yves.
 
Old 08-15-2005, 06:55 PM   #3
tkedwards
Senior Member
 
Registered: Aug 2004
Location: Munich, Germany
Distribution: Opensuse 11.2
Posts: 1,549

Rep: Reputation: 51
umask sets the default permissions that files and directories have when they're created. If my user's umask is 0027 any files or directories I create when logged in as me will be inaccessible to 'others' and not writeable to 'group' and will give full access to 'user' (the extra zero on the end if for setting special permission bits like setuid, setgid etc.).

So to get the effect of the umask subtract 7 from the umask number. For the group permissions in this example 7-2=5 which is read and execute permissions. It will actually create directories with read and execute permission but files with just read permission - its smart enough to know that making files executable by default is unecessary and could lead to security problems.
 
  


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
umask chmod?? blackzone Linux - Newbie 3 01-11-2005 01:50 AM
dir tree tommytomato Linux - General 2 05-12-2004 08:10 PM
Which command displays the dir tree of a HD? cbjhawks Linux - General 5 02-28-2004 12:17 AM
chmod and umask InsaneBob Linux - Software 20 07-19-2003 11:10 PM
file perm, chgrp, chmod, and umask Martini Linux - Newbie 2 08-06-2002 08:04 PM


All times are GMT -5. The time now is 06:36 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