source

Linux · Terminal · reference only

What it does

Runs a script inside the current shell, so the variables, aliases and functions it defines stay available in your session.

Syntax

source fichero [argumentos...]
. fichero [argumentos...]

Options and parameters

  • fichero

    Script that is run in the current shell.

  • argumentos

    Positional parameters the script receives as $1, $2...

  • . (punto)

    Short equivalent form of source, valid in any POSIX shell.

  • --

    Can be written before the name if the file starts with a dash.

Usage examples

  • source ~/.bashrc

    Reloads your bash configuration without closing the terminal.

  • source entorno.sh

    Loads into the current session the variables defined in a script.

  • source venv/bin/activate

    Activates a Python virtual environment.

  • . ./variables.env

    Uses the short form to load a variables file.

Notes and common mistakes

  • If you run the script as ./script.sh a child shell is started and its variables disappear when it ends; with source they persist.
  • An exit inside the script would close your current session.

Related commands