Results 1 to 7 of 7

Thread: Explain umask please?

  1. #1
    Join Date
    Nov 2013
    Beans
    12

    Explain umask please?

    I'm reading a Linux Bible book I bought and ran across unmask. I've looked online at various sites and videos to explain it, but I must have a hard time grasping the concept. I know it's a default used to set permissions for files and folders when created, and I understand rwx=421 and the ugo ad well.

    I just don't understand why its set as 022 and 755.. Maybe I need diagrams and formulas lol.

  2. #2
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    7,737
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Explain umask please?

    Hi rubensaurus.

    Just in case (to cover the basics):
    Code:
    --x = 1
    -w- = 2
    r-- = 4
    then
    Code:
    rw- = 6
    r-x = 5
    rwx = 7
    Does that help?
    Regards.

  3. #3
    Join Date
    Aug 2013
    Beans
    76
    Distro
    Ubuntu 13.04 Raring Ringtail

    Re: Explain umask please?

    umask is like a filter they run permissions through. So full permissions is 777 and then the subtract the umask from it so a umask of 022 gives you a default of 755 (777 - 022)

  4. #4
    Join Date
    Nov 2013
    Beans
    12

    Re: Explain umask please?

    So if I want to have the default be 777 would I have a umask of 000? Or if I want rwxrw-rw- I would be 011?

  5. #5
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    7,737
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Explain umask please?

    Quote Originally Posted by rubensaurus View Post
    So if I want to have the default be 777 would I have a umask of 000? Or if I want rwxrw-rw- I would be 011?
    Yes, but note that file creation by default won't include execution bit.

    For instance:
    Code:
    $ umask 000
    $ touch thisfile
    $ ls -l thisfile
    -rw-rw-rw- 1 pablo pablo 12 Nov  7 16:30 thisfile
    However, with directories will be exactly that:
    Code:
    $ umask 000
    $ mkdir thisdir
    $ ls -ld thisdir
    drwxrwxrwx 2 pablo pablo 4096 Nov  7 16:29 thisdir/
    Does that help?
    Regards.

  6. #6
    Join Date
    Nov 2013
    Beans
    12

    Re: Explain umask please?

    Quote Originally Posted by Kevin_Arnold View Post
    umask is like a filter they run permissions through. So full permissions is 777 and then the subtract the umask from it so a umask of 022 gives you a default of 755 (777 - 022)
    Quote Originally Posted by papibe View Post
    Yes, but note that file creation by default won't include execution bit.

    For instance:
    Code:
    $ umask 000
    $ touch thisfile
    $ ls -l thisfile
    -rw-rw-rw- 1 pablo pablo 12 Nov  7 16:30 thisfile
    However, with directories will be exactly that:
    Code:
    $ umask 000
    $ mkdir thisdir
    $ ls -ld thisdir
    drwxrwxrwx 2 pablo pablo 4096 Nov  7 16:29 thisdir/
    Does that help?
    Regards.

    thanks guys!

  7. #7
    Join Date
    May 2008
    Location
    SoCal
    Beans
    Hidden!
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Explain umask please?

    Quote Originally Posted by papibe View Post
    Yes, but note that file creation by default won't include execution bit.

    For instance:
    Code:
    $ umask 000
    $ touch thisfile
    $ ls -l thisfile
    -rw-rw-rw- 1 pablo pablo 12 Nov  7 16:30 thisfile
    However, with directories will be exactly that:
    Code:
    $ umask 000
    $ mkdir thisdir
    $ ls -ld thisdir
    drwxrwxrwx 2 pablo pablo 4096 Nov  7 16:29 thisdir/
    Does that help?
    Regards.
    For completeness: The reason for the difference between files and directories is that that default file creation is 666 (with 002 umask it's 664) and the default file creation is 777 (with the same umask you get 775).

    The default in not the only method to set umask. The last setting is in force however. You can set umask at the CLI (it will disappear when the terminal is closed) and you can set umask in a script (which is in effect only during that script's execution.
    -BAB1

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •