Bourne – Different ways to execute a script

1. The following 2 types of syntax are both ways to execute a script. Using these methods a second shell will be opened and once the script has finished the variables will not persist.

chmod +x [script]
sh [script]

2. Below shows you a way in which you can run your script using the current shell, and once the script has finished the variables will persist.
This would be useful in a scenario when you were making changes to your profile variables and wanted to activate the changes without logging off.

. [script]

3. The final way terminates you current shell, and spawns a new shell in order to run the script. Once the script has completed the user will be logged off.
This can be useful to isolate and restrict certain users and their profiles.

exec [script]

Rick Donato

Want to become a Linux expert?

Here is our hand-picked selection of the best courses you can find online:
Linux Mastery course
Linux Administration Bootcamp
and our recommended certification practice exams:
AlphaPrep Practice Tests - Free Trial