Linux umask, chmod, chown

Linux file Permission check

ls -al

first character is – (file) , d (directory) , l (link)

r : Read  = 4
w : Write = 2
x : eXcute = 1

rwxrwxrwx   ( 777 )
r–r–r–  ( 444 )
rwx--x–x ( 711 )

2~4 field  : User Permission
5~7 field  : Group Permission
8~10 field : Others Permission

 

Change Permission

사용법: chmod [옵션]... MODE[,MODE]... FILE...
  또는: chmod [옵션]... 8진수-MODE FILE...
  또는: chmod [옵션]... --reference=RFILE FILE...
  • ex)
    chmod 755 a_file
    ( Grant permission to Owner 7(rwx), Group and Others 5(r-x) )
    chmod o+rw a_file        
    ( To others read, write permission )
    chmod 700 *                
    ( Change all file and directory permission at Current location  )
    chmod -R 755 www  
    ( Change all file and directory permission at www directory )

 

Default Permission

 usage: umask [-p] [-S] [mode]
  • ex) umask 022
    -> Opposite of chmod. Subtract from 777.  if 022 same as chmod 755,

파일의 경우 666 – umask

참고

 

 

Change Owner

Usage: chown [OPTION]... [OWNER][:[GROUP]] FILE...
   or: chown [OPTION]... --reference=RFILE FILE...
  • ex)
    chown test file1
    ( Change owner of  file1 test )
    chown test:test2 file2
    ( Change owner and group to test and test2 at file2 )
    chown -cR nobody:nobody dirl
    ( Change owner and group at dirl internal file and directory )
    chown -R test:web uploads –from=nobody:nobody
    ( Change owner and group at uploads from nobody:nobody to test:web )