UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old July 18th, 2003, 07:12 PM
Tundra's Avatar
Tundra Tundra is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2001
Location: Honolulu, Hawaii
Posts: 252 Tundra User rank is Corporal (100 - 500 Reputation Level)Tundra User rank is Corporal (100 - 500 Reputation Level)Tundra User rank is Corporal (100 - 500 Reputation Level)Tundra User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 4 h 53 m 57 sec
Reputation Power: 9
Send a message via AIM to Tundra
MySpace
Umask

It's hard to find a good umask specific resource. I don't what section of the man the umask usage falls under. I'm trying to set a directory so that files are automatically created with 775 permissions.

I have three questions. What is the umask code I would use to have the files auto-set to 775? Does anyone know a good website that explains how to use umask? What section of the man (on FreeBSD) can I find the umask usage documentation.

Thanks

Reply With Quote
  #2  
Old July 18th, 2003, 07:24 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 5th Plane (7000 - 7499 posts)
 
Join Date: Nov 2001
Location: Glendale, Los Angeles County, California, USA
Posts: 7,433 Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 4 Weeks 1 Day 22 h 44 m 46 sec
Reputation Power: 784
man -k umask
This gives a pointer to man umask. The man 1 umask page then says to consult the man pages for sh or csh for specifics. man csh has the info you're looking for. I did this all on FreeBSD 4.6-RELEASE

To save you a bit of a read, basically umask is used to unmask certain bits. I assume you know how to use the chmod command. Well, the umask is used to unmask certain bits by default.

In your case, you need to unmask the write bit for world. So, you would set umask to 002. Basically, this will unmask bit 2 for world alone (i.e. write permissions) and leave the user and group bits untouched since they're both 0. HTH
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne

Puzzle of the Month solved by sizeablegrin, etienne141 and L7Sqr, superior C/C++ programmers of the month

Reply With Quote
  #3  
Old July 18th, 2003, 07:49 PM
Tundra's Avatar
Tundra Tundra is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2001
Location: Honolulu, Hawaii
Posts: 252 Tundra User rank is Corporal (100 - 500 Reputation Level)Tundra User rank is Corporal (100 - 500 Reputation Level)Tundra User rank is Corporal (100 - 500 Reputation Level)Tundra User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 4 h 53 m 57 sec
Reputation Power: 9
Send a message via AIM to Tundra
MySpace
Thanks for the tip. Unfortunately files under a umask 002 are created with rw-rw-r-- settings, which is strange considering what the man says.

"002, giving all access to the group and read and execute access to others"

That seems to fit the description of what I want really well so I don't know what to tell you.

Reply With Quote
  #4  
Old July 18th, 2003, 08:06 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 5th Plane (7000 - 7499 posts)
 
Join Date: Nov 2001
Location: Glendale, Los Angeles County, California, USA
Posts: 7,433 Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 4 Weeks 1 Day 22 h 44 m 46 sec
Reputation Power: 784
It also depends on the app that is being used to create the file. For example, vi doesn't set a file as executable (only sets the read and write bits). So if you edit a file with vi, it will try to set 666 for permissions. Since your umask is 002, the effective permissions will be set to 664.

Now, by contrast, if you try to use gcc to compile a file, it sets the execute bits of the executable file that it created. gcc tries to set the executable's permissions to 777, so if you have umask of 002, the effective permissions will be set to 775.

To demonstrate:
Code:
# umask 002
# gcc -o file file.c
# ls -l file
-rwxrwxr-x  1 root  wheel  5220 Jul 18 18:01 file
# umask 022
# gcc -o file file.c
# ls -l file
-rwxr-xr-x  1 root  wheel  5220 Jul 18 18:01 file


So, if an app doesn't set a permission by default, your umask is not going to affect it.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Umask


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway