토요일, 9월 14, 2024
HomeLinuxubuntu File/Directory Permissions

ubuntu File/Directory Permissions

ubuntu File/Directory Permissions

액세스 제한 의 세 가지 유형이 있습니다

Permission   Action   chmod option

read         (view)       r or 4
write        (edit)       w or 2
execute      (execute)    x or 1

사용자 제한 의 세 가지 유형 이있다

User        ls output
owner       -rwx------
group       ----rwx---
other       -------rwx

Folder/Directory Permissions

Permission             Action                     chmod option

read          (view contents, i.e. ls command)       r or 4
write         (create or remove files from dir)      w or 2
execute       (cd into directory)                    x or 1

Permissions in Action

user@host:/home/user$ ls -l /etc/hosts
-rw-r--r--  1 root root 288 2005-11-13 19:24 /etc/hosts
user@host:/home/user$

-rw-r–r–

owner = Read & Write (rw-)
group = Read (r–)
other = Read (r–)

Changing Permissions

user@host:/home/user# ls -l /etc/shadow
-rw-r-----  1 root shadow 869 2005-11-08 13:16 /etc/shadow

Permissions:
owner = Read & Write (rw-)
group = Read (r--)
other = None (---)

Ownership:
owner = root
group = shadow

Usage: chmod {options} filename

Options Definition
u owner
g group
o other
a all (same as ugo)
x execute
w write
r read
+ add permission
– remove permission
= set permission

Owner Group Other

read & write read & write read, write & execute
4+2=6 4+2=6 4+2+1=7

처음 화일 생성

user@host:/home/user$ touch file1 file2 file3 file4
user@host:/home/user$ ls -l
total 0
-rw-r--r--  1 user user 0 Nov 19 20:13 file1
-rw-r--r--  1 user user 0 Nov 19 20:13 file2
-rw-r--r--  1 user user 0 Nov 19 20:13 file3
-rw-r--r--  1 user user 0 Nov 19 20:13 file4

owner 실행권한설정

user@host:/home/user$ chmod 744 file1
user@host:/home/user$ ls -l file1
-rwxr--r--  1 user user 0 Nov 19 20:13 file1

Other 쓰기 & 실행권한설정

user@host:/home/user$ chmod 647 file2
user@host:/home/user$ ls -l file2
-rw-r--rwx  1 user user 0 Nov 19 20:13 file2

everyone 읽시 & 쓰기 & 실행권한설정

user@host:/home/user$ chmod 777 file4
user@host:/home/user$ ls -l file4
-rwxrwxrwx  1 user user 0 Nov 19 20:13 file4

특정 디렉토리 및 하위 디렉토리 모든권한설정

user@host:/home/user$ sudo chmod 777 -R /path/to/someDirectory
user@host:/home/user$ ls -l
total 3
-rwxrwxrwx  1 user user 0 Nov 19 20:13 file1
drwxrwxrwx  2 user user 4096 Nov 19 20:13 folder
-rwxrwxrwx  1 user user 0 Nov 19 20:13 file2

특정 디렉토리 및 하위 디렉토리 owner / group 변경

user@host:/home/user$ ls -l
total 3
-rwxrwxrwx  1 user user 0 Nov 19 20:13 file1
drwxrwxrwx  2 user user 4096 Nov 19 20:13 folder
-rwxrwxrwx  1 user user 0 Nov 19 20:13 file2

user@host:/home/user$ sudo chown -R www-data:www-data /path/to/someDirectory
user@host:/home/user$ ls -l
total 3
-rwxrwxrwx  1 www-data www-data 0 Nov 19 20:13 file1
drwxrwxrwx  2 www-data www-data 4096 Nov 19 20:13 folder
-rwxrwxrwx  1 www-data www-data 0 Nov 19 20:13 file2
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular