source

verb

say it: “SORSS” /sɔrs/

A shell command that runs a file's lines in the shell you are in, so the settings the file makes stay after it finishes.

What does source do?

source runs a file's lines in the shell you're already in, so the aliases, functions and variables it sets stay after it finishes. Running the file with bash file.sh instead hands it to a second shell, which closes when it's done and takes everything it set with it. That's why a change to ~/.bashrc is loaded with source ~/.bashrc. A dot, . ~/.bashrc, means the same.

source ~/.bashrc
. ~/.bashrc          # the same, written with a dot

In a sentence

  • “Running today.sh with bash made the alias vanish, but source today.sh kept it.”
  • “After editing ~/.bashrc, Sam ran source ~/.bashrc so the new aliases worked without opening a new window.”

Level: Apprentice · More Unix terms at this level

Updated