<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wikicyber.org/index.php?action=history&amp;feed=atom&amp;title=Draft%3AIntermediate_Bash</id>
	<title>Draft:Intermediate Bash - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wikicyber.org/index.php?action=history&amp;feed=atom&amp;title=Draft%3AIntermediate_Bash"/>
	<link rel="alternate" type="text/html" href="https://wikicyber.org/index.php?title=Draft:Intermediate_Bash&amp;action=history"/>
	<updated>2026-09-24T04:43:52Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://wikicyber.org/index.php?title=Draft:Intermediate_Bash&amp;diff=165&amp;oldid=prev</id>
		<title>MigrationBot: Backfill (v3.0 review queue): added to the review queue</title>
		<link rel="alternate" type="text/html" href="https://wikicyber.org/index.php?title=Draft:Intermediate_Bash&amp;diff=165&amp;oldid=prev"/>
		<updated>2026-09-22T05:42:37Z</updated>

		<summary type="html">&lt;p&gt;Backfill (v3.0 review queue): added to the review queue&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 05:42, 22 September 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l86&quot;&gt;Line 86:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 86:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Linux Fundamentals|020]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Linux Fundamentals|020]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Migrated from cypat.guide]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Migrated from cypat.guide]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Pending review]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wikicyber:diff:1.41:old-85:rev-165:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>MigrationBot</name></author>
	</entry>
	<entry>
		<id>https://wikicyber.org/index.php?title=Draft:Intermediate_Bash&amp;diff=85&amp;oldid=prev</id>
		<title>MigrationBot: Import from cypat.guide: docs/linux/linux_fundamentals/intermediate_bash.md</title>
		<link rel="alternate" type="text/html" href="https://wikicyber.org/index.php?title=Draft:Intermediate_Bash&amp;diff=85&amp;oldid=prev"/>
		<updated>2026-09-18T17:06:14Z</updated>

		<summary type="html">&lt;p&gt;Import from cypat.guide: docs/linux/linux_fundamentals/intermediate_bash.md&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Submit}}&lt;br /&gt;
&amp;lt;!-- Migrated from https://cypat.guide/docs/linux/linux_fundamentals/intermediate_bash (source: docs/linux/linux_fundamentals/intermediate_bash.md) --&amp;gt;&lt;br /&gt;
Author(s): Matthias Lee (ml2322) &amp;lt;br /&amp;gt; Last Updated: 07-07-2025&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;mw-collapsible mw-collapsed wikitable&amp;quot; style=&amp;quot;width:100%&amp;quot;&lt;br /&gt;
! Recommended Prerequisites (click to expand)&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Introductory bash&amp;lt;/li&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Now that you understand the basics of Bash, we can learn about some more advanced things it can do.&lt;br /&gt;
&lt;br /&gt;
=== Privilege escalation ===&lt;br /&gt;
&lt;br /&gt;
In linux, the hidden &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; user has special privileges. The root user can, for the most part, read, write, and change permissions on every file. Many commands can only be executed as root, since they use these more locked down files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
As mentioned, some commands require root privileges to run, as they modify restricted system files or interact with the system in a privileged manner. To run commands as root, you can prefix them with &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt;. Sudo is another command that runs whatever you specified with root privileges. A common command that needs root access is &amp;lt;code&amp;gt;apt&amp;lt;/code&amp;gt; for installing, removing, or modifying programs on your system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;user@system:/home/user$ ls /root&lt;br /&gt;
Permission Denied&lt;br /&gt;
user@system:/home/user$ sudo ls /root&lt;br /&gt;
1984.pdf&lt;br /&gt;
user@system:/home/user$ whoami&lt;br /&gt;
user&lt;br /&gt;
user@system:/home/user$ sudo whoami&lt;br /&gt;
root&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== Scripts ===&lt;br /&gt;
&lt;br /&gt;
Bash isn&amp;#039;t just for interacting with the terminal, you can script in it too. To make a bash script, put bash commands (as you would run them in the terminal) in a file with the &amp;lt;code&amp;gt;.sh&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;.bash&amp;lt;/code&amp;gt; extension. While not usually required, it&amp;#039;s good practice to put &amp;lt;code&amp;gt;#!/usr/bin/bash&amp;lt;/code&amp;gt; at the top of the file, as it is required in some cases. To run a script, just run &amp;lt;code&amp;gt;bash &amp;amp;lt;script&amp;amp;gt;&amp;lt;/code&amp;gt;, and bash will execute your script.&lt;br /&gt;
&lt;br /&gt;
=== Variables ===&lt;br /&gt;
&lt;br /&gt;
Just like any other programming language, Bash has variables too, which you can read, create, and modify.&lt;br /&gt;
&lt;br /&gt;
==== Setting variables ====&lt;br /&gt;
&lt;br /&gt;
To set a variable in bash, you can either run &amp;lt;code&amp;gt;variable=value&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;export variable=value&amp;lt;/code&amp;gt;. The key difference between the two is that if you use &amp;lt;code&amp;gt;export&amp;lt;/code&amp;gt;, any programs you run within bash can access the variable too. NOTE: one quirk of bash is that you can not have a space before or after the &amp;lt;code&amp;gt;=&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Using variables ====&lt;br /&gt;
&lt;br /&gt;
To use a variable, you can do &amp;lt;code&amp;gt;$&amp;amp;lt;name&amp;amp;gt;&amp;lt;/code&amp;gt;, where &amp;lt;code&amp;gt;&amp;amp;lt;name&amp;amp;gt;&amp;lt;/code&amp;gt; is the variable you want to access. That will then get substituted out for the variable&amp;#039;s value. For example, if variable &amp;lt;code&amp;gt;foo&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;bar&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;echo $foo&amp;lt;/code&amp;gt; will print &amp;lt;code&amp;gt;bar&amp;lt;/code&amp;gt;. This syntax works, but has limitations, as you can not put regular characters straight after the variable. For example, (&amp;lt;code&amp;gt;$variablehello&amp;lt;/code&amp;gt;) will be interpreted as you trying to access a variable called &amp;lt;code&amp;gt;variablehello&amp;lt;/code&amp;gt;, instead of accessing &amp;lt;code&amp;gt;variable&amp;lt;/code&amp;gt; and taking &amp;lt;code&amp;gt;hello as additional input right after&amp;lt;/code&amp;gt;. To solve this, you can use the following syntax instead: &amp;lt;code&amp;gt;${variable}&amp;lt;/code&amp;gt;. This will also access the variable, &amp;lt;code&amp;gt;variable&amp;lt;/code&amp;gt;, except bash knows when it ends by the curly braces. This syntax also has other uses we&amp;#039;ll discuss later. Uniquely, if the variable doesn&amp;#039;t exist, bash doesn&amp;#039;t throw an error, it just treats it like the variable is blank&lt;br /&gt;
&lt;br /&gt;
==== Examples ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;user@system:/home/user$ var=a&lt;br /&gt;
user@system:/home/user$ echo $var&lt;br /&gt;
a&lt;br /&gt;
user@system:/home/user$ export env_var=b&lt;br /&gt;
user@system:/user/user$ echo $env_var&lt;br /&gt;
b&lt;br /&gt;
user@system:/user/user$ some_command&lt;br /&gt;
(this command can access env_var but not var)&lt;br /&gt;
user@system:/user/user$ echo $varbc&lt;br /&gt;
(no output because varbc doesn&amp;#039;t exist)&lt;br /&gt;
user@system:/user/user$ echo ${var}bc&lt;br /&gt;
abc&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== Joining Commands ===&lt;br /&gt;
&lt;br /&gt;
Bash has three main ways to let you run several commands at once:&lt;br /&gt;
&lt;br /&gt;
==== ; ====&lt;br /&gt;
&lt;br /&gt;
Joining commands with a semicolon will make them run sequentially, no matter if they succeed or not.&lt;br /&gt;
&lt;br /&gt;
==== &amp;amp;amp;&amp;amp;amp; ====&lt;br /&gt;
&lt;br /&gt;
Joining commands with &amp;lt;code&amp;gt;&amp;amp;amp;&amp;amp;amp;&amp;lt;/code&amp;gt; will execute the second command only if the first succeeds&lt;br /&gt;
&lt;br /&gt;
==== || ====&lt;br /&gt;
&lt;br /&gt;
Joining commands with &amp;lt;code&amp;gt;||&amp;lt;/code&amp;gt; will execute the second command only if the first fails&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;user@system:/home/user$ command_a; command_b&lt;br /&gt;
(both will always run)&lt;br /&gt;
user@system:/home/user$ command_a &amp;amp;&amp;amp; command_b&lt;br /&gt;
(b will run only if a succeeds)&lt;br /&gt;
user@system:/home/user$ command_a || command_b&lt;br /&gt;
(b will run only if a fails)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
====== Further Reading ======&lt;br /&gt;
&lt;br /&gt;
* https://www.howtogeek.com/737563/what-is-root-on-linux/&lt;br /&gt;
&lt;br /&gt;
[[Category:Linux Fundamentals|020]]&lt;br /&gt;
[[Category:Migrated from cypat.guide]]&lt;/div&gt;</summary>
		<author><name>MigrationBot</name></author>
	</entry>
</feed>