+ Reply to Thread
Results 1 to 6 of 6
Like Tree3Likes
  • 1 Post By simonthecat
  • 1 Post By lemon-tree
  • 1 Post By slacker3

Thread: Linux Command Line and Permissions Question

  1. #1
    simonthecat's Avatar
    simonthecat is offline x10Hosting Member simonthecat is an unknown quantity at this point
    Join Date
    Aug 2007
    Posts
    56

    Question Linux Command Line and Permissions Question

    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. Anyways thanks for helping.
    dinomirt96 likes this.

  2. #2
    steronius's Avatar
    steronius is offline x10 Sophmore steronius is an unknown quantity at this point
    Join Date
    Feb 2008
    Posts
    191

    Re: Linux Command Line and Permissions Question

    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$

  3. #3
    lemon-tree's Avatar
    lemon-tree is offline x10 Minion lemon-tree has a spectacular aura about
    Join Date
    Nov 2007
    Posts
    1,420

    Re: Linux Command Line and Permissions Question

    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.
    verlmirt17 likes this.

  4. #4
    adessobastadavvero is offline x10Hosting Member adessobastadavvero is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    9

    Re: Linux Command Line and Permissions Question

    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.

  5. #5
    simonthecat's Avatar
    simonthecat is offline x10Hosting Member simonthecat is an unknown quantity at this point
    Join Date
    Aug 2007
    Posts
    56

    Re: Linux Command Line and Permissions Question

    I understand now thank you for the help.

  6. #6
    slacker3 is offline x10 Sophmore slacker3 is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    146

    Re: Linux Command Line and Permissions Question

    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 by slacker3; 03-26-2010 at 01:37 PM.
    karimirt47 likes this.

+ Reply to Thread

Similar Threads

  1. SQL Command Line
    By gavicus in forum Programming Help
    Replies: 3
    Last Post: 07-04-2009, 12:00 PM
  2. Command line?
    By shaiaqua in forum Free Hosting
    Replies: 2
    Last Post: 05-09-2008, 10:10 PM
  3. log into sql from command line?
    By chess314 in forum Scripts & 3rd Party Apps
    Replies: 6
    Last Post: 01-30-2008, 03:01 AM
  4. Command line
    By Skizzerz in forum Free Hosting
    Replies: 9
    Last Post: 11-05-2007, 09:40 PM
  5. command line use
    By estado3 in forum Free Hosting
    Replies: 1
    Last Post: 07-09-2007, 09:20 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers