사용 버전 : Linux 우분투(레드햇 계열) 24.04.01 LTS 버전
사용한 시스템 지역/언어 : 대한민국/한글
man chmod 원문
CHMOD(1) User Commands CHMOD(1)
NAME
chmod - change file mode bits
SYNOPSIS
chmod [OPTION]... MODE[,MODE]... FILE...
chmod [OPTION]... OCTAL-MODE FILE...
chmod [OPTION]... --reference=RFILE FILE...
DESCRIPTION
This manual page documents the GNU version of chmod. chmod changes the
file mode bits of each given file according to mode, which can be ei‐
ther a symbolic representation of changes to make, or an octal number
representing the bit pattern for the new mode bits.
The format of a symbolic mode is [ugoa...][[-+=][perms...]...], where
perms is either zero or more letters from the set rwxXst, or a single
letter from the set ugo. Multiple symbolic modes can be given, sepa‐
rated by commas.
A combination of the letters ugoa controls which users' access to the
file will be changed: the user who owns it (u), other users in the
file's group (g), other users not in the file's group (o), or all users
(a). If none of these are given, the effect is as if (a) were given,
but bits that are set in the umask are not affected.
The operator + causes the selected file mode bits to be added to the
existing file mode bits of each file; - causes them to be removed; and
= causes them to be added and causes unmentioned bits to be removed ex‐
cept that a directory's unmentioned set user and group ID bits are not
affected.
The letters rwxXst select file mode bits for the affected users: read
(r), write (w), execute (or search for directories) (x), execute/search
only if the file is a directory or already has execute permission for
some user (X), set user or group ID on execution (s), restricted dele‐
tion flag or sticky bit (t). Instead of one or more of these letters,
you can specify exactly one of the letters ugo: the permissions granted
to the user who owns the file (u), the permissions granted to other
users who are members of the file's group (g), and the permissions
granted to users that are in neither of the two preceding categories
(o).
A numeric mode is from one to four octal digits (0-7), derived by
adding up the bits with values 4, 2, and 1. Omitted digits are assumed
to be leading zeros. The first digit selects the set user ID (4) and
set group ID (2) and restricted deletion or sticky (1) attributes. The
second digit selects permissions for the user who owns the file: read
(4), write (2), and execute (1); the third selects permissions for
other users in the file's group, with the same values; and the fourth
for other users not in the file's group, with the same values.
chmod never changes the permissions of symbolic links; the chmod system
call cannot change their permissions. This is not a problem since the
permissions of symbolic links are never used. However, for each sym‐
bolic link listed on the command line, chmod changes the permissions of
the pointed-to file. In contrast, chmod ignores symbolic links encoun‐
tered during recursive directory traversals.
SETUID AND SETGID BITS
chmod clears the set-group-ID bit of a regular file if the file's group
ID does not match the user's effective group ID or one of the user's
supplementary group IDs, unless the user has appropriate privileges.
Additional restrictions may cause the set-user-ID and set-group-ID bits
of MODE or RFILE to be ignored. This behavior depends on the policy
and functionality of the underlying chmod system call. When in doubt,
check the underlying system behavior.
For directories chmod preserves set-user-ID and set-group-ID bits un‐
less you explicitly specify otherwise. You can set or clear the bits
with symbolic modes like u+s and g-s. To clear these bits for directo‐
ries with a numeric mode requires an additional leading zero like
00755, leading minus like -6000, or leading equals like =755.
RESTRICTED DELETION FLAG OR STICKY BIT
The restricted deletion flag or sticky bit is a single bit, whose in‐
terpretation depends on the file type. For directories, it prevents
unprivileged users from removing or renaming a file in the directory
unless they own the file or the directory; this is called the re‐
stricted deletion flag for the directory, and is commonly found on
world-writable directories like /tmp. For regular files on some older
systems, the bit saves the program's text image on the swap device so
it will load more quickly when run; this is called the sticky bit.
OPTIONS
Change the mode of each FILE to MODE. With --reference, change the
mode of each FILE to that of RFILE.
-c, --changes
like verbose but report only when a change is made
-f, --silent, --quiet
suppress most error messages
-v, --verbose
output a diagnostic for every file processed
--no-preserve-root
do not treat '/' specially (the default)
--preserve-root
fail to operate recursively on '/'
--reference=RFILE
use RFILE's mode instead of specifying MODE values. RFILE is
always dereferenced if a symbolic link.
-R, --recursive
change files and directories recursively
--help display this help and exit
--version
output version information and exit
Each MODE is of the form
'[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'.
AUTHOR
Written by David MacKenzie and Jim Meyering.
REPORTING BUGS
GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Report any translation bugs to <https://translationproject.org/team/>
COPYRIGHT
Copyright © 2023 Free Software Foundation, Inc. License GPLv3+: GNU
GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
SEE ALSO
chmod(2)
Full documentation <https://www.gnu.org/software/coreutils/chmod>
or available locally via: info '(coreutils) chmod invocation'
GNU coreutils 9.4 April 2024 CHMOD(1)
man chmod 번역기 번역본
CHMOD(1) 사용자 명령 CHMOD(1)
이름
chmod - 파일 모드 비트 변경
요약
chmod [옵션]... 모드[,모드]... 파일...
chmod [옵션]... 8진 모드 파일...
chmod [옵션]... --reference=RFILE 파일...
설명
이 매뉴얼 페이지는 chmod의 GNU 버전을 설명합니다. chmod는 모드에 따라 각 파일의 파일 모드 비트를 변경합니다. 모드는 변경할 내용의 기호 표현이거나 새 모드 비트의 비트 패턴을 나타내는 8진수일 수 있습니다.
기호 모드의 형식은 [ugoa...][[-+=][perms...]...]이며, 여기서 perms는 rwxXst 세트의 0개 이상의 문자이거나 ugo 세트의 단일 문자입니다. 여러 기호 모드를 쉼표로 구분하여 지정할 수 있습니다.
ugoa 문자 조합은 파일에 대한 사용자의 액세스 권한을 변경할지 제어합니다. 파일을 소유한 사용자(u), 파일 그룹의 다른 사용자(g), 파일 그룹에 없는 다른 사용자(o) 또는 모든 사용자(a)입니다. 이 중 아무것도 지정하지 않으면 (a)가 지정된 것과 같은 효과가 있지만 umask에 설정된 비트는 영향을 받지 않습니다.
연산자 +는 선택한 파일 모드 비트를 각 파일의 기존 파일 모드 비트에 추가합니다. -는 비트를 제거합니다.
=는 비트를 추가하고 언급되지 않은 비트를 제거합니다. 단, 디렉토리의 언급되지 않은 사용자 및 그룹 ID 비트는 영향을 받지 않습니다.
rwxXst 문자는 영향을 받는 사용자에 대한 파일 모드 비트를 선택합니다. 읽기(r), 쓰기(w), 실행(또는 디렉토리 검색)(x), 실행/검색(파일이 디렉토리이거나 이미 일부 사용자에 대한 실행 권한이 있는 경우에만)(X), 실행 시 사용자 또는 그룹 ID 설정(s), 제한된 삭제 플래그 또는 스티키 비트(t). 이러한 문자 중 하나 이상 대신 문자 ugo 중 하나만 지정할 수 있습니다. 파일을 소유한
사용자에게 부여된 권한(u), 파일 그룹의 멤버인
다른 사용자에게 부여된 권한(g), 두 가지 이전 범주에 속하지 않는
사용자에게 부여된 권한(o).
숫자 모드는 1에서 4개의 8진수(0-7)로, 값 4, 2, 1인 비트를 더하여 도출합니다. 생략된 숫자는 선행 0으로 간주됩니다. 첫 번째 숫자는 설정된 사용자 ID(4)와
설정된 그룹 ID(2) 및 제한된 삭제 또는 스티키(1) 속성을 선택합니다. 두 번째 숫자는 파일을 소유한 사용자의 권한을 선택합니다. 읽기
(4), 쓰기 (2), 실행 (1); 세 번째 숫자는
파일 그룹의 다른 사용자에 대한 권한을 선택합니다. 동일한 값; 네 번째 숫자는
파일 그룹에 없는 다른 사용자에 대한 권한을 선택합니다. 동일한 값.
chmod는 심볼릭 링크의 권한을 변경하지 않습니다. chmod 시스템 호출은 권한을 변경할 수 없습니다. 심볼릭 링크의 권한이 사용되지 않으므로 이는 문제가 되지 않습니다. 그러나 명령줄에 나열된 각 심볼릭 링크의 경우 chmod는 가리키는 파일의 권한을 변경합니다. 반면 chmod는 재귀적 디렉토리 탐색 중에 발견된 심볼릭 링크를 무시합니다.
SETUID 및 SETGID 비트
chmod는 파일의 그룹 ID가 사용자의 유효 그룹 ID 또는 사용자의 보충 그룹 ID 중 하나와 일치하지 않는 경우 일반 파일의 set-group-ID 비트를 지웁니다. 단, 사용자에게 적절한 권한이 있는 경우는 예외입니다.
추가 제한으로 인해 MODE 또는 RFILE의 set-user-ID 및 set-group-ID 비트가 무시될 수 있습니다. 이 동작은 기본 chmod 시스템 호출의 정책 및 기능에 따라 달라집니다. 의심스러운 경우 기본 시스템 동작을 확인하세요.
디렉토리의 경우 chmod는 명시적으로 달리 지정하지 않는 한 set-user-ID 및 set-group-ID 비트를 보존합니다. u+s 및 g-s와 같은 기호 모드로 비트를 설정하거나 지울 수 있습니다. 숫자 모드가 있는 디렉토리의 이러한 비트를 지우려면
00755와 같은 추가 선행 0, -6000과 같은 선행 마이너스 또는 =755와 같은 선행 등호가 필요합니다.
제한적 삭제 플래그 또는 스티키 비트
제한적 삭제 플래그 또는 스티키 비트는 단일 비트이며, 해석은 파일 유형에 따라 달라집니다. 디렉토리의 경우 권한이 없는 사용자가 파일이나 디렉토리를 소유하지 않는 한 디렉토리에서 파일을 제거하거나 이름을 바꾸는 것을 방지합니다. 이를 디렉토리의 제한적 삭제 플래그라고 하며 일반적으로 /tmp와 같은 전체 쓰기 가능 디렉토리에서 찾을 수 있습니다. 일부 오래된 시스템의 일반 파일의 경우 비트는 프로그램의 텍스트 이미지를 스왑 장치에 저장하므로 실행 시 더 빨리 로드됩니다. 이를 스티키 비트라고 합니다.
옵션
각 FILE의 모드를 MODE로 변경합니다. --reference를 사용하여 각 FILE의 모드를 RFILE의 모드로 변경합니다.
-c, --changes
verbose와 비슷하지만 변경이 있을 때만 보고
-f, --silent, --quiet
대부분의 오류 메시지를 억제
-v, --verbose
처리된 모든 파일에 대한 진단을 출력
--no-preserve-root
'/'를 특별히 취급하지 않음(기본값)
--preserve-root
'/'에서 재귀적으로 작동하지 않음
--reference=RFILE
MODE 값을 지정하는 대신 RFILE의 모드를 사용합니다. RFILE은
심볼릭 링크인 경우 항상 역참조됩니다.
-R, --recursive
파일과 디렉터리를 재귀적으로 변경
--help 이 도움말을 표시하고 종료
--version
버전 정보를 출력하고 종료
각 MODE는 형식이
'[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'입니다.
작성자
David MacKenzie와 Jim Meyering이 작성했습니다.
버그 보고
GNU coreutils 온라인 도움말: <https://www.gnu.org/software/coreutils/>
번역 버그가 있으면 <https://translationproject.org/team/>에 보고하세요.
저작권
저작권 © 2023 Free Software Foundation, Inc. 라이선스 GPLv3+: GNU
GPL 버전 3 이상 <https://gnu.org/licenses/gpl.html>.
이것은 무료 소프트웨어입니다. 변경하고 재배포할 수 있습니다.
법률에서 허용하는 범위 내에서 어떠한 보증도 없습니다.
또한 참조
chmod(2)
전체 설명서 <https://www.gnu.org/software/coreutils/chmod>
또는 다음을 통해 로컬에서 사용 가능: info '(coreutils) chmod invocation'
GNU coreutils 9.4 2024년 4월 CHMOD(1)
형태 : chmod [옵션] [권한] [파일]
기능 : [파일]의 접근 [권한]을 변경한다.
특정 파일의 접근 권한을 알고 싶다면 ls -l 명령어를 통해서 알아낼 수 있다.
리눅스 명령어 - ls
형태 : ls [옵션] [dir]기능 : 해당 디렉토리에 존재하는 파일, 디렉토리들을 보여줌 [dir]디렉토리를 입력하면 되며 상대경로와 절대경로 모두 입력가능하다. [옵션]-a : 숨김 파일을 포함하여 모든
warmice8226.tistory.com
[권한]
접근 권한을 설정하는 방법에 대해서는 2가지 방법이 있다.
1. 기호 표기
2. 숫자 표기
기호로 표기를 할 경우 "권한 부여 대상" + "권한 추가/제거/대입" + "접근 권한" 의 형태로 이루어진다.
- 권한 부여 대상은 소유자 / 소유 그룹 / 기타 사용자 3가지로 구분되며 각각 u / g / o 의 약어를 가진다.
만약 3개의 대상을 모두 지정하고 싶다면 a 로 지정할 수 있다.
- 권한 추가/제거/대입의 경우 + / - / = 로 표기한다.
추가/제거는 권한 부여대상에게 접근 권한을 추가/제거해주고
대입의 경우 우측에 작성한 접근 권한이 되도록 부여한다.
-접근 권한은 읽기/쓰기/실행 3개의 종류가 있으며 각각 r/w/x 의 약어를 가진다.
ex)
uo-w : 소유자와 기타 사용자에서 쓰기 권한을 제거
ug+wr : 소유자와 소유 그룹에 쓰기와 읽기 권한을 추가
a=xr : 전체 대상에게 실행 권한과 읽기 권한 추가, 쓰기 권한은 제거
숫자로 표기하는 경우는 다음과 같은 원리로 기록된다.
각각의 사용자에 대해서 rwx의 권한을 2진수로 대입할 경우
r = 2^2 = 4
w = 2^1 = 2
x = 2^0 = 1
의 자리값을 가지게 된다.
각 자리수를 0과 1을 조합하여 더하게 될 경우
r,x의 권한을 가진경우 4+1 = 5
r,w의 권한을 가진 경우 4+2 = 6
모든 권한을 가진 경우 4 + 2 + 1 = 7의 권한 값을 가지게 된다.
이러한 각각의 권한의 합을 소유자, 소유 그룹, 기타 사용자에 대해서 표기해주면 된다.
접근 권한에 대한 예시
r-x rwx --x = 571
r-- -w- -wx = 423
rw --- r-x = 605
'IT 공부내용 정리 > Linux' 카테고리의 다른 글
| 터미널 명령어 - ps 현재 실행중인 프로세스를 알고 싶을 때 (1) | 2025.03.13 |
|---|---|
| 터미널 명령어 - umask 기본 접근 권한의 설정을 바꿔야 할 때 (0) | 2025.03.06 |
| 터미널 명령어 - which / whereis 명령어 파일이 어디 있는지 알고 싶을 때 (0) | 2025.03.06 |
| 터미널 명령어 - find 원하는 파일을 찾고 싶다면 (0) | 2025.03.06 |
| 터미널 명령어 - grep 파일 내용 중에 찾고 싶은 값이 있다면 (1) | 2025.03.06 |