<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MarcTek Tutorials</title>
	<atom:link href="https://tutorials.marctek.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://tutorials.marctek.com</link>
	<description>Build While You Learn</description>
	<lastBuildDate>Sat, 10 Oct 2026 00:31:02 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.3</generator>

<image>
	<url>https://tutorials.marctek.com/wp-content/uploads/2026/07/cropped-MarcTek-Icon-32x32.png</url>
	<title>MarcTek Tutorials</title>
	<link>https://tutorials.marctek.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Bash Tutorial for Beginners</title>
		<link>https://tutorials.marctek.com/bash/bash-tutorial-for-beginners/</link>
		
		<dc:creator><![CDATA[Marcus]]></dc:creator>
		<pubDate>Sat, 10 Oct 2026 00:31:02 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<guid isPermaLink="false">https://tutorials.marctek.com/?p=215</guid>

					<description><![CDATA[Bash is one of the most widely used command-line shells on Linux systems, and it is also a powerful scripting [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Bash is one of the most widely used command-line shells on Linux systems, and it is also a powerful scripting language. If you are learning Linux, system administration, programming, or automation, Bash is a great place to start.</p>



<p class="wp-block-paragraph">In this tutorial series, you will learn how Bash works, how to write Bash scripts, and eventually how to use Bash to build useful command-line tools.</p>



<h2 class="wp-block-heading">Table of Contents</h2>



<ol class="wp-block-list">
<li><a href="#what-is-bash">What is Bash?</a></li>



<li><a href="#what-can-you-do-with-bash">What Can You Do With Bash?</a></li>



<li><a href="#bash-vs-the-linux-terminal">Bash vs. the Linux Terminal</a></li>



<li><a href="#how-to-check-whether-bash-is-installed">How to Check Whether Bash Is Installed</a></li>



<li><a href="#how-to-start-bash">How to Start Bash</a></li>



<li><a href="#your-first-bash-command">Your First Bash Command</a>
<ul class="wp-block-list">
<li><a href="#the-echo-command">The <code>echo</code> Command</a></li>
</ul>
</li>



<li><a href="#listing-files-with-ls">Listing Files With <code>ls</code></a>
<ul class="wp-block-list">
<li><code><a href="#ls">ls</a></code></li>



<li><a href="#the-a-option">The <code>-a</code> Option</a></li>
</ul>
</li>



<li><a href="#getting-help-with-commands">Getting Help With Commands</a></li>



<li><a href="#commands-vs-bash-scripts">Commands vs. Bash Scripts</a></li>



<li><a href="#your-first-bash-script">Your First Bash Script</a></li>



<li><a href="#what-is-a-shebang">What Is a Shebang?</a></li>



<li><a href="#comments-in-bash">Comments in Bash</a></li>



<li><a href="#making-the-script-executable">Making the Script Executable</a></li>



<li><a href="#running-your-bash-script">Running Your Bash Script</a></li>



<li><a href="#why-learn-bash">Why Learn Bash?</a></li>



<li><a href="#what-youll-learn-in-this-bash-tutorial-series">What You&#8217;ll Learn in This Bash Tutorial Series</a></li>



<li><a href="#what-you-need-before-starting">What You Need Before Starting</a></li>



<li><a href="#using-bash-on-windows">Using Bash on Windows</a></li>



<li><a href="#start-learning-bash">Start Learning Bash</a></li>
</ol>



<h2 id="what-is-bash" class="wp-block-heading">What Is Bash?</h2>



<p class="wp-block-paragraph">Bash stands for <strong>Bourne Again SHell</strong>. It is a command-line shell that lets you interact with your operating system by typing commands. It was created by Brian Fox for the GNU Project in 1988. It was designed as a free and open-source replacement for the older Bourne shell (<code>sh</code>), which was created by Stephen Bourne at Bell Labs.</p>



<p class="wp-block-paragraph">Bash is extremely common on Linux systems. It is also available on macOS, although modern versions of macOS use Zsh as the default interactive shell. Windows does not include Bash as its normal command shell, but Windows users can still use Bash through tools such as the Windows Subsystem for Linux (WSL).</p>



<p class="wp-block-paragraph">Bash can be used interactively by entering commands into a terminal, or it can be used as a scripting language to automate commands and repetitive tasks.</p>



<h2 id="what-can-you-do-with-bash" class="wp-block-heading">What Can You Do With Bash?</h2>



<p class="wp-block-paragraph">You can use Bash to:</p>



<ul class="wp-block-list">
<li>Navigate through files and directories</li>



<li>Create, move, rename, and delete files</li>



<li>Install and manage software</li>



<li>Automate backups</li>



<li>Process files and text</li>



<li>Monitor a Linux system</li>



<li>Analyze system logs</li>



<li>Run sequences of commands automatically</li>



<li>Manage processes and services</li>



<li>Write automation scripts</li>



<li>Build command-line utilities</li>



<li>And much more</li>
</ul>



<p class="wp-block-paragraph">As you continue through this tutorial series, you will learn how to do many of these things yourself.</p>



<h2 id="bash-vs-the-linux-terminal" class="wp-block-heading">Bash vs. the Linux Terminal</h2>



<p class="wp-block-paragraph">One important distinction beginners often miss is that <strong>Bash and the terminal are not the same thing</strong>.</p>



<p class="wp-block-paragraph">A <strong>terminal</strong> is the application or window where you type commands. Think of it as the interface that lets you communicate with command-line programs.</p>



<p class="wp-block-paragraph">A <strong>shell</strong> is the program that reads and interprets the commands you type.</p>



<p class="wp-block-paragraph"><strong>Bash is one particular shell.</strong></p>



<p class="wp-block-paragraph">In other words:</p>



<ul class="wp-block-list">
<li>The <strong>Terminal</strong> is where you type commands</li>



<li>The <strong>Shell</strong> is the program that interprets those commands</li>



<li><strong>Bash</strong> is one specific type of shell</li>
</ul>



<p class="wp-block-paragraph">There are many other shells, including Zsh, Fish, Dash, and others.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph"><strong><mark style="background-color:rgba(0, 0, 0, 0);color:#8ed1fc" class="has-inline-color">Note:</mark></strong></p>



<p class="wp-block-paragraph">In some of the examples in this tutorial, you may see a <code>$</code> before a command:</p>



<pre class="wp-block-code"><code>$ bash --version</code></pre>



<p class="wp-block-paragraph">The <code>$</code> represents the shell prompt. <strong>Do not type the</strong> <code><strong>$</strong></code> <strong>yourself.</strong></p>



<p class="wp-block-paragraph">You only need to type:</p>



<pre class="wp-block-code"><code>bash --version</code></pre>
</blockquote>



<h2 id="how-to-check-whether-bash-is-installed" class="wp-block-heading">How to Check Whether Bash Is Installed</h2>



<p class="wp-block-paragraph">Open a terminal and run:</p>



<pre class="wp-block-code"><code>$ bash --version</code></pre>



<p class="wp-block-paragraph">If Bash is installed, you should see output similar to:</p>



<pre class="wp-block-code"><code>GNU bash, version 5.x.x
Copyright (C) Free Software Foundation, Inc.</code></pre>



<p class="wp-block-paragraph">The exact version number will depend on your system.</p>



<p class="wp-block-paragraph">If you receive an error such as:</p>



<pre class="wp-block-code"><code>bash: command not found</code></pre>



<p class="wp-block-paragraph">Bash may not be installed on your system.</p>



<p class="wp-block-paragraph">It is important to understand that <code>bash --version</code> tells you whether Bash is installed. It does not necessarily tell you which shell your terminal is currently using.</p>



<p class="wp-block-paragraph">You can check your configured login shell with:</p>



<pre class="wp-block-code"><code>$ echo "$SHELL"</code></pre>



<p class="wp-block-paragraph">You might see something like:</p>



<pre class="wp-block-code"><code>/bin/bash</code></pre>



<p class="wp-block-paragraph">or:</p>



<pre class="wp-block-code"><code>/bin/zsh</code></pre>



<p class="wp-block-paragraph">If you see <code>/bin/bash</code>, Bash is configured as your login shell.</p>



<h2 id="how-to-start-bash" class="wp-block-heading">How to Start Bash</h2>



<p class="wp-block-paragraph">Even if your terminal is currently using another shell, you can start Bash by running:</p>



<pre class="wp-block-code"><code>$ bash</code></pre>



<p class="wp-block-paragraph">This starts a new Bash shell inside your terminal. You can then enter Bash commands normally.</p>



<p class="wp-block-paragraph">When you are finished, type:</p>



<pre class="wp-block-code"><code>$ exit</code></pre>



<p class="wp-block-paragraph">This exits the Bash session and returns you to your previous shell. If your terminal is already running Bash, you usually do not need to run <code>bash</code> first.</p>



<h2 id="your-first-bash-command" class="wp-block-heading">Your First Bash Command</h2>



<p class="wp-block-paragraph">Let&#8217;s run your first command.</p>



<p class="wp-block-paragraph">Open a terminal and type:</p>



<pre class="wp-block-code"><code>$ echo "Hello, World!"</code></pre>



<p class="wp-block-paragraph">Press Enter.</p>



<p class="wp-block-paragraph">You should see:</p>



<pre class="wp-block-code"><code>Hello, World!</code></pre>



<p class="wp-block-paragraph">You just ran a command through Bash.</p>



<p class="wp-block-paragraph">Let&#8217;s break it down.</p>



<h3 id="the-echo-command" class="wp-block-heading">The <code>echo</code> Command</h3>



<p class="wp-block-paragraph"><code>echo</code> prints text to the terminal.</p>



<p class="wp-block-paragraph">In this command:</p>



<pre class="wp-block-code"><code>$ echo "Hello, World!"</code></pre>



<p class="wp-block-paragraph"><code>echo</code> is the command being executed.</p>



<p class="wp-block-paragraph"><code>"Hello, World!"</code> is an argument being passed to <code>echo</code>. An <strong>argument</strong> provides additional information to a command. In this case, it tells <code>echo</code> what text to print. The quotation marks group the text together and prevent certain characters or spaces from being interpreted separately by the shell.</p>



<p class="wp-block-paragraph">The quotation marks themselves are not printed, which is why the output is:</p>



<pre class="wp-block-code"><code>Hello, World!</code></pre>



<p class="wp-block-paragraph">instead of:</p>



<pre class="wp-block-code"><code>"Hello, World!"</code></pre>



<p class="wp-block-paragraph">You will learn much more about commands, arguments, and quotes later in this Bash tutorial series.</p>



<h2 id="listing-files-with-ls" class="wp-block-heading">Listing Files With <code>ls</code></h2>



<p class="wp-block-paragraph">Let&#8217;s try another command:</p>



<pre class="wp-block-code"><code>$ ls -a</code></pre>



<p class="wp-block-paragraph">You might see output similar to:</p>



<pre class="wp-block-code"><code>.   ..   .bash_history   .bashrc   Documents   Downloads</code></pre>



<p class="wp-block-paragraph">Let&#8217;s break this command down.</p>



<h3 id="ls" class="wp-block-heading"><code>ls</code></h3>



<p class="wp-block-paragraph"><code>ls</code> means <strong>list</strong>. It lists files and directories.</p>



<p class="wp-block-paragraph">Running:</p>



<pre class="wp-block-code"><code>$ ls</code></pre>



<p class="wp-block-paragraph">normally displays the non-hidden files and directories in your current directory.</p>



<h3 id="the-a-option" class="wp-block-heading">The <code>-a</code> Option</h3>



<p class="wp-block-paragraph">In:</p>



<pre class="wp-block-code"><code>ls -a</code></pre>



<p class="wp-block-paragraph">the <code>-a</code> changes the behavior of <code>ls</code>. The <code>-a</code> option means <strong>all</strong>, so <code>ls</code> also displays hidden files and directories.</p>



<p class="wp-block-paragraph">On Linux and other Unix-like systems, files and directories whose names begin with a period (<code>.</code>) are normally considered hidden.</p>



<p class="wp-block-paragraph">Examples include:</p>



<pre class="wp-block-code"><code>.bashrc
.bash_history
.config</code></pre>



<p class="wp-block-paragraph">Options beginning with <code>-</code> are often called <strong>options</strong>, <strong>flags</strong>, or <strong>command-line options</strong>. Different commands support different options.</p>



<p class="wp-block-paragraph">For example:</p>



<pre class="wp-block-code"><code>$ ls -l</code></pre>



<p class="wp-block-paragraph">shows a more detailed listing, while:</p>



<pre class="wp-block-code"><code>$ ls -a</code></pre>



<p class="wp-block-paragraph">includes hidden files.</p>



<p class="wp-block-paragraph">You can even combine many short options:</p>



<pre class="wp-block-code"><code>$ ls -la</code></pre>



<p class="wp-block-paragraph">You will learn more about commands and options in the next tutorial.</p>



<h2 id="getting-help-with-commands" class="wp-block-heading">Getting Help With Commands</h2>



<p class="wp-block-paragraph">Bash includes a built-in <code>help</code> command.</p>



<p class="wp-block-paragraph">Try:</p>



<pre class="wp-block-code"><code>$ help</code></pre>



<p class="wp-block-paragraph">This displays Bash&#8217;s built-in commands.</p>



<p class="wp-block-paragraph">You can also ask for help about a specific Bash built-in. For example:</p>



<pre class="wp-block-code"><code>$ help echo</code></pre>



<p class="wp-block-paragraph">However, <code>help</code> does not document every program installed on your computer.</p>



<p class="wp-block-paragraph">Many external commands support the <code>--help</code> option:</p>



<pre class="wp-block-code"><code>$ ls --help</code></pre>



<p class="wp-block-paragraph">Linux systems also commonly provide manual pages through the <code>man</code> command:</p>



<pre class="wp-block-code"><code>$ man ls</code></pre>



<p class="wp-block-paragraph">Press <code>q</code> to exit a manual page.</p>



<p class="wp-block-paragraph">These tools are extremely useful when working from the command line because you do not have to memorize every option a command supports.</p>



<h2 id="commands-vs-bash-scripts" class="wp-block-heading">Commands vs. Bash Scripts</h2>



<p class="wp-block-paragraph">So far, you have been using Bash interactively.</p>



<p class="wp-block-paragraph">You type a command:</p>



<pre class="wp-block-code"><code>$ echo "Hello, World!"</code></pre>



<p class="wp-block-paragraph">Bash runs it immediately. Bash can also execute commands stored inside a file. This is called a <strong>Bash script</strong>.</p>



<p class="wp-block-paragraph">Let&#8217;s create one.</p>



<h2 id="your-first-bash-script" class="wp-block-heading">Your First Bash Script</h2>



<p class="wp-block-paragraph">Open your preferred text editor or Integrated Development Environment (IDE). I use <a href="https://code.visualstudio.com/">Visual Studio Code</a>, but you can use almost any plain-text editor.</p>



<p class="wp-block-paragraph">Create a new file named:</p>



<pre class="wp-block-code"><code>hello_world.sh</code></pre>



<p class="wp-block-paragraph">The <code>.sh</code> extension is commonly used for shell scripts. Technically, Bash does not require the file to end in <code>.sh</code>, but using the extension makes it easier to identify the file as a shell script.</p>



<p class="wp-block-paragraph">Add the following:</p>



<pre class="wp-block-code"><code>#!/usr/bin/env bash

# This outputs "Hello, World!"
echo "Hello, World!"</code></pre>



<p class="wp-block-paragraph">Now save the file. Let&#8217;s look at each part before running it.</p>



<h2 id="what-is-a-shebang" class="wp-block-heading">What Is a Shebang?</h2>



<p class="wp-block-paragraph">The first line is:</p>



<pre class="wp-block-code"><code>#!/usr/bin/env bash</code></pre>



<p class="wp-block-paragraph">The characters:</p>



<pre class="wp-block-code"><code>#!</code></pre>



<p class="wp-block-paragraph">are called a <strong>shebang</strong>.</p>



<p class="wp-block-paragraph">When you execute the script directly, the shebang tells the operating system which interpreter should be used to run the file. In this example:</p>



<pre class="wp-block-code"><code>#!/usr/bin/env bash</code></pre>



<p class="wp-block-paragraph"><code>env</code> searches for <code>bash</code> using the environment&#8217;s <code>PATH</code> and then runs the script with the Bash interpreter it finds. This is a common way to write Bash scripts because Bash may be installed in different locations on different systems.</p>



<h2 id="comments-in-bash" class="wp-block-heading">Comments in Bash</h2>



<p class="wp-block-paragraph">The next line is:</p>



<pre class="wp-block-code"><code># This outputs "Hello, World!"</code></pre>



<p class="wp-block-paragraph">This is a <strong>comment</strong>. In Bash, a <code>#</code> normally begins a comment. Bash ignores everything after the <code>#</code> on that line. Comments let you leave notes inside your scripts explaining what the code does.</p>



<p class="wp-block-paragraph">For example:</p>



<pre class="wp-block-code"><code># Display a greeting
echo "Hello!"</code></pre>



<p class="wp-block-paragraph">The comment is ignored, while the <code>echo</code> command is executed. Comments become especially useful as your scripts get larger.</p>



<h2 id="making-the-script-executable" class="wp-block-heading">Making the Script Executable</h2>



<p class="wp-block-paragraph">Open your terminal and navigate to the directory where you saved <code>hello_world.sh</code>.</p>



<p class="wp-block-paragraph">Then run:</p>



<pre class="wp-block-code"><code>$ chmod +x hello_world.sh</code></pre>



<p class="wp-block-paragraph">The <code>chmod</code> command changes file permissions.</p>



<p class="wp-block-paragraph">In this command:</p>



<pre class="wp-block-code"><code>chmod +x hello_world.sh</code></pre>



<p class="wp-block-paragraph"><code>chmod</code> is the command. <code>+x</code> tells <code>chmod</code> to add executable permission. <code>hello_world.sh</code> is the file whose permissions you are changing. In simple terms, you are telling the system that this file is allowed to be executed as a program.</p>



<h2 id="running-your-bash-script" class="wp-block-heading">Running Your Bash Script</h2>



<p class="wp-block-paragraph">Now run:</p>



<pre class="wp-block-code"><code>$ ./hello_world.sh</code></pre>



<p class="wp-block-paragraph">You should see:</p>



<pre class="wp-block-code"><code>Hello, World!</code></pre>



<p class="wp-block-paragraph">You just created and ran your first Bash script. But what does the <code>./</code> mean? The <code>.</code> represents your <strong>current directory</strong>.</p>



<p class="wp-block-paragraph">So:</p>



<pre class="wp-block-code"><code>./hello_world.sh</code></pre>



<p class="wp-block-paragraph">Runs the file named <code>hello_world.sh</code> located in the current directory. Linux shells normally do not search the current directory automatically when looking for commands. Using <code>./</code> explicitly tells Bash where the executable file is located.</p>



<p class="wp-block-paragraph">You could also run the script without making it executable by passing it directly to Bash:</p>



<pre class="wp-block-code"><code>$ bash hello_world.sh</code></pre>



<p class="wp-block-paragraph">In that case, Bash opens and executes the script itself.</p>



<h2 id="why-learn-bash" class="wp-block-heading">Why Learn Bash?</h2>



<p class="wp-block-paragraph">Bash is useful because many computer tasks involve running several commands in a predictable order. Instead of repeatedly typing those commands yourself, you can put them into a script and let Bash do the work for you.</p>



<p class="wp-block-paragraph">Once you understand variables, conditions, loops, functions, and command-line arguments, Bash can automate surprisingly complex tasks. It is especially useful for Linux administration, servers, development environments, automation, and command-line utilities.</p>



<h2 id="what-youll-learn-in-this-bash-tutorial-series" class="wp-block-heading">What You&#8217;ll Learn in This Bash Tutorial Series</h2>



<p class="wp-block-paragraph">This article is the starting point for the Bash tutorial series.</p>



<p class="wp-block-paragraph">Throughout the series, you will learn about:</p>



<ul class="wp-block-list">
<li>Basic Bash commands</li>



<li>Variables</li>



<li>User input</li>



<li>Strings and numbers</li>



<li>Command-line arguments</li>



<li>If statements</li>



<li>Conditions</li>



<li><code>for</code> loops</li>



<li><code>while</code> loops</li>



<li>Functions</li>



<li>Reusable Bash scripts</li>



<li>Working with files</li>



<li>Automating Linux tasks</li>
</ul>



<p class="wp-block-paragraph">Once you understand the fundamentals, you will also be able to apply what you have learned by building real Bash projects.</p>



<p class="wp-block-paragraph">These include projects such as:</p>



<ul class="wp-block-list">
<li>A file metadata command-line tool</li>



<li>A Linux system monitor</li>



<li>An automatic backup utility</li>



<li>A Linux log analyzer</li>
</ul>



<p class="wp-block-paragraph">Instead of only learning individual commands, these projects will show you how Bash can be used to solve real problems.</p>



<h2 id="what-you-need-before-starting" class="wp-block-heading">What You Need Before Starting</h2>



<p class="wp-block-paragraph">You do not need much to begin learning Bash.</p>



<p class="wp-block-paragraph">You should have:</p>



<ul class="wp-block-list">
<li>A Linux, macOS, or other system with Bash installed</li>



<li>Bash</li>



<li>A terminal</li>



<li>A plain-text editor or IDE</li>



<li>Basic familiarity with using a computer</li>
</ul>



<p class="wp-block-paragraph">You do <strong>not</strong> need previous programming experience. We will build up from the fundamentals throughout the series.</p>



<h2 id="using-bash-on-windows" class="wp-block-heading">Using Bash on Windows</h2>



<p class="wp-block-paragraph">Windows does not use Bash as its normal command shell. Windows primarily provides shells such as PowerShell and Command Prompt.</p>



<p class="wp-block-paragraph">If you are using Windows and want to follow this Bash series, I recommend installing <strong>Windows Subsystem for Linux (WSL)</strong>. WSL gives you a Linux environment that runs directly on Windows, allowing you to use Bash and Linux commands.</p>



<p class="wp-block-paragraph">Microsoft provides installation instructions here: <a href="https://learn.microsoft.com/en-us/windows/wsl/install">Install WSL</a></p>



<p class="wp-block-paragraph">Once WSL is installed, you can open your Linux distribution&#8217;s terminal and follow along with the Bash tutorials.</p>



<h2 id="start-learning-bash" class="wp-block-heading">Start Learning Bash</h2>



<p class="wp-block-paragraph">Now that you know what Bash is, how commands work, and how to create a basic Bash script, you are ready to start learning the language itself.</p>



<p class="wp-block-paragraph">Continue to the first tutorial:</p>



<p class="wp-block-paragraph"><strong>Bash Tutorial for Beginners: Variables, Input, and Basic Commands</strong></p>



<p class="wp-block-paragraph">In the next lesson, you will learn how to work with Bash variables, accept user input, and use the basic commands that you will need as you begin writing your own scripts.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
