-rw-r--r-- 이렇게 설정된 파일을 다른 user가 지우지 못하게 하는 방법?

foruses의 이미지

안녕하세요.

지금까지 -rw-r--r-- 로 권한 설정되어 있는 파일의 경우 다른 사람이 읽을 수 만 있지 지우지는 못하는 것으로 알고 있었는데,
그렇지가 않더라구요. 개인이 만든 파일을 다른 사람이 지우지 못하게 하려면 어떻게 해야 하나요?

wewoori의 이미지

되실듯합니다.

chattr +i 파일명 하시면 되실듯합니다.. 사용해본지 오래되서 기억이 가물가물하기
는 하지만 저의 기억엔 +i는 다른 사람이 수정이 불가능하게 오로지 수퍼유저권한을
가진자만이 이 옵션을 변경을 할수있다로 기억하고있습니다.. 틀릴수도있는데 아마도
맞지않을까싶습니다.아마도 이 옵션들이 파일에 적용되었는지 보는 명령은 lsattr
인가 그럴겁니다.. 참고로 푸는 방법은 +을 -로 바꿔서 주면 풀립니다..

물론 이 명령을 실행을 하려면 root권한을 가져야합니다...

작은 도움이나마 되셧으면 합니다.. 즐거운 하루하루되세요..!!!

----------------

wewoori@ubuntu:~/temp$ sudo chattr +i 123.txt
wewoori@ubuntu:~/temp$ lsattr
----i------------- ./123.txt

삭제을 시도할 경우

wewoori@ubuntu:~/temp$ rm 123.txt
rm: remove write-protected regular file `123.txt'? y
rm: cannot remove `123.txt': Operation not permitted

수정을 하고 저장을 하려고하면 다음과 같은 익숙한 메세지가 뜹니다.

Error writing 123.txt: Permission denied

이정도면 충분히 답변이 되셨으시라 생각됩니다..

익명 사용자의 이미지

디렉토리의 권한을 rwxr-xr-x 로 해도 그런가요?

파일을 지우는건 디렉토리의 내용을 바꾸는거라서 디렉토리의 권한을 따라 간답니다.

foruses의 이미지

궁금증이 풀렸습니다. 디렉토리 권한에 의존하는군요.

그런데, 사실 제가 하고 싶은 것이,

디렉토리 쓰기 권한 주고, 파일은 다른 사람이 지우지 못하게.....하고 싶습니다.
즉, 공동으로 사용하는 디렉토리를 하나 만들고 그 안에서 여러 유저들이 자유롭게 쓰고 지우고 할 수 있게 하면서도,
다른 사람의 파일은 삭제하지는 못하게 하는 것이......원하는 내용입니다.

도움 부탁드릴께요.

감사합니다.

Hyun의 이미지

그런 기능은 디렉토리에 스티키 플래그를 걸어두면 됩니다. 보통 /tmp 디렉토리가 그렇게 스티키 플래그가 걸려있습니다.

chmod o+t /directory/name
해보세요.

STICKY DIRECTORIES
       When  the sticky bit is set on a directory, files in that directory may
       be unlinked or renamed only by root or their owner.  Without the sticky
       bit,  anyone able to write to the directory can delete or rename files.
       The sticky bit is commonly found on directories, such as /tmp, that are
       world-writable.

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.