What is the difference between `source script.sh` and `./script.sh`?
BeginnerConceptPackages, Shell & Text Tools
Answer
./script.sh runs in a new child process (using the shebang interpreter), so variables and cd do not affect your shell; it needs execute permission. source script.sh (or . script.sh) runs the commands in the current shell, so exported variables and directory changes persist. That is how you load venv/bin/activate or a .env file.
More on Packages, Shell & Text Tools
Compare apt and dnf package management.BeginnerWhat is the difference between `apt upgrade` and `apt full-upgrade`?IntermediateHow do you find which package provides a file or command?BeginnerHow do you pin or hold a package version?IntermediateHow are repositories and their GPG keys configured?AdvancedWhat is the difference between a login shell and an interactive non-login shell?Intermediate