DAY 13 - PERMISSION | ACL | MOUNT | DIRECTORY TYPE

r  Three types of permission
 
    o   Read (r)
    o   Write (w)
    o   Execute (x)
 
r  File:
 
    o   Read >> cat/more/less/head/tail/vi
    o   Write >> create/modify/rename/delete
    o   Execute >> Run as a command [type useradd]
 
r  Directory:
 
    o   Read >> ls
    o   Write >> create/modify/rename/delete
    o   Execute >> cd
 
r  Three types of Users
 
    o   Owner/User (u)
    o   Group (g)
    o   Other (o)
 
r  Umask (user mask) – depend define default permission of file & folder.
 
r  Numeric Value:
 
    o   Read                r           4
    o   Write              w          2
    o   Execute           x          1
 
r  Check file permission:
 
    o   ls -l filename[file1]
    o   ls -ld dir1[directory1]
    o   stat filename[file1]
    o   getfacl (facl-file access control list) filename[file1]
 
r  Change File/Directory Permission
 
o   If a file/folder is created by a normal user, the root user can change the permission.
o   If a file/folder is created by a root user, the normal user cannot change the permission.
o   chmod [OPTION] [MODE] [FILE]
o   chmod [OPTION] [OCTAL-MODE] [FILE]

§  + Add
§  - Remove
§  = Assign Value
 
§  chmod u+x filename
§  chmod u+x, g+x filename | chmod ug+x filename
§  chmod u+r, g+w, o+x filename
§  chmod u=rw, g=, o+w filename
§  chmod ugo+x filename
§  chmod a+x filename [a means all permission]
§  chmod +x filename [execute permission for all]
§  chmod ugo-rx filename
§  chmod ugo+rwx dir1
§  chmod -R ugo+rw dir1 [R means permission will be applied for all including inside file/folder]
§  chmod -R ugo+rwx dir1 [File+Folder – Add Execution bit]
§  chmod -R ugo+rwX dir1 [Dir – Add Execution bit]
 
§  chmod 640 file1
 
r  Terminal Multiplexer
 
    o   yum install tmux
    o   Spilt two windows

§  Ctrl+b+” [up/below]
§  Ctrl+b + Shift+% [left/right]

    o   Move one from another window

§  Ctrl+b + right/left arrow
 
r  type id [will be checked location of command]
r  which id
r  whereis id
 
r  Change OwerShip/GroupOwnerShip
 
    o   chown/chgrp > root [Only root user can run]
    o   chown [change ownership/group ownership]
 
§  Owner:
 
        ·         Chown <username> file/dir
        ·         Chown -R <uid> file/dir
 
§  Owner+Group:
 
        ·         chown [OPTION] [OWNER]:[GROUP] [FILE]
        ·         Chown <username>:<groupname> file/dir [behind the change ID]
        ·         Chown -R <uid>:<gid> file/dir
        ·         Chown <username>.<groupname> file/dir
        ·         Chown -R <uid>.<gid> file/dir
 
§  Group:
 
        ·         Chown :<groupname> file/dir
        ·         Chown :<gid> file/dir
        ·         Chown .<groupname> file/dir
        ·         Chown .<gid> file/dir
 
o   chgrp [only group ownership]
 
§  chgrp [OPTION] [GROUP] [FILE]
§  chgrp <groupname> file/dir
§  chgrp <gid> file/dir
 
r  ACL [Access Control List]:
 
        ·         Base ACL – chmod
        ·         Posix ACL – setfacl [selective user, group permission]
        ·         setfacl -m u:<username>:<permission><file/dir> [m means modify, u means user]
        ·         setfacl -m u:<UID>:<rwx><file/dir>
        ·         setfacl -m u:1010:7 file/etc
        ·         setfacl -m g:<UID>:<---><file/dir>
        ·         setfacl -m G:<UID>:<0><file/dir>
        ·         setfacl -m o:<UID>:<0><file/dir>
        ·         getfacl /opt/file1
        ·         setfacl -x u:shohan /opt/file1 [x means remove acl]
        ·         setfacl -b /opt/file1 [b means base acl]
 
r  Mount:
 
        ·         CD-ROM/DVD-ROM/pendrive/USB hard drive/hard disk partition [Accessing device from system]
        ·         mount <whomDevice><whereDirectory>
        ·         mount /dev/sr0 /mnt/
        ·         mount -t <FileSystemType> <whomDevice><whereDirectory>
        ·         mount -t <FileSystemType> -o <Permission> <whomDevice><whereDirectory>
        ·         mount -t <FileSystemType> -o remount <whomDevice><whereDirectory>
 
        ·         lsblk [check block devices]
        ·         cat /proc/sys/dev/cdrom/info [check how any cd-dvd rom are available]
 
 ·         Verify(mount)

        ·         mount
        ·         cat /etc/ mtab
        ·         df -hT
        ·         mount -t xfs/vfat
        ·         mount -t iso9660
 
·         umount <device/mount-point>
    
        ·         umount /dev/sr0 or /mnt/
        ·         umount /dev/sr0 /mnt /dev/sdc [multiple devices unmount]
 
r  Attribute [Nobody can change/delete]:

    o   lsattr file1
    o   chattr +i file1 [Nobody can change/delete immutable file/dir]
    o   chattr -i file1
    o   chattr +a dir [a means append, can be added file/dir not deleted]
    o   chattr -a dir
    o   chattr -aR dir
 
r  Linux File & Directory types:
 
        ·         - = Regular file                                    : text/any file
        ·         d = Directory                                       : Regular directory
        ·         l = Link file                                          : $ ls -l /dev/stdin
        ·         b = Block Device CD/DVD/HDD       : $ ls -l /dev/sda
        ·         s = Socket                                            : $ ls -l /run/rpcbind.sock  
        ·         p = Pipe file                                         : $ ls -l /run/initctl     
        ·         c = Character device                           : $ ls -l /dev/tty
 
r  dr-xr-x---. 14 root root 4096 Jul 15 16:08 .
 
dr-xr-x---: File permissions

        ·         d: Indicates it is a directory.
        ·         r-x: Owner (root) has read and execute permissions.
        ·         r-x: Group (root) has read and execute permissions.
        ·         ---: Others have no permissions.

14: Number of hard links to the directory.
root: Owner of the directory.
root: Group of the directory.
4096: Size of the directory in bytes.
Jul 15 16:08: Last modification date and time of the directory.
.: The name of the directory (in this case, it refers to the current directory).

Previous Post Next Post

نموذج الاتصال