Javatpoint Logo
Javatpoint Logo

Linux Source Command

Source is a built-in shell command. It is used for reading and executing a file's content (generally command set) and it is passed as any argument inside the shell script (current).

The command after getting the specified file's content passes it towards the TCL interpreter like a text script which gets executed.

The arguments become the positional parameters if filename is run when they are supplied.

Otherwise, these positional parameters endure unchanged. In $PATH, the entries are used for finding the directory having FILENAME.

But, if the file is not available in $PATH, it will find a file inside our current directory.

In Linux, the source command includes no option and the file is the argument only.

Syntax of the source command:


  1. The command will find the file inside the $PATH environment variables described by the directories when the FILENAME isn't a complete path to the file.
    The command will search for the file inside our current directory if the file isn't found within the $PATH.
  2. The arguments will become the positional parameters for the FILENAME if they are given.
  3. The source command in Linux has a "0" exit code if the FILENAME presents. Otherwise, it will give "1" when the file isn't found.


1. For passing hello2.txt as the argument which is saved inside our home directory. All commands enlisted within the file will be run line by line.

Linux Source Command

2. For passing the path_name of any file as the argument. The file's content is mentioned as follows:

Linux Source Command

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA