umask 에 관한 질문입니다.

ikshin의 이미지

리눅스마스터의 기출문제 중 궁금한 점이 있어 여쭤봅니다.

$ umask ( )
$ touch test
$ ls -al test
$ -rw-r----- ihd ihd 32 6월 0 13:22 test

해당 umask 의 셋팅값을 물어보는 문제거든요.
저는 "026"이 아닐까 생각하고 있었는데, 문제의 답지엔 "137"로 되어있더군요.
두 셋팅값의 결과는 모두 동일하게 나오긴 합니다만, 제가 알기론 umask 는 일반파일의
퍼미션인 "666" 값을 기준으로 셋팅한다고 알고 있었거든요.

그래서 .bashrc 같은 곳에서도 umask 값을 "022" 같은 식으로 설정하는 걸로 알고
있어구요. 답이 "137"이 될 수 밖에 없는 다른 이유가 있는건지...아니면 제가 umask에
대해 기본적으로 잘못 이해하고 있는건지 싶어서 여쭤봅니다.

오네테르의 이미지

파일이 만들어질 때 자동으로 해당 퍼미션을 꺼주는 기능을
하는것이 umask입니다.
즉 mode를 적용할 때
(~mask)&mode
이런식으로 적용하게 됩니다.
결국 -rw-r-----
이므로 octal로 표현하면 777이고
~mask가 적용되는 과정을 보면

Quote:
&
111111111
110100000 -> ~mask
------------------------------
110100000 -> -rw-r-----

결국 ~mask가 110100000이므로
mask는 001011111이어서
137이 되는거죠

Want 2 be A good Programmer

kuaaan의 이미지

파일의 경우 666에서 빼므로... 위의 문제는 026이나 137이나 둘다 답이 될수 있을듯 합니다만...?
아마 126이나 037이나... 여러가지 답이 가능할듯. 안좋은 문제네요. -_-;;

[root@fedora tmp]# umask 137;touch test1;ll test1
-rw-r----- 1 root root 0 11월 6 16:51 test1
[root@fedora tmp]# umask 026;touch test2;ll test2
-rw-r----- 1 root root 0 11월 6 16:52 test2
[root@fedora tmp]# umask 126;touch test3;ll test3
-rw-r----- 1 root root 0 11월 6 16:53 test3

----------------------------------------------
한번뿐인 인생....
미친듯이 살아보자!
----------------------------------------------

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.