Linux Command Line and Permissions Question

simonthecat

Member
Messages
60
Reaction score
0
Points
6
I am taking a linux class in college at the end of each chapter I have some review questions. Here is a question that has me wondering if it is a typo error or if I really missed understanding what I was reading.

After typing the command umask 731, the permissions on all subsequently created files and dircetories will be affected. In this case, what will be the permissions on all new files?

a. rw-rw-rw-
b. rwxrw-r--
c. ---r--rw-
d. ----wx--x
I found the answer key online and supposedly the answer is c

But if I am understanding the permissions correctly should it instead be: rwx-wx--x since 731 breaks up into 421021001???

And in answer to the question why don't I just ask my teacher I am taking an internet class and my teach would take 1 to 2 weeks to get around to answering me. :rolleyes: Anyways thanks for helping.
 

steronius

Member
Messages
195
Reaction score
4
Points
18
Well I was curious, so I tested it. I had never used umask before.

here are my results, but not that I understand why:

chmod produced the rights that you thought it would be.
Code:
ster@FriedLiver:~$ chmod 731 temp.txt
ster@FriedLiver:~$ ls t* -a -l
-rwx-wx--x 1 ster ster 0 2010-03-25 07:36 temp.txt

However using umask in a test folder produced answer "c".
Code:
ster@FriedLiver:~$ mkdir test
ster@FriedLiver:~$ cd test
ster@FriedLiver:~/test$ umask 731
ster@FriedLiver:~/test$ touch temp.txt
ster@FriedLiver:~/test$ ls t* -a -l
----r--rw- 1 ster ster 0 2010-03-25 07:42 temp.txt
ster@FriedLiver:~/test$
 

lemon-tree

x10 Minion
Community Support
Messages
1,420
Reaction score
46
Points
48
From a quick search it appears umask is similar to an inverse chmod. i.e A Chmod of 777 is a umask of 000. In your case, umask 731 is equivalent to chmod 046.
 

adessobastadavvero

New Member
Messages
9
Reaction score
0
Points
0
With umask you specify which permissions you are NOT giving to subsequently created files.
You must subtract the mask from 777.
In your exercise 777-731=046, that is answer c.
 

slacker3

New Member
Messages
146
Reaction score
6
Points
0
note the difference in files/directories:
file: 0666 - umask
dir: 0777 - umask

so with an umask of 0022 a new created file would have the permissions 0644 / -rw-r--r-- (0666 - 0022), and a new created directory would have 0755 / -rwxr-x-r-x (0777 - 0022)
 
Last edited:
Top