source command executes the provided script (executable permission is not mandatory) in the current shell environment, while ./ executes the provided executable script in a new shell.
source command do have a synonym . filename.
To make it more clear, have a look at the following script, which sets the alias.
make_alias
#! /bin/bash
alias myproject='cd ~/Documents/Projects/2015/NewProject'
Now we have two choices to execute this script. But with only one option, the desired alias for current shell can be created among these two options.
Option 1: ./make_alias
Make script executable first.
chmod +x make_alias
Execute
./make_alias
Verify
alias
Output
**nothing**
Whoops! Alias is gone with the new shell.
Let's go with the second option.
Option 2: source make_alias
Execute
source make_alias
or
. make_alias
Verify
alias
Output
alias myproject='cd ~/Documents/Projects/2015/NewProject'
Yeah Alias is set.
$ type sourcesource is a shell built-in– bnjmn Oct 09 '13 at 06:00$ whatis sourcesource (1) - bash built-in commands, see bash(1). Also,man sourcetakes me to theBASH_BUILTINS(1)man pages. This is on Fedora btw, no idea why those debian packages are un-(or badly)-documented. – arielnmz Aug 20 '14 at 12:29source --helpis a good start. – Thorbjørn Ravn Andersen Mar 13 '18 at 16:45