Bash Cheatsheet

  • Test Operators

    -f file
    -z string is empty
    -n string non-empty
    -d directory
    -L symlink
    -r readable
    -w writeable
    -x executable
  • Bash Permissions

    0777 rwx rwx rwx
    0755 rwx r-x r-x
    0644 rw- r– r–
    0600 rw- — —
    0555 r-x r-x r-x
    0444 r– r– r–
    0400 r– — —
  • Bash Checks
    bash -n ./script.sh Check script syntax
    bash -x ./script.sh See what the script is doing