Aller au contenu principal

sh-scripts-cheats

Before Pull: Make .sh scripts executable (chmod quick reference)

GoalCommandNotes / When to use
Make one script runnablechmod +x script.shMost common – adds execute for owner/group/others
Owner onlychmod u+x script.shSafer on shared servers
Everyonechmod a+x *.shOr chmod +x *.sh (same)
Standard for scripts in repochmod 755 script.shrwxr-xr-x – owner full, others read+exec
Fix many at oncefind . -name "*.sh" -exec chmod +x {} \;Recursive in current dir
Check current permsls -l script.shLook for x in permissions

Tip: Always have #!/usr/bin/env bash (or #!/bin/bash) as first line.