{"id":14094,"date":"2023-07-25T07:18:00","date_gmt":"2023-07-25T07:18:00","guid":{"rendered":"https:\/\/linuxsimply.com\/?p=14094"},"modified":"2023-12-06T06:59:32","modified_gmt":"2023-12-06T06:59:32","slug":"bash-source","status":"publish","type":"post","link":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/","title":{"rendered":"What Are the Usages of Bash Source [3 Practical Examples]"},"content":{"rendered":"<p style=\"text-align: justify;\">In <strong>Bash <\/strong>scripting, sourcing a script allows you to run the commands within the script in the current shell session, rather than launching a new subshell. And this entire process is much more useful when you need to load environment variables, define functions, or execute commands that should affect the current shell session. In this article, I will explain the concept of <strong>sourcing in Bash<\/strong> with practical examples.<\/p>\n<div class=\"su-youtube su-u-responsive-media-yes\"><iframe width=\"600\" height=\"400\" src=\"https:\/\/www.youtube.com\/embed\/-7o5gunOEs4?\" frameborder=\"0\" allowfullscreen allow=\"autoplay; encrypted-media; picture-in-picture\" title=\"\"><\/iframe><\/div>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/#Key_Takeaways\" >Key Takeaways<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/#Free_Downloads\" >Free Downloads<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/#Difference_Between_Executing_vs_Sourcing_a_Bash_Script\" >Difference Between Executing vs Sourcing a Bash Script<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/#3_Practical_Examples_of_Bash_Source\" >3 Practical Examples of Bash Source<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/#Example_1_Sourcing_a_Script_Using_the_Bash_%E2%80%9Csource%E2%80%9D_Command\" >Example 1: Sourcing a Script Using the Bash &#8220;source&#8221; Command<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/#Example_2_Sourcing_Functions_Using_the_Bash_%E2%80%9Csource%E2%80%9D_Command\" >Example 2: Sourcing Functions Using the Bash &#8220;source&#8221; Command<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/#Example_3_Modifying_the_Current_Shell_Environment\" >Example 3: Modifying the Current Shell Environment<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/#People_Also_Ask\" >People Also Ask<\/a><\/li><\/ul><\/nav><\/div>\n<h3><span class=\"ez-toc-section\" id=\"Key_Takeaways\"><\/span>Key Takeaways<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li>Learning the concept of Bash sourcing.<\/li>\n<li>Seeing the process through practical examples.<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"Free_Downloads\"><\/span>Free Downloads<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<div class=\"su-button-center\"><a href=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/Practice-files-of-bash_source.zip\" class=\"su-button su-button-style-default\" style=\"color:#000000;background-color:#e8f9ff;border-color:#bac8cc;border-radius:56px\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"color:#000000;padding:8px 26px;font-size:20px;line-height:30px;border-color:#effbff;border-radius:56px;text-shadow:0px 0px 0px #000000\"><i class=\"sui sui-download\" style=\"font-size:20px;color:#1aa1d6\"><\/i> Download the Practice Files<\/span><\/a><\/div>\n<h3><span class=\"ez-toc-section\" id=\"Difference_Between_Executing_vs_Sourcing_a_Bash_Script\"><\/span>Difference Between Executing vs Sourcing a Bash Script<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">When you source or execute a script, the commands in the script are run line by line as if you typed them manually. Here are the key differences:<\/p>\n<p style=\"text-align: left;\"><span style=\"color: #800080;\"><strong>Executing a Script &gt;<\/strong><\/span><\/p>\n<p><span style=\"font-weight: 400;\"><div class=\"su-list\" style=\"margin-left:8px\"><\/span><\/p>\n<ul>\n<li><i class=\"sui sui-arrow-right\" style=\"color:#000000\"><\/i> Opens a new shell, runs the commands in that shell, and returns the output to your current shell.<\/li>\n<li><i class=\"sui sui-arrow-right\" style=\"color:#000000\"><\/i> Changes made to the environment are limited to the new shell and are lost once it is closed.<\/li>\n<li><i class=\"sui sui-arrow-right\" style=\"color:#000000\"><\/i> Use it when you want to run the script independently without affecting your current shell.<\/li>\n<li><i class=\"sui sui-arrow-right\" style=\"color:#000000\"><\/i> Use the command syntax <strong>\u2018.\/filename.sh\u2019<\/strong> to execute a file.<\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\"><\/div><\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"color: #800080;\"><strong>Sourcing a Script &gt;<\/strong><\/span><\/p>\n<p><span style=\"font-weight: 400;\"><div class=\"su-list\" style=\"margin-left:8px\"><\/span><\/p>\n<ul>\n<li><i class=\"sui sui-arrow-right\" style=\"color:#000000\"><\/i> Runs the commands directly in your current shell.<\/li>\n<li><i class=\"sui sui-arrow-right\" style=\"color:#000000\"><\/i> Changes made to the environment take effect and persist in your current shell.<\/li>\n<li><i class=\"sui sui-arrow-right\" style=\"color:#000000\"><\/i> Use it when you want the script to modify the environment in your current shell.<\/li>\n<li><i class=\"sui sui-arrow-right\" style=\"color:#000000\"><\/i> Use the command syntax <strong>\u2018. filename.sh\u2019<\/strong> or <strong>\u2018source filename.sh\u2019<\/strong> to source a file.<\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\"><\/div><\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"3_Practical_Examples_of_Bash_Source\"><\/span>3 Practical Examples of Bash Source<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">In this article, I will try to explain the concept of <strong>Bash<\/strong> sourcing with 3 practical examples. So that you can get a clearer overview of how <strong>sourcing in Bash<\/strong> works.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Example_1_Sourcing_a_Script_Using_the_Bash_%E2%80%9Csource%E2%80%9D_Command\"><\/span>Example 1: Sourcing a Script Using the Bash &#8220;source&#8221; Command<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">In this example, I will simply source a script using the &#8216;<a href=\"https:\/\/linuxsimply.com\/source-command-in-linux\/\" target=\"_blank\" rel=\"noopener\"><strong>source command<\/strong><\/a>&#8216;. You can also use the &#8216;<strong><a href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/dot-command\/\" target=\"_blank\" rel=\"noopener\">dot command<\/a><\/strong>&#8216; which is basically a\u00a0shorter approach for the <strong>source command<\/strong>. In other words, <strong>a symbol (.) <\/strong>that represents the <strong>source<\/strong> command. Here, I will utilize the \u2018<strong>env_setup.sh<\/strong>\u2019 script that sets up some <strong>environment variables<\/strong>. Please go through the below steps to see the whole process:<\/p>\n<p><span style=\"color: #800080;\"><strong>Steps to Follow &gt;<\/strong><\/span><\/p>\n<p>\u2776 At first, open your <strong>Ubuntu Terminal<\/strong> application.<\/p>\n<p>\u2777 Now, let\u2019s check out the contents of the script:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#! \/bin\/bash\n\nexport MY_VARIABLE=\u201dHello, World!\u201d<\/code><\/pre>\n<p style=\"text-align: justify;\"><div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#e1e3e6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\">EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\">\n<ul style=\"text-align: justify;\">\n<li><strong>#! \/bin\/bash<\/strong>: <strong>shebang <\/strong>or <strong>hashbang<\/strong>. It indicates the interpreter to be used for executing the script, in this case, it\u2019s <strong>bash<\/strong>.<\/li>\n<li><a href=\"https:\/\/linuxsimply.com\/export-command-in-linux\/\" target=\"_blank\" rel=\"noopener\"><strong>export<\/strong><\/a><strong>: <\/strong>Makes the environment variables available to the child processes for the current shell session.<\/li>\n<li><strong>MY_VARIABLE: <\/strong>Variable name.<\/li>\n<li><strong>\u201cHello, World!\u201d: <\/strong>Variable value.<\/div><\/div><\/li>\n<\/ul>\n<p style=\"text-align: justify;\">\u278c Now to source the \u2018<strong>env_setup.sh<\/strong>\u2019 script, write the following command in your command prompt &amp; press <strong>ENTER<\/strong>:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">source env.sh<\/code><\/pre>\n<p style=\"text-align: justify;\"><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-full wp-image-14103\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/1.-Source-a-bash-script-file.png\" alt=\"Source a bash script file\" width=\"700\" height=\"147\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/1.-Source-a-bash-script-file.png 700w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/1.-Source-a-bash-script-file-300x63.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/1.-Source-a-bash-script-file-767x161.png 767w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><div class=\"su-note\"  style=\"border-color:#cedfe2;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#e8f9fc;border-color:#ffffff;color:#333333;\">\n<p style=\"text-align: justify;\"><strong>NOTE:<\/strong> You won\u2019t see any output on the terminal, but the environment variable<strong> \u2018MY_VARIABLE\u2019<\/strong> is defined in the current shell session. And, you can access the variable value using the &#8216;<strong><a href=\"https:\/\/linuxsimply.com\/echo-command-in-linux\/\" target=\"_blank\" rel=\"noopener\">echo command<\/a>&#8216;<\/strong>.<\/div><\/div>\n<p style=\"text-align: justify;\">\u278d Now, let\u2019s access the value of <strong>\u201cMY_VARIABLE\u201d<\/strong> using the following command:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">echo $MY_VARIABLE<\/code><\/pre>\n<p style=\"text-align: justify;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-14104\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/2.-Load-a-variable.png\" alt=\"Load a variable\" width=\"700\" height=\"182\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/2.-Load-a-variable.png 700w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/2.-Load-a-variable-300x78.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/2.-Load-a-variable-765x199.png 765w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/>From the output image, you can see the <strong>MY_VARIABLE<\/strong> has been sourced to the current shell session successfully, as a result, it loads the value when called upon.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Example_2_Sourcing_Functions_Using_the_Bash_%E2%80%9Csource%E2%80%9D_Command\"><\/span>Example 2: Sourcing Functions Using the Bash &#8220;source&#8221; Command<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">Let\u2019s consider two scripts, <strong>\u201cHello.sh\u201d <\/strong>and <strong>\u201cOlleh.sh<\/strong>\u201d. In <strong>\u201cHello.sh\u201d<\/strong>, you want to source and use a function that is defined in <strong>\u201cOlleh.sh\u201d<\/strong>. You can do that using the <strong>source<\/strong> command.\u00a0 That way you don\u2019t need to define the same function again for the second script. For that, let\u2019s check out the contents of the two scripts:<\/p>\n<p><span style=\"color: #800080;\"><strong>Script (Olleh.sh) &gt;<\/strong><\/span><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#! \/bin\/bash\n\n#Defining function\nhello_world () {\n\u00a0\u00a0 echo \u201cHello, world!\u201d\n}<\/code><\/pre>\n<p style=\"text-align: justify;\"><div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#e1e3e6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\">EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\"> The script defines a function named <strong>\u2018hello_world\u2019<\/strong> &amp; the empty parentheses <strong>\u2018{ }\u2019<\/strong> indicates that the function does not accept any <strong>arguments<\/strong>. After that, the opening &amp; ending curly braces indicate the start &amp; end of the function body with the <strong>echo command <\/strong>as the body.<\/div><\/div>\n<p><span style=\"color: #800080;\"><strong>Script (Hello.sh) &gt;<\/strong><\/span><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#! \/bin\/bash\n\n#Sourcing Olleh.sh using the source command\nsource Olleh.sh\n\n#Calling the function defined in Olleh.sh\nhello_world<\/code><\/pre>\n<p style=\"text-align: justify;\"><div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#e1e3e6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\">EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\">The script uses the <strong>\u2018source\u2019 <\/strong>command to source the contents of the <strong>\u2018Olleh.sh\u2019<\/strong> script. The script proceeds to call a function named <strong>\u2018hello_world\u2019<\/strong> that is defined in <strong>\u2018Olleh.sh\u2019.<\/strong><\/div><\/div>\n<p style=\"text-align: justify;\">Now to source the defined function of the <strong>\u2018Olleh.sh\u2019<\/strong> script to the <strong>\u2018Hello.sh\u2019 <\/strong>script\u2018 run the following command in your command prompt &amp; press <strong>ENTER<\/strong>:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">.\/Hello.sh<\/code><\/pre>\n<p style=\"text-align: justify;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-14107\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/5.-Running-a-script.png\" alt=\"source a bash script \" width=\"700\" height=\"165\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/5.-Running-a-script.png 700w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/5.-Running-a-script-300x71.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/5.-Running-a-script-768x181.png 768w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/>The output of the <strong>Hello.sh <\/strong>script is the \u2018<strong>defined function\u2019<\/strong> of <strong>Olleh.sh<\/strong> script.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Example_3_Modifying_the_Current_Shell_Environment\"><\/span>Example 3: Modifying the Current Shell Environment<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">In this example, we will source a script that defines aliases. <a href=\"https:\/\/linuxsimply.com\/alias-command-in-linux\/\" target=\"_blank\" rel=\"noopener\"><strong>Aliases<\/strong><\/a> are shortcuts for longer commands or command combinations. Once sourced, <strong>Bash<\/strong> reads the contents of the script and applies these aliases as if they were directly defined in your current shell session, saving you from typing lengthy command combinations repeatedly.<\/p>\n<p><span style=\"color: #800080;\"><strong>Script (aliases.sh) &gt;<\/strong><\/span><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#! \/bin\/bash\n\n#Defining aliases\nalias ll=\u201dls -l | grep Downloads\u201d\nalias new=\u201dneofetch --ascii distro windows | lolcat\u201d<\/code><\/pre>\n<p style=\"text-align: justify;\"><div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#e1e3e6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\">EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\"> The script defines aliases ( <strong>ll<\/strong> &amp; <strong>new<\/strong>) for longer commands <strong>\u2018ls -l | grep Downloads<\/strong>\u2019 &amp; \u2018<strong>neofetch \u2013ascii distro windows | lolcat<\/strong>\u2019.<\/div><\/div>\n<p>Now, write the following command to source the <strong>aliases<\/strong> written in the upper script:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">source aliases.sh<\/code><\/pre>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14105\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/3.-Source-defined-aliases.png\" alt=\"Source defined bash aliases\" width=\"700\" height=\"141\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/3.-Source-defined-aliases.png 700w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/3.-Source-defined-aliases-300x60.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/3.-Source-defined-aliases-765x154.png 765w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/>To check if the<strong> aliases<\/strong> are sourced successfully in the current shell session, just type the <strong>aliases<\/strong> &amp; check the output like the following image:<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14106\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/4.-Loading-aliases.png\" alt=\"Load values of defined aliases\" width=\"825\" height=\"209\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/4.-Loading-aliases.png 825w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/4.-Loading-aliases-300x76.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/4.-Loading-aliases-766x194.png 766w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/> From the output image, you can see, as the aliases are sourced successfully. So whenever I type them ( <strong>\u2018ll\u2019 <\/strong>&amp;<strong> \u2018new\u2019 <\/strong>) &amp; simply press <strong>ENTER<\/strong>, as the output I get the output of the confined commands.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">To sum up, <strong>Bash source<\/strong> is a powerful feature that allows you to execute commands, load variables, and import functions from files directly into your current shell session. In this article, I tried to clarify the concept of sourcing with some practical examples. Hope you find this helpful!<\/p>\n<h2><span class=\"ez-toc-section\" id=\"People_Also_Ask\"><\/span>People Also Ask<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\"><div class=\"su-accordion su-u-trim\">\n<p style=\"text-align: justify;\"><div class=\"su-spoiler su-spoiler-style-fancy su-spoiler-icon-plus\" data-scroll-offset=\"0\" data-anchor-in-url=\"no\"><div class=\"su-spoiler-title\" tabindex=\"0\" role=\"button\"><span class=\"su-spoiler-icon\"><\/span><strong>What does source in Bash do?<\/strong><\/div><div class=\"su-spoiler-content su-u-clearfix su-u-trim\"> When you use the <strong>\u2018source\u2019<\/strong> command with a script, it effectively merges the contents of the script with the current shell environment, making any changes or definitions within the script immediately available in the current session. <\/div><\/div>\n<p style=\"text-align: justify;\"><div class=\"su-spoiler su-spoiler-style-fancy su-spoiler-icon-plus su-spoiler-closed\" data-scroll-offset=\"0\" data-anchor-in-url=\"no\"><div class=\"su-spoiler-title\" tabindex=\"0\" role=\"button\"><span class=\"su-spoiler-icon\"><\/span><strong>What is Bash source file?<\/strong><\/div><div class=\"su-spoiler-content su-u-clearfix su-u-trim\"> In <strong>Bash<\/strong>, a <strong>\u2018source file\u2019 <\/strong>refers to a script file that is read and executed within the current shell session using the<strong> \u2018source\u2019 <\/strong>command or its shorthand notation, the period <strong>( . )<\/strong> symbol. <\/div><\/div>\n<p style=\"text-align: justify;\"><div class=\"su-spoiler su-spoiler-style-fancy su-spoiler-icon-plus su-spoiler-closed\" data-scroll-offset=\"0\" data-anchor-in-url=\"no\"><div class=\"su-spoiler-title\" tabindex=\"0\" role=\"button\"><span class=\"su-spoiler-icon\"><\/span><strong>Why use the source () command?<\/strong><\/div><div class=\"su-spoiler-content su-u-clearfix su-u-trim\">The <strong>source<\/strong> command in <strong>Bash<\/strong> is used for several reasons and offers specific advantages over executing a script as an independent process. Such as modifying the current shell environment, preserving variable assignments, loading functions &amp; aliases, etc.<\/div><\/div>\n<p style=\"text-align: justify;\"><div class=\"su-spoiler su-spoiler-style-fancy su-spoiler-icon-plus su-spoiler-closed\" data-scroll-offset=\"0\" data-anchor-in-url=\"no\"><div class=\"su-spoiler-title\" tabindex=\"0\" role=\"button\"><span class=\"su-spoiler-icon\"><\/span><strong>What is sourcing a shell script?<\/strong><\/div><div class=\"su-spoiler-content su-u-clearfix su-u-trim\"> Sourcing a shell script means running the commands directly in your current shell. And changes made to the environment take effect and persist in your current shell. Source a script when you want the script to modify the environment in your current shell.<\/div><\/div>\n<p style=\"text-align: justify;\"><\/div>\n<p><span style=\"font-size: 18pt; color: #003366;\"><strong>Related Articles<\/strong><\/span><\/p>\n<ul>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/make-file-executable\/\" target=\"_blank\" rel=\"noopener\">How to make a File Executable in Bash [2 Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/dot-command\/\" target=\"_blank\" rel=\"noopener\">A Complete Overview of Bash Dot Command [With 2 Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-a-script\/\" target=\"_blank\" rel=\"noopener\">How to Run a Bash Script [2 Methods with Cases]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/\" target=\"_blank\" rel=\"noopener\">How to Run Bash Commands in Parallel [4 Ways with Examples]<\/a><\/strong><\/li>\n<\/ul>\n<hr \/>\n<p><strong>&lt;&lt; Go Back to <span data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Executing Bash Script&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:1065857,&quot;3&quot;:{&quot;1&quot;:0},&quot;10&quot;:1,&quot;11&quot;:4,&quot;12&quot;:0,&quot;17&quot;:1,&quot;23&quot;:1}\" data-sheets-hyperlink=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/\"><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/\" target=\"_blank\" rel=\"noopener\">Executing Bash Script<\/a><\/span> | <span data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Bash Scripting Basics&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:16768,&quot;10&quot;:1,&quot;11&quot;:4,&quot;17&quot;:1}\" data-sheets-hyperlink=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/\"><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/\" target=\"_blank\" rel=\"noopener\">Bash Scripting Basics<\/a> <\/span>| <a href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/\" target=\"_blank\" rel=\"noopener\">Bash Scripting Tutorial<\/a><\/strong><\/p>\n\n\n<div class=\"kk-star-ratings kksr-auto kksr-align-center kksr-valign-bottom\"\n    data-payload='{&quot;align&quot;:&quot;center&quot;,&quot;id&quot;:&quot;14094&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;bottom&quot;,&quot;ignore&quot;:&quot;&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;class&quot;:&quot;&quot;,&quot;count&quot;:&quot;0&quot;,&quot;legendonly&quot;:&quot;&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;0&quot;,&quot;starsonly&quot;:&quot;&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;5&quot;,&quot;greet&quot;:&quot;Rate this post&quot;,&quot;legend&quot;:&quot;0\\\/5 - (0 votes)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;title&quot;:&quot;What Are the Usages of Bash Source [3 Practical Examples]&quot;,&quot;width&quot;:&quot;0&quot;,&quot;_legend&quot;:&quot;{score}\\\/{best} - ({count} {votes})&quot;,&quot;font_factor&quot;:&quot;1.25&quot;}'>\n            \n<div class=\"kksr-stars\">\n    \n<div class=\"kksr-stars-inactive\">\n            <div class=\"kksr-star\" data-star=\"1\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"2\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"3\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"4\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"5\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n    \n<div class=\"kksr-stars-active\" style=\"width: 0px;\">\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n<\/div>\n                \n\n<div class=\"kksr-legend\" style=\"font-size: 19.2px;\">\n            <span class=\"kksr-muted\">Rate this post<\/span>\n    <\/div>\n    <\/div>\n","protected":false},"excerpt":{"rendered":"<p>In Bash scripting, sourcing a script allows you to run the commands within the script in the current shell session, &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"What Are the Usages of Bash Source [3 Practical Examples]\" class=\"read-more button\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/#more-14094\" aria-label=\"Read more about What Are the Usages of Bash Source [3 Practical Examples]\">Read more<\/a><\/p>\n","protected":false},"author":314897,"featured_media":14108,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[102],"tags":[113],"class_list":["post-14094","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bash-scripting","tag-executing-bash-script","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>What Are the Usages of Bash Source [3 Practical Examples]<\/title>\n<meta name=\"description\" content=\"The bash source command reads and executes any bash script file within the current shell session as if it was typed directly into the shell.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What Are the Usages of Bash Source [3 Practical Examples]\" \/>\n<meta property=\"og:description\" content=\"The bash source command reads and executes any bash script file within the current shell session as if it was typed directly into the shell.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/\" \/>\n<meta property=\"og:site_name\" content=\"LinuxSimply\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/moniramunny05\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-25T07:18:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-06T06:59:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/bash-source-command.png\" \/>\n\t<meta property=\"og:image:width\" content=\"400\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Monira Akter Munny\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Monira Akter Munny\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/source\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/source\\\/\"},\"author\":{\"name\":\"Monira Akter Munny\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/person\\\/2d8ccee92571d892b55ef5999761fc9e\"},\"headline\":\"What Are the Usages of Bash Source [3 Practical Examples]\",\"datePublished\":\"2023-07-25T07:18:00+00:00\",\"dateModified\":\"2023-12-06T06:59:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/source\\\/\"},\"wordCount\":1317,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/source\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/bash-source-command.png\",\"keywords\":[\"executing bash script\"],\"articleSection\":[\"Bash Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/source\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/source\\\/\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/source\\\/\",\"name\":\"What Are the Usages of Bash Source [3 Practical Examples]\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/source\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/source\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/bash-source-command.png\",\"datePublished\":\"2023-07-25T07:18:00+00:00\",\"dateModified\":\"2023-12-06T06:59:32+00:00\",\"description\":\"The bash source command reads and executes any bash script file within the current shell session as if it was typed directly into the shell.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/source\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/source\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/source\\\/#primaryimage\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/bash-source-command.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/bash-source-command.png\",\"width\":400,\"height\":400,\"caption\":\"bash source\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/source\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Bash Scripting Tutorial\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Bash Scripting Basics\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Executing Bash script\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"What Are the Usages of Bash Source [3 Practical Examples]\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#website\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/\",\"name\":\"LinuxSimply\",\"description\":\"All About Linux\",\"publisher\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/linuxsimply.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#organization\",\"name\":\"LinuxSimply\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/LinuxSimply-New-Logo-Without-Icon.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/LinuxSimply-New-Logo-Without-Icon.png\",\"width\":355,\"height\":48,\"caption\":\"LinuxSimply\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/person\\\/2d8ccee92571d892b55ef5999761fc9e\",\"name\":\"Monira Akter Munny\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Monira-Akter-Munny-II-96x96.png\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Monira-Akter-Munny-II-96x96.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Monira-Akter-Munny-II-96x96.png\",\"caption\":\"Monira Akter Munny\"},\"description\":\"Hello!! This is Monira Akter Munny. I'm a Linux content developer executive here, at SOFTEKO company. I have completed my B.Sc. in Engineering from Rajshahi University of Engineering &amp; Technology in the Electrical &amp; Electronics department. I'm more of an online gaming person who also loves to read blogs &amp; write. As an open-minded person ready to learn &amp; adapt to new territory, I'm always excited to explore the Linux world &amp; share it with you! Read Full Bio\",\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/moniramunny05\",\"https:\\\/\\\/www.instagram.com\\\/monira_munny\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/monira-akter-munny-a76742113\\\/\"],\"url\":\"https:\\\/\\\/linuxsimply.com\\\/author\\\/munny\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What Are the Usages of Bash Source [3 Practical Examples]","description":"The bash source command reads and executes any bash script file within the current shell session as if it was typed directly into the shell.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/","og_locale":"en_US","og_type":"article","og_title":"What Are the Usages of Bash Source [3 Practical Examples]","og_description":"The bash source command reads and executes any bash script file within the current shell session as if it was typed directly into the shell.","og_url":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/","og_site_name":"LinuxSimply","article_author":"https:\/\/www.facebook.com\/moniramunny05","article_published_time":"2023-07-25T07:18:00+00:00","article_modified_time":"2023-12-06T06:59:32+00:00","og_image":[{"width":400,"height":400,"url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/bash-source-command.png","type":"image\/png"}],"author":"Monira Akter Munny","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Monira Akter Munny","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/#article","isPartOf":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/"},"author":{"name":"Monira Akter Munny","@id":"https:\/\/linuxsimply.com\/#\/schema\/person\/2d8ccee92571d892b55ef5999761fc9e"},"headline":"What Are the Usages of Bash Source [3 Practical Examples]","datePublished":"2023-07-25T07:18:00+00:00","dateModified":"2023-12-06T06:59:32+00:00","mainEntityOfPage":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/"},"wordCount":1317,"commentCount":0,"publisher":{"@id":"https:\/\/linuxsimply.com\/#organization"},"image":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/bash-source-command.png","keywords":["executing bash script"],"articleSection":["Bash Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/","url":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/","name":"What Are the Usages of Bash Source [3 Practical Examples]","isPartOf":{"@id":"https:\/\/linuxsimply.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/#primaryimage"},"image":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/bash-source-command.png","datePublished":"2023-07-25T07:18:00+00:00","dateModified":"2023-12-06T06:59:32+00:00","description":"The bash source command reads and executes any bash script file within the current shell session as if it was typed directly into the shell.","breadcrumb":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/#primaryimage","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/bash-source-command.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/bash-source-command.png","width":400,"height":400,"caption":"bash source"},{"@type":"BreadcrumbList","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/linuxsimply.com\/"},{"@type":"ListItem","position":2,"name":"Bash Scripting Tutorial","item":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/"},{"@type":"ListItem","position":3,"name":"Bash Scripting Basics","item":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/"},{"@type":"ListItem","position":4,"name":"Executing Bash script","item":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/"},{"@type":"ListItem","position":5,"name":"What Are the Usages of Bash Source [3 Practical Examples]"}]},{"@type":"WebSite","@id":"https:\/\/linuxsimply.com\/#website","url":"https:\/\/linuxsimply.com\/","name":"LinuxSimply","description":"All About Linux","publisher":{"@id":"https:\/\/linuxsimply.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/linuxsimply.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/linuxsimply.com\/#organization","name":"LinuxSimply","url":"https:\/\/linuxsimply.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/#\/schema\/logo\/image\/","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/LinuxSimply-New-Logo-Without-Icon.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/LinuxSimply-New-Logo-Without-Icon.png","width":355,"height":48,"caption":"LinuxSimply"},"image":{"@id":"https:\/\/linuxsimply.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/linuxsimply.com\/#\/schema\/person\/2d8ccee92571d892b55ef5999761fc9e","name":"Monira Akter Munny","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Monira-Akter-Munny-II-96x96.png","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Monira-Akter-Munny-II-96x96.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Monira-Akter-Munny-II-96x96.png","caption":"Monira Akter Munny"},"description":"Hello!! This is Monira Akter Munny. I'm a Linux content developer executive here, at SOFTEKO company. I have completed my B.Sc. in Engineering from Rajshahi University of Engineering &amp; Technology in the Electrical &amp; Electronics department. I'm more of an online gaming person who also loves to read blogs &amp; write. As an open-minded person ready to learn &amp; adapt to new territory, I'm always excited to explore the Linux world &amp; share it with you! Read Full Bio","sameAs":["https:\/\/www.facebook.com\/moniramunny05","https:\/\/www.instagram.com\/monira_munny\/","https:\/\/www.linkedin.com\/in\/monira-akter-munny-a76742113\/"],"url":"https:\/\/linuxsimply.com\/author\/munny\/"}]}},"_links":{"self":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts\/14094","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/users\/314897"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/comments?post=14094"}],"version-history":[{"count":0,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts\/14094\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/media\/14108"}],"wp:attachment":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/media?parent=14094"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/categories?post=14094"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/tags?post=14094"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}