This question already has an answer here:

The command . .bash_profile is used to reload(?) bash_profile. What is the general purpose of the first .? How it can be used and is there a resource to read about these type symbols of Terminal?

marked as duplicate by muru bash Jun 10 '18 at 17:05

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


The command . is a shell built-in. It executes the shell script you give as argument, but within your current shell environment. This is also called "sourcing" a script. In Bash, source is therefore a synonym of . (but e.g. not in sh or in the POSIX standard). Also see What is the difference between "source" and "."?

Sourcing a script (like . ~/.bashrc) is different to regularly running a script (like ~/.bashrc) in that if you run it normally, it will run inside a sub-shell instead of the current shell environment.

A sub-shell has its own working directory, shell options and local variables, so that changing them within the script (e.g. by using cd or setting/changing variables) does not affect the parent shell. If you run a script, it will also only get read access to those local variables of the parent shell which it exported, not the regular ones.

If you want to allow the script to modify your current environment (e.g. to change shell options, set environment variables, create aliases and functions which you then can use, etc), which is the case for .bashrc, you have to source it. If you just ran it, all its changes would be lost as soon as it exits and returns to your shell environment.

More info can be obtained by running help . or help source, and man bash (section about shell built-ins).

  • I thought . and source would have been duplicate by now but I couldn't find one. So +1 :) – WinEunuuchs2Unix Jun 10 '18 at 14:54

I am attaching the output of . --help. This might help you.

.: . filename [arguments]
Execute commands from a file in the current shell.

Read and execute commands from FILENAME in the current shell.  The
entries in $PATH are used to find the directory containing FILENAME.
If any ARGUMENTS are supplied, they become the positional parameters
when FILENAME is executed.

Exit Status:
Returns the status of the last command executed in FILENAME; fails if
FILENAME cannot be read.

Not the answer you're looking for? Browse other questions tagged or ask your own question.