Linux user permissions and ACL — Bird's Linux Private Kitchen notes

Contents

  1. 1. Permission management
    1. 1.1. User permissions
      1. 1.1.1. Understanding /etc/shadow
      2. 1.1.2. useradd
      3. 1.1.3. usermod
      4. 1.1.4. userdel
      5. 1.1.5. passwd
      6. 1.1.6. chage
    2. 1.2. Group permissions
      1. 1.2.1. groupadd
      2. 1.2.2. groupmod
      3. 1.2.3. groupdel
      4. 1.2.4. groups
      5. 1.2.5. gpasswd
      6. 1.2.6. newgrp
      7. 1.2.7. finger
      8. 1.2.8. chfn
      9. 1.2.9. chsh
      10. 1.2.10. id
    3. 1.3. ACL control
      1. 1.3.1. setfacl
      2. 1.3.2. getfacl

Notes from Bird’s Linux Private Kitchen (3rd edition), kept for quick review.

Permission management

User permissions

Understanding /etc/shadow

useradd

  • -u UID
  • -c ‘msg’
  • -g initial group
  • -G supplementary groups
  • -d home directory
  • -s shell
  • -e YYYY-MM-DD # password expiration date
  • -f num # days after password expiry the account may still be used; -1 = never lock; 0 = lock immediately
  • -D # show defaults

usermod

  • -L # lock
  • -U # unlock
  • -aG group_name # append supplementary groups instead of replacing
  • other flags same as useradd

userdel

  • -r # remove home directory

passwd

  • -l # lock user
  • -u # unlock
  • -S # show password status
  • -n num # minimum days between password changes
  • -x num # maximum days before password must change
  • -w num # warn this many days before deadline
  • -i YYYY-MM-DD # password inactive after this date
  • –stdin # set password from a pipe

chage

  • -l # show password aging info
  • -d YYYY-MM-DD # last password change; 0 forces change on next login
  • -m num # minimum days between changes
  • -M num # maximum days before change required
  • -w num # warn days before deadline
  • -I YYYY-MM-DD # password inactive date
  • -E YYYY-MM-DD # account expiration date

Group permissions

groupadd

  • -g GID
  • -r system group

groupmod

  • -g GID
  • -n new group name

groupdel

groups

  • first line shown is the effective group

gpasswd

  • gpasswd group # set group password
  • -A user group # set group administrator
  • -a user group # add member

newgrp

  • switch effective group

finger

  • finger user # plan text: echo 'str' >~/.plan

chfn

  • -f # full name
  • -o # office
  • -p # phone
  • -h # home phone

chsh

  • -l # list shells
  • -s # change your shell

id

  • id newbmiao # inspect account attributes

ACL control

setfacl

  • -m u:[users]:rwx file
  • -m d:u:[users]:rwx dir # default ACL for new children
  • -m g:[groups]:rwx file
  • -m m:rwx file # mask — effective permission is intersected with mask (caps maximum permission)
  • -b file # remove ACL

getfacl

Questions? Leave a comment below or email: newbvirgil@gmail.com