{"id":139361,"date":"2026-01-26T04:22:57","date_gmt":"2026-01-26T04:22:57","guid":{"rendered":"\/tutorials\/?p=139361"},"modified":"2026-03-09T19:16:03","modified_gmt":"2026-03-09T19:16:03","slug":"bash-scripting-tutorial","status":"publish","type":"post","link":"\/ng\/tutorials\/bash-scripting-tutorial\/","title":{"rendered":"What is a bash script and how to use it?"},"content":{"rendered":"<?xml encoding=\"utf-8\" ?><p>If you&rsquo;ve ever used a Linux operating system, you may have heard of bash. It&rsquo;s a Unix shell that reads and executes various commands.<\/p><p>When you need to run several bash commands, you don&rsquo;t have to execute them manually one at a time. Instead, it&rsquo;s possible to create a script file that contains bash functions to run those commands.<\/p><p>It may sound complicated, but by learning its basics, you will understand the bash scripting language and find out how it can help your workflow.<\/p><p>This article will cover the process of bash scripting. We&rsquo;ll go over everything from bash commands to running a bash program on a Linux terminal.<\/p><h2 class=\"wp-block-heading\" id=\"h-what-is-bash\">What is bash?<\/h2><p>Bash, short for <strong>Bourne-Again Shell<\/strong>, is a Unix shell and a command language interpreter. It reads shell commands and interacts with the operating system to execute them.<\/p><p>To fully understand bash shell scripting, you need to know two concepts &ndash; <strong>shell<\/strong> and <strong>scripting<\/strong>.<\/p><p>Shell is a macro processor that uses commands to interact with the operating system. This means that it can retrieve, process, and store information on a computer.<\/p><p>Meanwhile, scripting is the process of compiling shell commands into a new file using a text editor.<\/p><p>When you write bash in a text editor, you&rsquo;re compiling <strong>bash commands<\/strong> or<strong> bash functions<\/strong> &ndash; a set of commands that can be called numerous times by only using the function name. The text is then saved as an executable <strong>bash script<\/strong> file with the <strong>.sh <\/strong>extension.&nbsp;<\/p><h2 class=\"wp-block-heading\" id=\"h-why-should-you-use-a-bash-script\">Why should you use a bash script?<\/h2><p>Bash scripts can help with your workflow as they compile many lengthy commands into a single executable script file.<\/p><p>For example, if you have multiple commands that you have to run at a specific time interval, you can compile a bash script instead of typing and executing the commands manually one by one. You only need to execute the script file when it&rsquo;s necessary.<\/p><p>Here are some other advantages of using bash scripts:<\/p><ul class=\"wp-block-list\">\n<li><strong>Well-structured commands <\/strong>&ndash; structure the commands in a sequence so that every time you execute the script, it will run in the right order.<\/li>\n\n\n\n<li><strong>Task automation <\/strong>&ndash; automate the script execution at any defined time using cron&rsquo;s time-based scheduler.<\/li>\n\n\n\n<li><strong>Transparency <\/strong>&ndash; people can check the content of a script since it&rsquo;s in a readable text file. However, if you run the commands using another program written in a different programming language, such as C++, you&rsquo;ll need to access the source code.<\/li>\n\n\n\n<li><strong>Transferable <\/strong>&ndash; if you transfer a script to other Linux distributions, it&rsquo;ll still work, providing that shell commands are available on that particular operating system.<\/li>\n<\/ul><h2 class=\"wp-block-heading\" id=\"h-understanding-bash-commands\">Understanding bash commands<\/h2><p>Bash is available on almost all types of Unix-based operating systems and doesn&rsquo;t require a separate installation. You will need a <a href=\"\/ng\/tutorials\/linux-commands\/\">Linux command<\/a> line, also known as the Linux terminal. It&rsquo;s a program that contains the shell and lets you execute bash scripts.&nbsp;<\/p><p>Use this command to check the list of available shells on your Unix operating system:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cat \/etc\/shells<\/pre><p>The output should show a list like this:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/bin\/bash\n\/bin\/sh\n\/bin\/tcsh\n\/bin\/csh<\/pre><p>Each bash shell script needs to start with <strong>#! <\/strong>followed by the absolute path to the bash interpreter. To view the path, enter this command:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">which bash<\/pre><p>It should produce the following output:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/bin\/bash<\/pre><p>This is the standard path to the bash interpreter on most Unix operating systems. To let the shell know that it should run commands using the bash interpreter, start the script with this line:<\/p><p>#!\/bin\/bash<\/p><p>\n[pro tip]Linux has a bash shell command manual. It contains descriptions of all technical terms and standard shell variables. Type and execute the man bash command to display the manual on the terminal.[\/protip]<\/p><p>The next step is to write and compile the commands in a <strong>.sh<\/strong> file using a text editor. You will need a Unix text editor such as VIM or GNU Nano. In this tutorial, we&rsquo;ll use the <strong>Nano <\/strong>text editor to create the file by inputting this command:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nano function.sh<\/pre><p>This will open a new <strong>.sh<\/strong> file for you to edit. Begin by writing <strong>#!\/bin\/bash<\/strong> followed by bash commands.<\/p><p><div class=\"announcement-block announcement-block--important\">\n            <span class=\"announcement-block__heading\">\n                <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                    <path fill-rule=\"evenodd\" clip-rule=\"evenodd\"\n                          d=\"M12 22.5C17.799 22.5 22.5 17.799 22.5 12C22.5 6.20101 17.799 1.5 12 1.5C6.20101 1.5 1.5 6.20101 1.5 12C1.5 17.799 6.20101 22.5 12 22.5ZM13.637 7.65198C13.637 6.74791 12.9041 6.01501 12 6.01501C11.0959 6.01501 10.363 6.74791 10.363 7.65198C10.5335 9.53749 10.875 13.383 10.875 13.383C10.875 14.0043 11.3787 14.508 12 14.508C12.6213 14.508 13.125 14.0043 13.125 13.383V13.38L13.637 7.65198ZM11.9927 15.714C11.3714 15.714 10.8677 16.2177 10.8677 16.839C10.8677 17.4603 11.3714 17.964 11.9927 17.964H12.0073C12.6286 17.964 13.1323 17.4603 13.1323 16.839C13.1323 16.2177 12.6286 15.714 12.0073 15.714H11.9927Z\"\n                          fill=\"#FEA419\"\/>\n                <\/svg>\n                Important\n            <\/span>\n            <p class=\"announcement-block__content\">\n                Once you&rsquo;re done using the Nano text editor, press CTRL+X to close it, then press Y and Enter to save the changes.\n            <\/p><\/div>\n\n\n\n<\/p><p>In order to successfully create your first bash script, you need to understand the essential bash commands. They are the main elements of a script, and you must know what they do and how to write them properly.<\/p><p>Read our <a href=\"\/ng\/tutorials\/bash-script-example\/\">bash commands and script examples<\/a> to help you get started.<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-run-a-bash-script\">How to run a bash script<\/h2><p>Now that we have written a bash script, let&rsquo;s learn how to run it from the terminal. There are three methods to do it &ndash; using the <strong>bash <\/strong>command, using the <strong>.\/ <\/strong>command, and running the script from a different directory.<\/p><h3 class=\"wp-block-heading\">Using the bash command<\/h3><p>The first method is by using the <strong>bash<\/strong> command from the appropriate directory. For example, you may have a <strong>function.sh <\/strong>bash script containing simple echo functions in the <strong>Test\/Bash <\/strong>directory. You have to open the directory first by using this command:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cd Test\/Bash<\/pre><p>Then, execute the following <strong>bash <\/strong>command to run the bash script:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">bash function.sh<\/pre><p>You should see the output like this:<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"6a5875d7f1dfc\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a5875d7f1dfc\" class=\"aligncenter size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"571\" height=\"111\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/01\/bash-hello-world.png\/public\" alt=\"Output of bash function in the terminal\" class=\"wp-image-139379\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/01\/bash-hello-world.png\/w=571,fit=scale-down 571w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/01\/bash-hello-world.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/01\/bash-hello-world.png\/w=150,fit=scale-down 150w\" sizes=\"auto, (max-width: 571px) 100vw, 571px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>If you try to run the script without the <strong>bash <\/strong>command, you&rsquo;ll receive a <strong>command not found <\/strong>error message.<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"6a5875d7f370e\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a5875d7f370e\" class=\"aligncenter size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"511\" height=\"48\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/01\/bash-command-not-found.png\/public\" alt=\"Command not found error output due to the non-existent bash command\" class=\"wp-image-139380\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/01\/bash-command-not-found.png\/w=511,fit=scale-down 511w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/01\/bash-command-not-found.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/01\/bash-command-not-found.png\/w=150,fit=scale-down 150w\" sizes=\"auto, (max-width: 511px) 100vw, 511px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><h3 class=\"wp-block-heading\">Using the .\/ command<\/h3><p>You can run a bash script without the <strong>bash <\/strong>command. However, you have to set the file to have the <strong>execute <\/strong>permission using the following command from the appropriate directory:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">chmod +x function.sh<\/pre><p>This command modifies the file permissions so that everyone can execute the file. Once you&rsquo;ve done that, execute the bash script by using this command:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">.\/function.sh<\/pre><p>If you don&rsquo;t set the permission correctly, the terminal will print a <strong>Permission denied <\/strong>error message:<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"6a5875d800e8c\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a5875d800e8c\" class=\"aligncenter size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"530\" height=\"49\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/01\/bash-denied.png\/public\" alt=\"Bash permission denied output\" class=\"wp-image-139381\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/01\/bash-denied.png\/w=530,fit=scale-down 530w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/01\/bash-denied.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/01\/bash-denied.png\/w=150,fit=scale-down 150w\" sizes=\"auto, (max-width: 530px) 100vw, 530px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>Like the <strong>bash <\/strong>command, you&rsquo;ll also get a <strong>command not found <\/strong>error if you don&rsquo;t use <strong>.\/ <\/strong>in your command.<\/p><h3 class=\"wp-block-heading\">Run the script from a different directory<\/h3><p>Another alternative is to run the script from a different directory. After you create the bash script, use the <strong>pwd <\/strong>command to find your current directory. Once you know the path, you can run the script from any directory. For example, use the following command to run <strong>function.sh<\/strong> from the home directory:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">bash Test\/Bash\/function.sh<\/pre><p>        <div class=\"protip\">\n            <div class=\"protip__heading\">\n                <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                    <path d=\"M1.49234 23.5024C1.23229 23.5024 0.972242 23.4024 0.782206 23.2123C0.562165 22.9923 0.452144 22.6822 0.502153 22.3722C0.562165 21.9221 1.14227 17.9113 3.00262 16.351C3.63274 15.8209 4.43289 15.5509 5.26305 15.5609C6.09321 15.5909 6.87335 15.9109 7.47347 16.4911C8.6937 17.6913 8.76371 19.6717 7.6435 20.9919C6.0832 22.8523 2.08245 23.4324 1.63237 23.4924C1.59236 23.4924 1.54235 23.4924 1.50234 23.4924L1.49234 23.5024ZM5.16303 17.5613C4.84297 17.5613 4.53291 17.6713 4.29287 17.8813C3.60274 18.4614 3.07264 19.9317 2.75258 21.242C4.06282 20.9219 5.5331 20.3918 6.11321 19.7017C6.55329 19.1716 6.54329 18.3814 6.0832 17.9213C5.85316 17.7013 5.5431 17.5713 5.20304 17.5613C5.19304 17.5613 5.17303 17.5613 5.16303 17.5613ZM11.7243 21.8821C11.4942 21.8821 11.2642 21.8021 11.0841 21.652C10.8541 21.462 10.7241 21.1819 10.7241 20.8819V15.9109L8.08358 13.2705H3.11264C2.81259 13.2705 2.53254 13.1404 2.3425 12.9104C2.15246 12.6803 2.07245 12.3803 2.12246 12.0902C2.19247 11.7102 2.84259 8.36953 4.70294 7.12929C6.33325 6.04909 8.96375 6.49918 10.244 6.80923C11.5442 4.96889 13.2546 3.4286 15.2349 2.33839C17.4553 1.11816 19.9858 0.518051 22.4963 0.498047C23.0464 0.498047 23.4865 0.948132 23.4865 1.49824C23.4865 5.0389 22.3763 9.97983 17.1753 13.7605C17.4853 15.0408 17.9354 17.6613 16.8552 19.2816C15.615 21.1419 12.2744 21.7921 11.8943 21.8621C11.8343 21.8721 11.7743 21.8821 11.7143 21.8821H11.7243ZM12.7245 16.181V19.6016C13.7146 19.2916 14.7948 18.7915 15.2049 18.1814C15.675 17.4812 15.605 16.091 15.385 14.9008C14.5248 15.3808 13.6346 15.8109 12.7245 16.181ZM9.66388 12.0302L11.9643 14.3307C13.1845 13.8306 14.3648 13.2204 15.485 12.5103C19.9358 9.51974 21.2361 5.60901 21.4561 2.53843C19.6157 2.67846 17.8254 3.20856 16.2051 4.09872C14.2847 5.14892 12.6544 6.68921 11.4942 8.54956C10.7841 9.65977 10.174 10.82 9.66388 12.0302ZM4.39289 11.2701H7.81353C8.1936 10.3599 8.63368 9.46974 9.11377 8.60957C7.92355 8.38953 6.51329 8.31952 5.81315 8.78961C5.19304 9.19968 4.70294 10.3099 4.39289 11.2701Z\" fill=\"#673DE6\"\/>\n                <\/svg>\n                <p class=\"protip__title\">\n                    Expert tip                <\/p>\n            <\/div>\n            <p class=\"protip__content\">Use the cd command to go to the home directory straight away regardless of the directory you are in.<\/p>\n                    <\/div>\n        \n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-next-step-practicing-and-mastering-bash-scripting\">Next step: Practicing and mastering bash scripting<\/h2><p>Bash reads shell commands and interacts with the operating system to execute them. The great aspect of bash is that you can compile many bash commands and functions into a single executable script, helping you streamline your workflow.<\/p><p>However, there is much more to learn if you want to be able to utilize the full potential of bash. Practice with the examples we have provided and continue exploring bash so you can write better and more efficient scripts. We recommend continue learning about <a href=\"\/ng\/tutorials\/bash-variables\/\">bash variables<\/a> as they can make your script more flexible. Good luck!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&rsquo;ve ever used a Linux operating system, you may have heard of bash. It&rsquo;s a Unix shell that reads and executes various commands. When you need to run several bash commands, you don&rsquo;t have to execute them manually one at a time. Instead, it&rsquo;s possible to create a script file that contains bash functions [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ng\/tutorials\/bash-scripting-tutorial\/\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":411,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"What is a bash scripting and how to use it?","rank_math_description":"Bash is a Unix shell that reads and executes various commands. Read this article if you want to learn how to use Bash to manage your server.\n","rank_math_focus_keyword":"bash scripting tutorial","footnotes":""},"categories":[22644],"tags":[],"class_list":["post-139361","post","type-post","status-publish","format-standard","hentry","category-vps"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/bash-scripting-tutorial","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/bash-scripting-tutorial","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/bash-scripting-tutorial","default":0},{"locale":"en-GB","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/bash-scripting-tutorial","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/bash-scripting-tutorial","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/bash-scripting-tutorial","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/bash-scripting-tutorial","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/bash-scripting-tutorial","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/139361","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/users\/411"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/comments?post=139361"}],"version-history":[{"count":2,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/139361\/revisions"}],"predecessor-version":[{"id":142940,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/139361\/revisions\/142940"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/media?parent=139361"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/categories?post=139361"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/tags?post=139361"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}