The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
umask falcon16 SUN Solaris 7 03-18-2009 11:47 PM
umask praveen_b744 UNIX for Dummies Questions & Answers 1 07-27-2008 03:14 AM
help on umask suvendu4urs Linux 6 04-11-2008 01:12 PM
Umask help x96riley3 AIX 1 04-04-2006 04:56 PM
umask rsh UNIX for Dummies Questions & Answers 2 12-14-2002 12:52 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-01-2009
Nagapandi Nagapandi is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 36
umask

Hi,

Please, let me know how the umask is working? As per my understanding is aprt from subtracting from 666/777, logical gate operation is performing.

Ex: If I set uname 011, it gave the permission like 666 for file. Request you to explain which gate's operation performed.

$uname 011
$uname
0011
$vi abc
$ls -l abc
-rw-rw-rw- 1 unixguy staff 29 Jan 26 14:03 abc

Regards,
Naga
  #2 (permalink)  
Old 02-01-2009
pludi's Avatar
pludi pludi is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2008
Location: .at
Posts: 1,934
If you copy and pasted from your shell, you entered the wrong command (uname instead of umask).
A umask of 011 should give permissions of -rw-rw-rw- for a file
  #3 (permalink)  
Old 02-01-2009
Nagapandi Nagapandi is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 36
Hi,

Sorry for the inconvenience, Once again with umask

Please, let me know how the umask is working? As per my understanding is aprt from subtracting from 666/777, logical gate operation is performing.

Ex: If I set uname 011, it gave the permission like 666 for file. Request you to explain which gate's operation performed.

$umask 011
$umask
0011
$vi abc
$ls -l abc
-rw-rw-rw- 1 unixguy staff 29 Jan 26 14:03 abc

May I know why it should give -rw-rw-rw- if i set 011? As well if i see 000 also differ, may I know how the kernel is behaving?

Thanks,
Naga
  #4 (permalink)  
Old 02-01-2009
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,969
Quote:
Originally Posted by Nagapandi View Post
Hi,

Sorry for the inconvenience, Once again with umask

Please, let me know how the umask is working? As per my understanding is aprt from subtracting from 666/777, logical gate operation is performing.
The umask describes what file-access bits to always eliminate when creating a file, where 1 is execute, 2 is write, and 4 is read. a umask of 777 will always remove all bits, 666 will remove read and write, 000 won't clear any bits at all, etc. A umask of 000 will usually result in rw-rw-rw just because what created the file never asked for the execute bit to be set in the first place; the umask will never give more bits than what the program asked for, just remove specific bits.
  #5 (permalink)  
Old 06-29-2009
kurinchiblogger kurinchiblogger is offline
Registered User
  
 

Join Date: Jun 2009
Location: Canada
Posts: 1
umask explanation

I thought to post the information related to umask which i have read it from sites so that it might be helpful to someone who comes across this thread ...

$ umask
022 (this is the default value in my system)

For files, the permission settings are 0666 and for directories it is 0777


Having known the umask value, try creating a directory and a file and check what the file settings are

$ mkdir tempdir1

$ ls -l
drwxr-xr-x 2 root root 4096 2009-06-29 10:42 tempdir1

$ touch tempfile1

$ ls -l
drwxr-xr-x 2 root root 4096 2009-06-29 10:42 tempdir1
-rw-r--r-- 1 root root 0 2009-06-29 10:43 tempfile1


Change the umask and again create a directory and a file and check the file permission settings

$ umask 027
$ umask
0027
$ mkdir tempdir2
$ ls -l
total 12
drwxr-x--- 2 root root 4096 2009-06-29 10:40 tempdir2

$ touch tempfile2
$ ls -l
drwxr-x--- 2 root root 4096 2009-06-29 10:40 tempdir2
-rw-r----- 1 root root 0 2009-06-29 10:40 tempfile2

Now, let us see how the file permission settings are calculated using boolean expression.

For the directories, you need to take the 1's complement of the umask value and perform a logical AND operation with 0777.

For e.g. consider the case where we have umask value of 027 - 0000 0000 0010 0111
1's complement of 027 - 1111 1101 1000

For directories perform logical AND operation with 0777 (0000 0111 0111 0111). So

1111 1101 1000 (1's complement of 027)
0111 0111 0111 (0777)
-------------------
0111 0101 0000 = 0750


For files, perfom logical AND operation with 0666 (0000 0110 0110 0110), so

1111 1101 1000 (1's complement of 027)
0110 0110 0110 (0666)
-------------------
0110 0100 0000 = 0640
Reply

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:44 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0