<?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>Linux Archives - Tech Antidote</title>
	<atom:link href="https://techantidote.com/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>‎ &#124; LINUX &#124; Tech &#124; Security &#124;</description>
	<lastBuildDate>Tue, 29 Oct 2024 22:48:32 +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://techantidote.com/wp-content/uploads/2016/02/cropped-google-plus-profile-picture-32x32.png</url>
	<title>Linux Archives - Tech Antidote</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">106369530</site>	<item>
		<title>How to search for IOCs on a Linux machine using Loki IOC and Yara scanner</title>
		<link>https://techantidote.com/loki-apt-scanner/</link>
					<comments>https://techantidote.com/loki-apt-scanner/#respond</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Mon, 08 Jul 2024 14:09:05 +0000</pubDate>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[apt scanner]]></category>
		<category><![CDATA[dfir]]></category>
		<category><![CDATA[find iocs linux]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[loki]]></category>
		<category><![CDATA[yara]]></category>
		<category><![CDATA[yara rules]]></category>
		<guid isPermaLink="false">https://techantidote.com/?p=3699</guid>

					<description><![CDATA[<p>This is a quick guide to running Loki APT Scanner to check for IOCs on a Linux machine. Debian/Ubuntu: &#8211; Run the below commands to setup Loki: sudo su - apt-get install libssl-dev -y apt-get install python3.8-venv -y git clone https://github.com/Neo23x0/Loki.git cd Loki python3 -m venv . source bin/activate pip install colorama yara-python psutil rfc5424-logging-handler &#8230; <a href="https://techantidote.com/loki-apt-scanner/" class="more-link">Continue reading <span class="screen-reader-text">How to search for IOCs on a Linux machine using Loki IOC and Yara scanner</span> <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://techantidote.com/loki-apt-scanner/">How to search for IOCs on a Linux machine using Loki IOC and Yara scanner</a> appeared first on <a href="https://techantidote.com">Tech Antidote</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This is a quick guide to running Loki APT Scanner to check for IOCs on a Linux machine.</p>
<p><strong>Debian/Ubuntu:</strong></p>
<p>&#8211; Run the below commands to setup Loki:</p>
<pre>sudo su -
apt-get install libssl-dev -y
apt-get install python3.8-venv -y
git clone https://github.com/Neo23x0/Loki.git
cd Loki
python3 -m venv .
source bin/activate
pip install colorama yara-python psutil rfc5424-logging-handler netaddr
python3 loki-upgrader.py
</pre>
<p><img fetchpriority="high" decoding="async" data-attachment-id="3700" data-permalink="https://techantidote.com/loki-apt-scanner/loki/" data-orig-file="https://techantidote.com/wp-content/uploads/2023/11/loki.png" data-orig-size="1260,634" data-comments-opened="1" data-image-title="loki" data-image-description="" data-image-caption="" data-large-file="https://techantidote.com/wp-content/uploads/2023/11/loki-1024x515.png" class="alignnone size-large wp-image-3700" src="https://techantidote.com/wp-content/uploads/2023/11/loki-1024x515.png" alt="" width="640" height="322" srcset="https://techantidote.com/wp-content/uploads/2023/11/loki-1024x515.png 1024w, https://techantidote.com/wp-content/uploads/2023/11/loki-300x151.png 300w, https://techantidote.com/wp-content/uploads/2023/11/loki-768x386.png 768w, https://techantidote.com/wp-content/uploads/2023/11/loki.png 1260w" sizes="(max-width: 640px) 100vw, 640px" /></p>
<p>&#8211; Run Loki Scanner as root to check for IOCs, you the below command:</p>
<pre><strong> python3 loki.py</strong>
</pre>
<p><img decoding="async" data-attachment-id="3795" data-permalink="https://techantidote.com/loki-apt-scanner/loki-scanner-2/" data-orig-file="https://techantidote.com/wp-content/uploads/2024/07/loki-scanner-e1720472432746.png" data-orig-size="741,502" data-comments-opened="1" data-image-title="loki-scanner" data-image-description="" data-image-caption="" data-large-file="https://techantidote.com/wp-content/uploads/2024/07/loki-scanner-1024x389.png" class="alignnone wp-image-3795 size-full" src="https://techantidote.com/wp-content/uploads/2024/07/loki-scanner-e1720472432746.png" alt="" width="741" height="502" srcset="https://techantidote.com/wp-content/uploads/2024/07/loki-scanner-e1720472432746.png 741w, https://techantidote.com/wp-content/uploads/2024/07/loki-scanner-e1720472432746-300x203.png 300w" sizes="(max-width: 741px) 100vw, 741px" /></p>
<p>&nbsp;</p>
<p>&#8211; You can also search for IOCs in a particular directory using <strong>-p</strong> flag . For example:</p>
<pre><strong>python3 loki.py -p /var/log/apache2/</strong></pre>
<p>&nbsp;</p>
<p><strong>RHEL/CentOS systems:<br />
</strong><br />
On CentOS based system, you can run the below to use find IOCs using APT:</p>
<pre>sudo su -
yum install python3 python3-pip python3-devel openssl openssl-devel -y
pip install colorama yara-python psutil rfc5424-logging-handler netaddr
git clone https://github.com/Neo23x0/Loki.git
cd Loki
python3 loki-upgrader.py
python3 loki.py</pre>
<p><strong>Credits/Sources/References:</strong><br />
<strong><a href="https://github.com/Neo23x0/Loki">Neo23x0</a></strong></p>
<p><strong>Hope this helps! Happy Hunting Protectors! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></strong></p>
<p><strong>ΞXΤЯ3МΞ</strong></p>
<p>The post <a href="https://techantidote.com/loki-apt-scanner/">How to search for IOCs on a Linux machine using Loki IOC and Yara scanner</a> appeared first on <a href="https://techantidote.com">Tech Antidote</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techantidote.com/loki-apt-scanner/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3699</post-id>	</item>
		<item>
		<title>DFIR &#8211; Analyze Windows Event Logs (evtx) from a Linux machine using sigma rules, chainsaw and evtx dump</title>
		<link>https://techantidote.com/dfir-analyze-windows-event-logs-evtx-from-a-linux-machine-using-sigma-rules-chainsaw-and-evtx-dump/</link>
					<comments>https://techantidote.com/dfir-analyze-windows-event-logs-evtx-from-a-linux-machine-using-sigma-rules-chainsaw-and-evtx-dump/#respond</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Mon, 08 Jul 2024 00:18:57 +0000</pubDate>
				<category><![CDATA[Digital Forensics]]></category>
		<category><![CDATA[analyze windows event logs from linux]]></category>
		<category><![CDATA[dfir]]></category>
		<category><![CDATA[evtx]]></category>
		<category><![CDATA[forensics]]></category>
		<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://techantidote.com/?p=3760</guid>

					<description><![CDATA[<p>At work, I had a task to perform a quick compromise assessment for a hacked Windows server and I got a bunch of etvx files from the suspected host for analysis. I run Linux Mint + i3-gaps and its much easier and productive performing forensics from a Linux machine than Windows in my honest opinion. &#8230; <a href="https://techantidote.com/dfir-analyze-windows-event-logs-evtx-from-a-linux-machine-using-sigma-rules-chainsaw-and-evtx-dump/" class="more-link">Continue reading <span class="screen-reader-text">DFIR &#8211; Analyze Windows Event Logs (evtx) from a Linux machine using sigma rules, chainsaw and evtx dump</span> <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://techantidote.com/dfir-analyze-windows-event-logs-evtx-from-a-linux-machine-using-sigma-rules-chainsaw-and-evtx-dump/">DFIR &#8211; Analyze Windows Event Logs (evtx) from a Linux machine using sigma rules, chainsaw and evtx dump</a> appeared first on <a href="https://techantidote.com">Tech Antidote</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>At work, I had a task to perform a quick compromise assessment for a hacked Windows server and I got a bunch of etvx files from the suspected host for analysis. I run Linux Mint + i3-gaps and its much easier and productive performing forensics from a Linux machine than Windows in my honest opinion. This post is meant for Linux users who want to perform Digital Forensics to find IOCs from Windows artifacts such as event logs / evtx files. Here my setup for forensics analsys for windows from a Linux perspective and the tools that I use.</p>
<p>Here are some tools that will come handy:</p>
<pre class="prismjs line-numbers language-plaintext"><code class="language-plaintext">apt update &amp;&amp; apt install git vim tar jq libxml2-utils source-highlight -y</code></pre>
<h3><strong>Sigma Rules:</strong></h3>
<p>Get the latest sigma rules:</p>
<pre class="prismjs line-numbers language-plaintext"><code class="language-plaintext">cd ~/
git clone https://github.com/SigmaHQ/sigma
git clone https://github.com/sbousseaden/EVTX-ATTACK-SAMPLES.git</code></pre>
<h3>Chainsaw:</h3>
<p>&#8211; Install chainsaw:</p>
<pre class="prismjs line-numbers language-plaintext"><code class="language-plaintext">wget https://github.com/WithSecureLabs/chainsaw/releases/download/v2.9.1-2/chainsaw_x86_64-unknown-linux-gnu.tar.gz -O ~/chainsaw.tar.gz
tar zxvf ~/chainsaw.tar.gz
chmod +x ~/chainsaw/chainsaw</code></pre>
<p><code class="language-plaintext"><strong>Example:</strong> Assume that you have a bunch of evtx files that you want to analyze and you have it in a directory "~/EVTX-ATTACK-SAMPLES/", you can run chainsaw against the directory where the evtx files are stored with the below command: </code></p>
<pre class="prismjs line-numbers language-plaintext"><code class="language-plaintext">./chainsaw/chainsaw hunt ~/EVTX-ATTACK-SAMPLES/ -s ~/sigma/ --mapping ~/chainsaw/mappings/sigma-event-logs-all.yml -r ~/sigma/rules</code></pre>
<p>&#8211; The above will output the findings in stdout.</p>
<p><img decoding="async" data-attachment-id="3765" data-permalink="https://techantidote.com/dfir-analyze-windows-event-logs-evtx-from-a-linux-machine-using-sigma-rules-chainsaw-and-evtx-dump/chainsaw/" data-orig-file="https://techantidote.com/wp-content/uploads/2024/07/chainsaw.png" data-orig-size="951,304" data-comments-opened="1" data-image-title="chainsaw" data-image-description="&lt;p&gt;chainsaw&lt;/p&gt;
" data-image-caption="" data-large-file="https://techantidote.com/wp-content/uploads/2024/07/chainsaw.png" class="alignnone size-full wp-image-3765" src="https://techantidote.com/wp-content/uploads/2024/07/chainsaw.png" alt="" width="951" height="304" srcset="https://techantidote.com/wp-content/uploads/2024/07/chainsaw.png 951w, https://techantidote.com/wp-content/uploads/2024/07/chainsaw-300x96.png 300w, https://techantidote.com/wp-content/uploads/2024/07/chainsaw-768x246.png 768w" sizes="(max-width: 951px) 100vw, 951px" /></p>
<p>Now, let say you want to output these in <strong>csv</strong> for reporting or further analysis, you can run the below:<code class="language-plaintext"></code></p>
<pre class="prismjs line-numbers language-plaintext"><code class="language-plaintext">./chainsaw/chainsaw hunt ~/EVTX-ATTACK-SAMPLES/ -s ~/sigma/ --mapping ~/chainsaw/mappings/sigma-event-logs-all.yml -r ~/sigma/rules/ <strong>--csv </strong>--output csv-outputs</code></pre>
<p><span style="white-space: pre-wrap;">Alternatively, chainsaw also has the option to output in <strong>json</strong> file. This comes handy if you want to injest into a SIEM tool like Wazuh/Opensearch/ES/Spunk.</span></p>
<pre class="prismjs line-numbers language-plaintext"><code class="language-plaintext">/chainsaw/chainsaw hunt ~/EVTX-ATTACK-SAMPLES/ -s ~/sigma/ --mapping ~/chainsaw/mappings/sigma-event-logs-all.yml -r ~/sigma/rules/ <strong>--json --output json-output</strong></code></pre>
<p><strong>Chainsaw filters and advanced searching:</strong></p>
<p>&#8211; Chainsaw has options to search for specific event ids. For example, to search for Login Failures (Windows Event ID = 4625), you use the below command:</p>
<pre class="lx ly lz ma mb pk nd pl bo pm ba bj"><span id="d554" class="pn nr fp nd b bf po pp l pq pr" data-selectable-paragraph="">./chainsaw search -t <span class="hljs-string">'<strong>Event.System.EventID: =4625</strong>'</span> windows-log.evtx
</span></pre>
<p>&#8211; To search for specific strings such as to search for lssas dumps:</p>
<pre class="lx ly lz ma mb pk nd pl bo pm ba bj"><span id="fb04" class="pn nr fp nd b bf po pp l pq pr" data-selectable-paragraph="">./chainsaw search -e <span class="hljs-string">"lsass"</span> -i windows-log.evtx</span><span id="fb04" class="pn nr fp nd b bf po pp l pq pr" data-selectable-paragraph="">
</span></pre>
<p>&#8211; You can also search an entire directory of evtx files as well:</p>
<pre class="lx ly lz ma mb pk nd pl bo pm ba bj"><span id="fb04" class="pn nr fp nd b bf po pp l pq pr" data-selectable-paragraph="">./chainsaw search -e "lsass" -i <code class="language-plaintext"> ~/EVTX-ATTACK-SAMPLES/</code></span></pre>
<p>&#8211; To search for events between two timeframes:</p>
<pre class="lx ly lz ma mb pk nd pl bo pm ba bj"><span id="1dd1" class="pn nr fp nd b bf po pp l pq pr" data-selectable-paragraph=""><span class="hljs-string"><code class="language-plaintext">./chainsaw/chainsaw hunt ~/EVTX-ATTACK-SAMPLES/ -s ~/sigma/ --mapping ~/chainsaw/mappings/sigma-event-logs-all.yml -r ~/sigma/rules/ </code><strong>--from "2021-11-01T07:01:00" --to "2022-01-01T07:01:00"</strong></span></span></pre>
<p>&#8211; Below is screenshot for reference. (Right click image and open in new tab for better visual)</p>
<p><img loading="lazy" decoding="async" data-attachment-id="3767" data-permalink="https://techantidote.com/dfir-analyze-windows-event-logs-evtx-from-a-linux-machine-using-sigma-rules-chainsaw-and-evtx-dump/chainsaw-ouput/" data-orig-file="https://techantidote.com/wp-content/uploads/2024/07/chainsaw-ouput.png" data-orig-size="1555,744" data-comments-opened="1" data-image-title="chainsaw-ouput" data-image-description="" data-image-caption="" data-large-file="https://techantidote.com/wp-content/uploads/2024/07/chainsaw-ouput-1024x490.png" class="alignnone wp-image-3767 size-large" src="https://techantidote.com/wp-content/uploads/2024/07/chainsaw-ouput-1024x490.png" alt="" width="474" height="227" srcset="https://techantidote.com/wp-content/uploads/2024/07/chainsaw-ouput-1024x490.png 1024w, https://techantidote.com/wp-content/uploads/2024/07/chainsaw-ouput-300x144.png 300w, https://techantidote.com/wp-content/uploads/2024/07/chainsaw-ouput-768x367.png 768w, https://techantidote.com/wp-content/uploads/2024/07/chainsaw-ouput-1536x735.png 1536w, https://techantidote.com/wp-content/uploads/2024/07/chainsaw-ouput.png 1555w" sizes="auto, (max-width: 474px) 100vw, 474px" /></p>
<h3><strong>Evtx Dump:</strong></h3>
<p>If you like to dump all the events in a Windows event file for further analysis, there is an awesome opensource tool that allows you to just do that.</p>
<pre class="prismjs line-numbers language-plaintext"><code class="language-plaintext">wget https://github.com/omerbenamram/evtx/releases/download/v0.8.2/evtx_dump-v0.8.2-x86_64-unknown-linux-gnu -O ~/evtx_dump
chmod +x ~/evtx_dump</code></pre>
<p>&#8211;  To use the dump (Events will be separated with string “Event &lt;count&gt;&#8221; in the output file). This is handy when using vim/less by searching for &#8220;^Event &#8221; and then using &#8220;n&#8221; to go the next event.</p>
<div class="code-toolbar">
<pre class="prismjs line-numbers language-plaintext"><code class="language-plaintext">./evtx_dump-v0.8.2-x86_64-unknown-linux-gnu \
EVTX-ATTACK-SAMPLES/Discovery/4799_remote_local_groups_enumeration.evtx <strong>-f</strong> 4799_remote_local_groups_enumeration.<strong>parsed.xml</strong></code></pre>
<p><code class="language-plaintext"><br />
- Another method is to print to stdout and redirect to file:</code></p>
</div>
<pre class="prismjs line-numbers language-plaintext"><code class="language-plaintext">./evtx_dump-v0.8.2-x86_64-unknown-linux-gnu \
EVTX-ATTACK-SAMPLES/Discovery/4799_remote_local_groups_enumeration.evtx <strong>&gt;</strong> 4799_remote_local_groups_enumeration.<strong>parsed.xml</strong></code></pre>
<ul>
<li>To generate the dump <span style="color: #ff0000;"><strong>without the event separators</strong></span> in xml format:</li>
</ul>
<div class="code-toolbar">
<pre class="prismjs line-numbers language-plaintext"><code class="language-plaintext">./evtx_dump-v0.8.2-x86_64-unknown-linux-gnu \
<span style="color: #ff0000;"><strong>--dont-show-record-number</strong></span> \
EVTX-ATTACK-SAMPLES/Discovery/<strong>4799_remote_local_groups_enumeration.evtx  -f</strong> <strong>4799_remote_local_groups_enumeration.parsed.xml</strong></code></pre>
</div>
<div class="toolbar">
<div class="toolbar-item">&#8211; With this xml format, you can open this inside <strong>vim</strong> or use <strong>source-highlight</strong> to make it more readable.</div>
</div>
<div class="code-toolbar">
<pre class="prismjs line-numbers language-plaintext"><code class="language-plaintext"><strong>cat 4799_remote_local_groups_enumeration.parsed.xml | xmllint --format - | source-highlight -s xml -f esc | less -R</strong></code></pre>
</div>
<ul>
<li>To generate in json format:</li>
</ul>
<div class="code-toolbar">
<pre class="prismjs line-numbers language-plaintext"><code class="language-plaintext">./evtx_dump-v0.8.2-x86_64-unknown-linux-gnu \
EVTX-ATTACK-SAMPLES/Discovery/4799_remote_local_groups_enumeration.evtx <strong>-o json</strong> <strong>-f</strong> 4799_remote_local_groups_enumeration.<strong>parsed</strong>.<strong>json</strong>

./evtx_dump-v0.8.2-x86_64-unknown-linux-gnu \
<strong>--dont-show-record-number</strong> \
EVTX-ATTACK-SAMPLES/Discovery/4799_remote_local_groups_enumeration.evtx <strong>-o json -f </strong>4799_remote_local_groups_enumeration.<strong>parsed.json</strong></code></pre>
<p><code class="language-plaintext">- For <strong>jsonl</strong> format, you the below:</code></p>
<pre class="prismjs line-numbers language-plaintext"><code class="language-plaintext">./evtx_dump-v0.8.2-x86_64-unknown-linux-gnu \
EVTX-ATTACK-SAMPLES/Discovery/4799_remote_local_groups_enumeration.evtx <strong>-o jsonl -f</strong> 4799_remote_local_groups_enumeration.parsed.<strong>json</strong>
</code></pre>
<ul>
<li>Here is CLI usage:</li>
</ul>
<div class="code-toolbar">
<pre class="prismjs line-numbers language-plaintext"><code class="language-plaintext"><strong>./evtx_dump-v0.8.2-x86_64-unknown-linux-gnu -h</strong></code></pre>
</div>
</div>
<p><strong>Credits/References:</strong></p>
<p><a href="https://github.com/WithSecureLabs/chainsaw">Chainsaw github</a><br />
<a href="https://github.com/sbousseaden/EVTX-ATTACK-SAMPLES">EVTX-ATTACK-SAMPLES</a><br />
<a href="https://medium.com/@izzyboop/grab-your-chainsaw-were-going-hunting-50a5c82cef5d">izzyboop</a></p>
<p>Hope this helps. <strong>Happy Hunting Defenders! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></strong></p>
<p>ΞXΤЯ3МΞ</p>
<p>The post <a href="https://techantidote.com/dfir-analyze-windows-event-logs-evtx-from-a-linux-machine-using-sigma-rules-chainsaw-and-evtx-dump/">DFIR &#8211; Analyze Windows Event Logs (evtx) from a Linux machine using sigma rules, chainsaw and evtx dump</a> appeared first on <a href="https://techantidote.com">Tech Antidote</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techantidote.com/dfir-analyze-windows-event-logs-evtx-from-a-linux-machine-using-sigma-rules-chainsaw-and-evtx-dump/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3760</post-id>	</item>
		<item>
		<title>Password protect file using 7z in Linux from the terminal</title>
		<link>https://techantidote.com/password-protect-file-using-7z-in-linux-from-the-terminal/</link>
					<comments>https://techantidote.com/password-protect-file-using-7z-in-linux-from-the-terminal/#respond</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Tue, 31 Oct 2023 17:02:23 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[7z]]></category>
		<category><![CDATA[7zip]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[password protect]]></category>
		<category><![CDATA[zip]]></category>
		<guid isPermaLink="false">https://techantidote.com/?p=3696</guid>

					<description><![CDATA[<p>This is a short post on how to password protect a file using 7z in Linux from the terminal. Below is the sample command that encrypts file &#8220;file.txt&#8221; with password (Replace PASSWORD with your pass) and saves to encrypted zip file Protected.zip 7z a Protected.zip -pPASSWORD file.txt Credits/References: Stackoverflow</p>
<p>The post <a href="https://techantidote.com/password-protect-file-using-7z-in-linux-from-the-terminal/">Password protect file using 7z in Linux from the terminal</a> appeared first on <a href="https://techantidote.com">Tech Antidote</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This is a short post on how to password protect a file using 7z in Linux from the terminal.</p>
<p>Below is the sample command that encrypts file &#8220;file.txt&#8221; with password (Replace PASSWORD with your pass) and saves to encrypted zip file Protected.zip</p>
<p>7z a Protected.zip -p<strong>PASSWORD</strong> file.txt</p>
<p><strong>Credits/References:</strong></p>
<p><a href="https://stackoverflow.com/questions/32448318/7-zip-command-lines-to-add-password-protection-to-unprotected-zip-file" target="_blank" rel="noopener">Stackoverflow</a></p>
<p>The post <a href="https://techantidote.com/password-protect-file-using-7z-in-linux-from-the-terminal/">Password protect file using 7z in Linux from the terminal</a> appeared first on <a href="https://techantidote.com">Tech Antidote</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techantidote.com/password-protect-file-using-7z-in-linux-from-the-terminal/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3696</post-id>	</item>
		<item>
		<title>Setup Wireguard VPN Server and Client in Ubuntu 20.04</title>
		<link>https://techantidote.com/wireguard-vpn-server-setup-ubuntu/</link>
					<comments>https://techantidote.com/wireguard-vpn-server-setup-ubuntu/#respond</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Fri, 01 Jul 2022 20:12:46 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux / Ubuntu]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[mint]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[ubuntu 20.04]]></category>
		<category><![CDATA[vpn]]></category>
		<category><![CDATA[wireguard]]></category>
		<guid isPermaLink="false">https://techantidote.com/?p=3599</guid>

					<description><![CDATA[<p>This a guide on how to setup Wireguard VPN on Ubuntu and setting up a Wireguard client. Requirements: 1. Ubuntu Server 20.04 used in my lab. (20.04 or higher is required for Policy routing) 2. Ubuntu Client (Ubuntu 20.04) 3. Root access to the server. 4. Network Access Note: This should also work on Linux &#8230; <a href="https://techantidote.com/wireguard-vpn-server-setup-ubuntu/" class="more-link">Continue reading <span class="screen-reader-text">Setup Wireguard VPN Server and Client in Ubuntu 20.04</span> <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://techantidote.com/wireguard-vpn-server-setup-ubuntu/">Setup Wireguard VPN Server and Client in Ubuntu 20.04</a> appeared first on <a href="https://techantidote.com">Tech Antidote</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This a guide on how to setup Wireguard VPN on Ubuntu and setting up a Wireguard client.</p>
<p><span style="color: #3366ff;"><strong>Requirements:</strong></span></p>
<p>1. Ubuntu Server 20.04 used in my lab. (20.04 or higher is required for Policy routing)</p>
<p>2. Ubuntu Client (Ubuntu 20.04)</p>
<p>3. Root access to the server.</p>
<p>4. Network Access</p>
<p><strong>Note:</strong> This should also work on Linux Mint 20.04</p>
<h3><span style="color: #3366ff;">Setting up the Wireguard Server</span></h3>
<p>Login to the In my lab, I have set up a EC2 instance and below is the current IP configuration before setting up Wireguard.</p>
<pre>root@ip-172-31-20-229:~# <strong>ip a
</strong>1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: <strong>eth0</strong>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 9001 qdisc fq_codel state UP group default qlen 1000
    link/ether 02:ca:92:5f:0e:80 brd ff:ff:ff:ff:ff:ff
    inet <strong>172.31.20.229/20</strong> brd 172.31.31.255 scope global dynamic eth0
       valid_lft 2617sec preferred_lft 2617sec
    inet6 fe80::ca:92ff:fe5f:e80/64 scope link 
       valid_lft forever preferred_lft forever
</pre>
<p>From above, I have a single interface with IP 172.31.20.229 assigned to eth0.</p>
<pre><strong>sudo apt update &amp;&amp; sudo apt upgrade -y
sudo apt install wireguard -y
</strong></pre>
<p>-Switch to root and run the following:</p>
<p><strong> sudo su &#8211; </strong></p>
<p>Below are the default permissions on the wireguard dir:</p>
<pre>root@ip-172-31-20-229:~# <strong>ls -l /etc/ | grep wireguard
</strong>drwx------ 2 root root       4096 Aug  4  2020 wireguard
</pre>
<p>-You could set permissions to the directory as follows:</p>
<pre><strong>chmod 0700 /etc/wireguard/</strong>
root@ip-172-31-20-229:~# <strong>ls -l /etc/ | grep wireguard
drwx------</strong> 2 root root       4096 Aug  4  2020 wireguard
</pre>
<p>To check the version of Wireguard installed:</p>
<pre>root@ip-172-31-20-229:/etc/wireguard# <strong>wg --version
</strong>wireguard-tools v1.0.20200513 - https://git.zx2c4.com/wireguard-tools/
</pre>
<p>-Generate public and private key pairs:</p>
<pre><strong>cd /etc/wireguard/
umask 077; wg genkey | tee privatekey | wg pubkey &gt; publickey
</strong></pre>
<p>This should generate the private and the public key:</p>
<pre>root@ip-172-31-20-229:/etc/wireguard# <strong>ls -l
</strong>total 8
-rw------- 1 root root 45 Jun 30 20:23 <strong>privatekey</strong>
-rw------- 1 root root 45 Jun 30 20:23 publickey
</pre>
<p>-Take a note of the private key &#8220;<strong>privatekey</strong>&#8221; <strong>cat privatekey</strong> . You will need to add this to the WG server&#8217;s conf file.</p>
<p><strong>Setting up the Wireguard Server&#8217;s configuration file</strong></p>
<pre><strong>vim /etc/wireguard/wg0.conf</strong></pre>
<p>Add below content. (Here, I chose the IP as <strong>192.168.6.1</strong> which is the new VPN private address that will be assigned to the interface)</p>
<pre><em>[Interface]
## My VPN server private IP address ##
Address = <strong>192.168.6.1
</strong> 
## My VPN server port ##
ListenPort = 41194
 
## VPN server's private key i.e. string from /etc/wireguard/privatekey ##
PrivateKey = <strong>ADD_PRIVATE_KEY_HERE
</strong></em></pre>
<p>-Allow the port in the Server&#8217;s Firewall:</p>
<pre>root@ip-172-31-20-229:~# <strong>sudo ufw allow 41194/udp</strong>
Rules updated
Rules updated (v6)
</pre>
<p>-To check the status:</p>
<pre><strong>sudo ufw status
</strong></pre>
<p>&#8211; Enable wireguard service on boot on the server and start the service:</p>
<pre>ubuntu@ip-172-31-20-229:~$ <strong>sudo systemctl enable wg-quick@wg0</strong>
Created symlink /etc/systemd/system/multi-user.target.wants/wg-quick@wg0.service → /lib/systemd/system/wg-quick@.service.

ubuntu@ip-172-31-20-229:~$ <strong>sudo systemctl start wg-quick@wg0
</strong></pre>
<p>To check the status of the wireguard service, use the following:</p>
<pre>root@ip-172-31-20-229:~# <strong>sudo systemctl status wg-quick@wg0
</strong>● wg-quick@wg0.service - WireGuard via wg-quick(8) for wg0
     Loaded: <strong>loaded</strong> (/lib/systemd/system/wg-quick@.service; enabled; vendor preset: enabled)
     Active: <strong>active</strong> (exited) since Thu 2022-06-30 21:29:01 UTC; 8min ago
       Docs: man:wg-quick(8)
             man:wg(8)
             https://www.wireguard.com/
             https://www.wireguard.com/quickstart/
             https://git.zx2c4.com/wireguard-tools/about/src/man/wg-quick.8
             https://git.zx2c4.com/wireguard-tools/about/src/man/wg.8
    Process: 2230 ExecStart=/usr/bin/wg-quick up wg0 (code=exited, status=0/SUCCESS)
   Main PID: 2230 (code=exited, status=0/SUCCESS)

Jun 30 21:29:01 ip-172-31-20-229 systemd[1]: wg-quick@wg0.service: Succeeded.
Jun 30 21:29:01 ip-172-31-20-229 systemd[1]: Stopped WireGuard via wg-quick(8) for wg0.
Jun 30 21:29:01 ip-172-31-20-229 systemd[1]: Starting WireGuard via wg-quick(8) for wg0...
Jun 30 21:29:01 ip-172-31-20-229 wg-quick[2230]: [#] <strong>ip link add wg0 type wireguard</strong>
Jun 30 21:29:01 ip-172-31-20-229 wg-quick[2230]: [#] wg setconf wg0 /dev/fd/63
Jun 30 21:29:01 ip-172-31-20-229 wg-quick[2230]: [#] <strong>ip -4 address add 192.168.6.1/24 dev wg0</strong>
Jun 30 21:29:01 ip-172-31-20-229 wg-quick[2230]: [#] ip link set mtu 8921 up dev wg0
Jun 30 21:29:01 ip-172-31-20-229 systemd[1]: Finished WireGuard via wg-quick(8) for wg0.
</pre>
<p>Checking the ifconfig output, you would see a <strong>new interface</strong> <strong>wg0 </strong>is created automatically which is expected.</p>
<pre>root@ip-172-31-20-229:~# <strong>ip a
</strong>1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: <strong>eth0</strong>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 9001 qdisc fq_codel state UP group default qlen 1000
    link/ether 02:ca:92:5f:0e:80 brd ff:ff:ff:ff:ff:ff
    inet <strong>172.31.20.229/20</strong> brd 172.31.31.255 scope global dynamic eth0
       valid_lft 2235sec preferred_lft 2235sec
    inet6 fe80::ca:92ff:fe5f:e80/64 scope link 
       valid_lft forever preferred_lft forever
5: <strong>wg0</strong>: &lt;POINTOPOINT,NOARP,UP,LOWER_UP&gt; mtu 8921 qdisc noqueue state UNKNOWN group default qlen 1000
    link/none 
    inet <strong>192.168.6.1/24</strong> scope global wg0
       valid_lft forever preferred_lft forever

</pre>
<p>&#8211; You can check wireguard information/stats using the below command:</p>
<pre>ubuntu@ip-172-31-20-229:~$ <strong>sudo wg
interface</strong>: <strong>wg0</strong>
  public key: pHrkGojLiNZy2GwshmdEXMaaOmowXXXXXXXXXXXXXXX=
  private key: (hidden)
  listening port: 41194
</pre>
<h3><span style="color: #3366ff;"><strong>Configuring the VPN Client</strong></span></h3>
<ul>
<li>Login to the client and install Wireguard.</li>
</ul>
<pre><strong>sudo apt install wireguard -y
</strong></pre>
<p>&#8211; Create the configuration file</p>
<pre>root@wg-client:~# <strong>sudo sh -c 'umask 077; touch /etc/wireguard/wg0.conf'
</strong>
root@wg-client:~# <strong>ls -l /etc/wireguard/wg0.conf 
</strong>-rw------- 1 root root 0 Jun 30 20:58 /etc/wireguard/wg0.conf</pre>
<ul>
<li><strong>Create a key pair in the client</strong></li>
</ul>
<p>&#8211; In the client machine, create a key pair:</p>
<pre>root@wg-client:~# <strong>cd /etc/wireguard/
</strong>
root@wg-client:/etc/wireguard# <strong>umask 077; wg genkey | tee privatekey | wg pubkey &gt; publickey
</strong>
root@wg-client:/etc/wireguard# <strong>ls -l 
</strong>total 8
-rw------- 1 root root 45 Jun 30 21:01 privatekey
-rw------- 1 root root 45 Jun 30 21:01 publickey
-rw------- 1 root root  0 Jun 30 20:58 wg0.conf
root@wg-client:/etc/wireguard# 
</pre>
<p>&#8211; Take a note of the client&#8217;s public key. (This will be added in the server&#8217;s config later)</p>
<p>-Take a note of the private key from the client. This will be added in its own config file.</p>
<pre><strong>cat privatekey</strong></pre>
<ul>
<li><strong>Edit config</strong></li>
</ul>
<blockquote><p><strong>vim /etc/wireguard/wg0.conf</strong></p></blockquote>
<p>&#8211; On the client, create the wireguard config file as below:</p>
<pre>[Interface]
## Add the client's private key which is from /etc/wireguard/publickey ##
PrivateKey = <strong>CLIENT_PRIVATE_KEY_HERE</strong>
 
## Client ip address that will be set by this Client ##
Address = <strong>192.168.6.2/24
</strong>  
[Peer]
## Ubuntu 20.04 server public key ##
PublicKey = <strong>SERVER_PUBLIC_KEY_HERE</strong>
 
## set ACL ##
AllowedIPs = 192.168.2.0/24
  
## Your Ubuntu 20.04 LTS server's public IPv4/IPv6 address and port ##
Endpoint = <strong>PUBLIC_IP_OF_YOUR_WIREGUARD_SERVER</strong>:41194
   
##  Key connection alive ##
PersistentKeepalive = 15

</pre>
<p>-On the client, enable and start the Wireguard service:</p>
<pre>root@wg-client:/etc/wireguard# <strong>sudo systemctl enable wg-quick@wg0
</strong>Created symlink /etc/systemd/system/multi-user.target.wants/wg-quick@wg0.service -&gt; /lib/systemd/system/wg-quick@.service.

root@wg-client:/etc/wireguard# <strong>sudo systemctl start wg-quick@wg0
</strong></pre>
<p>&#8211; Check the status of the service in the client:</p>
<pre>root@wg-client:~# <strong>sudo systemctl status wg-quick@wg0
</strong>* wg-quick@wg0.service - WireGuard via wg-quick(8) for wg0
     Loaded: <strong>loaded</strong> (/lib/systemd/system/wg-quick@.service; enabled; vendor preset: enabled)
     Active: <strong>active</strong> (exited) since Thu 2022-06-30 21:35:17 UTC; 5min ago
       Docs: man:wg-quick(8)
             man:wg(8)
             https://www.wireguard.com/
             https://www.wireguard.com/quickstart/
             https://git.zx2c4.com/wireguard-tools/about/src/man/wg-quick.8
             https://git.zx2c4.com/wireguard-tools/about/src/man/wg.8
    Process: 123 ExecStart=/usr/bin/wg-quick up wg0 (code=exited, status=0/SUCCESS)
   Main PID: 123 (code=exited, status=0/SUCCESS)
        CPU: 28ms

Jun 30 21:35:17 wg-client systemd[1]: Starting WireGuard via wg-quick(8) for wg0...
Jun 30 21:35:17 wg-client wg-quick[123]: [#] <strong>ip link add wg0 type wireguard
</strong>Jun 30 21:35:17 wg-client wg-quick[123]: [#] wg setconf wg0 /dev/fd/63
Jun 30 21:35:17 wg-client wg-quick[123]: [#] <strong>ip -4 address add 192.168.6.2/24 dev wg0
</strong>Jun 30 21:35:17 wg-client wg-quick[123]: [#] ip link set mtu 1420 up dev wg0
Jun 30 21:35:17 wg-client systemd[1]: Finished WireGuard via wg-quick(8) for wg0.
</pre>
<p>-From the above output, we can see that the <strong>wireguard</strong> service has <strong>created</strong> the <strong>interface</strong> <strong>wg0</strong> and assigned the IP <strong>192.168.6.2/24</strong> to it. You could also verify this by checking by checking the device ip conf as below:</p>
<pre>root@wg-client:~# <strong>ip a
</strong>1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0@if114: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether aa:3c:37:57:21:8a brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 192.168.1.143/24 brd 192.168.1.255 scope global dynamic eth0
       valid_lft 86010sec preferred_lft 86010sec
    inet6 fe80::a83c:37ff:fe57:218a/64 scope link 
       valid_lft forever preferred_lft forever
3: <strong>wg0</strong>: &lt;POINTOPOINT,NOARP,UP,LOWER_UP&gt; mtu 1420 qdisc noqueue state UNKNOWN group default qlen 1000
    link/none 
    inet <strong>192.168.6.2/24</strong> scope global wg0
       valid_lft forever preferred_lft forever
</pre>
<p>So far, we can configured the client to talk to the server. But the Server does not know about the client. So, next we need to update the Server&#8217;s Wireguard configuration file with the details of the wireguard client.</p>
<p>-Login to the Wireguard Server and add the below block to the server&#8217;s wireguard conf:</p>
<pre>[Peer]
## Desktop/client VPN public key ##
PublicKey = <strong>CLIENT_PUB_KEY_HERE</strong>

## client VPN IP address (note  the /32 subnet) ##
AllowedIPs = <strong>192.168.6.2/32
</strong></pre>
<p>-So, your Wireguard server&#8217;s configuration file will be as follows:</p>
<pre>[Interface]
## My VPN server private IP address ##
Address = <strong>192.168.6.1
</strong> 
## My VPN server port ##
ListenPort = 41194
 
## VPN server's private key i.e. /etc/wireguard/privatekey ##
PrivateKey = <strong>ADD_PRIVATE_KEY_HERE</strong>

[Peer]
## Desktop/client VPN public key ##
PublicKey = <strong>CLIENT_PUB_KEY_HERE</strong>

## client VPN IP address (note  the /32 subnet) ##
AllowedIPs = <strong>192.168.6.2/32
</strong></pre>
<p>&#8211; Start the service again on the server:</p>
<pre><strong>sudo systemctl start wg-quick@wg0
</strong></pre>
<p><span style="color: #3366ff;"><strong>Verify connectivity from the client =&gt; server:</strong></span></p>
<p>&#8211; If the server is in the cloud, then update the security groups tallow the port.</p>
<p>&#8211; From the client, ping the server 192.168.6.1</p>
<pre>root@wg-client:~# <strong>ping 192.168.6.1
</strong>PING 192.168.6.1 (192.168.6.1) 56(84) bytes of data.
64 bytes from 192.168.6.1: icmp_seq=1 ttl=64 time=81.9 ms
64 bytes from 192.168.6.1: icmp_seq=2 ttl=64 time=82.5 ms
^C
--- 192.168.6.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 81.886/82.172/82.458/0.286 ms
</pre>
<p><strong>Checking active connections from Wireguard server:</strong></p>
<p>&#8211; To see which clients are connected to the server and the statistics, you can run the below:</p>
<pre>root@ip-172-31-20-229:~# <strong>sudo wg
</strong>interface: wg0
  public key: pHrkGojLiNZy2GwshmdEXMaaOmowXXXXXXXXXXXXXXX=
  private key: (hidden)
  listening port: 41194

<strong>peer</strong>: 8Zp7Cji5Aseew3L0P3c35sUzJNIPYYYYYYYYYYYYYYY=
  endpoint: <strong>1.2.3.4</strong>:33395
  allowed ips: 192.168.6.2/32
  latest handshake: 1 minute, 12 seconds ago
  transfer: 3.94 KiB received, 1.47 KiB sent
</pre>
<p><span style="color: #3366ff;"><strong>Additional Information:</strong></span></p>
<p>For debugging issue with wireguard, you could check the logs:</p>
<pre><strong>sudo journalctl -eu wg-quick@wg0</strong></pre>
<p>Here is a little cronjob to monitor the tunnel via ping and restart tunnel: (Credits to linuxbabe)</p>
<pre><strong>sudo crontab -e</strong></pre>
<p>-Add the below:</p>
<pre>SHELL=/bin/bash
* * * * * for ((i=1; i&lt;=6; i++)) do (ping -c9 192.168.6.1 &gt; /dev/null || systemctl restart wg-quick@wg0) done
</pre>
<p>Hope this helps! Cheers!</p>
<p><strong>Sources/References:</strong></p>
<p>https://www.cyberciti.biz/faq/ubuntu-20-04-set-up-wireguard-vpn-server/</p>
<blockquote class="wp-embedded-content" data-secret="32BYiyMmZq"><p><a href="https://www.linuxbabe.com/ubuntu/wireguard-vpn-server-ubuntu">Set Up Your Own WireGuard VPN Server on Ubuntu 24.04/22.04</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  title="&#8220;Set Up Your Own WireGuard VPN Server on Ubuntu 24.04/22.04&#8221; &#8212; LinuxBabe" src="https://www.linuxbabe.com/ubuntu/wireguard-vpn-server-ubuntu/embed#?secret=fha41Gk5Ja#?secret=32BYiyMmZq" data-secret="32BYiyMmZq" width="474" height="267" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>The post <a href="https://techantidote.com/wireguard-vpn-server-setup-ubuntu/">Setup Wireguard VPN Server and Client in Ubuntu 20.04</a> appeared first on <a href="https://techantidote.com">Tech Antidote</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techantidote.com/wireguard-vpn-server-setup-ubuntu/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3599</post-id>	</item>
		<item>
		<title>Hexadecimal basics using basic Linux utilities</title>
		<link>https://techantidote.com/hexadecimal-basics-using-basic-linux-utilities/</link>
					<comments>https://techantidote.com/hexadecimal-basics-using-basic-linux-utilities/#respond</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Sat, 21 Aug 2021 20:29:30 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[hex]]></category>
		<category><![CDATA[hexadecimal]]></category>
		<category><![CDATA[reverse engineering]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[xxd]]></category>
		<guid isPermaLink="false">https://techantidote.com/?p=3529</guid>

					<description><![CDATA[<p>A beginner friendly guide to hexadecimal in Linux using xxd and printf.</p>
<p>The post <a href="https://techantidote.com/hexadecimal-basics-using-basic-linux-utilities/">Hexadecimal basics using basic Linux utilities</a> appeared first on <a href="https://techantidote.com">Tech Antidote</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">This is short guide on how to convert strings  and decimal values to hexadecimal and vice-versa using simple Linux utilities such as xxd and printf.</p>



<ol class="wp-block-list"><li><strong>To convert a string to hexadecimal, you can use xxd in Linux.</strong></li></ol>



<p class="wp-block-paragraph">For example: To convert a string &#8220;<strong>kali</strong>&#8221; to hexadecimal, you can use the below format. </p>



<pre class="wp-block-preformatted">extr3me@op3n:~$ <strong><span style="color: #ff0000;">echo -n kali | xxd</span></strong>
00000000: <span style="color: #ff0000;">6b61 6c69</span> kali
</pre>



<p class="wp-block-paragraph">To group and display the output a single character at a time, use -c&nbsp; flag with argument 1.</p>



<pre class="wp-block-preformatted">extr3me@op3n:~$ <span style="color: #ff0000;"><strong>echo -n kali | xxd -c1</strong>
</span>00000000: <span style="color: #ff0000;">6b</span> k
00000001: <span style="color: #ff0000;">61</span> a
00000002: <span style="color: #ff0000;">6c</span> l
00000003: <span style="color: #ff0000;">69</span> i
</pre>



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



<pre class="wp-block-preformatted">00000000: <strong>6b k</strong>&nbsp;&lt;- <strong>k</strong> is a single character and its <strong>hexadecimal value is</strong> <strong>6b</strong>
00000001: <strong>61 a</strong> &lt;- <strong>a</strong> is a single character and its <strong>hexadecimal value is 61</strong>
00000002: <strong>6c l</strong> &lt;- <strong>l</strong> is a single character and its <strong>hexadecimal value is 6c</strong>
00000003: <strong>69 i</strong> &lt;- <strong>i</strong> is a single character and its <strong>hexadecimal value is 69</strong>
</pre>



<p class="wp-block-paragraph">2.<strong> Convert Hexadecimal value back to string:</strong></p>



<pre class="wp-block-preformatted">extr3me@op3n:~$ <span style="color: #ff0000;">echo -n "6b61 6c69" | xxd -r -p
kali
</span></pre>



<p class="wp-block-paragraph">Dont worry about the spaces, it should still work.</p>



<pre class="wp-block-preformatted">extr3me@op3n:~$<span style="color: #ff0000;"> echo -n "6b616c69" | xxd -r -p
kali</span>extr3me@op3n:~$</pre>



<p class="wp-block-paragraph">3. <strong>Convert decimal (number) to hexadecimal</strong></p>



<p class="wp-block-paragraph">-Lets say you want to convert number 12 to decimal value. To do so, you could use <strong>printf</strong> as shown below.</p>



<pre class="wp-block-preformatted">extr3me@op3n:~$ <span style="color: #ff0000;">printf "%x\n" 12
c
</span></pre>



<p class="wp-block-paragraph">From above output, the hexadecimal value for number <strong>12</strong> (aka decimal 12) is character <strong>c</strong>.</p>



<p class="has-text-align-justify wp-block-paragraph"><strong>To find hexadecimal values for values from 1 to 255, you could run through it in a loop </strong></p>



<pre class="wp-block-code"><code>for num in {1..255}; do printf "%x\n" $num ; done | less</code></pre>



<p class="wp-block-paragraph">Hope these help. </p>



<p class="wp-block-paragraph">PS: Knowing hexadecimal does come in handy while learning/debugging different protocols.</p>
<p>The post <a href="https://techantidote.com/hexadecimal-basics-using-basic-linux-utilities/">Hexadecimal basics using basic Linux utilities</a> appeared first on <a href="https://techantidote.com">Tech Antidote</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techantidote.com/hexadecimal-basics-using-basic-linux-utilities/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3529</post-id>	</item>
		<item>
		<title>How to fix &#8220;Error opening terminal: xterm-termite&#8221; when trying to SSH to a remote host</title>
		<link>https://techantidote.com/how-to-fix-error-opening-terminal-xterm-termite-when-trying-to-ssh-to-a-remote-host/</link>
					<comments>https://techantidote.com/how-to-fix-error-opening-terminal-xterm-termite-when-trying-to-ssh-to-a-remote-host/#respond</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Mon, 31 May 2021 23:27:06 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[arch-linux]]></category>
		<category><![CDATA[archlinux]]></category>
		<category><![CDATA[i3-gaps]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[termite]]></category>
		<category><![CDATA[xterm-termite]]></category>
		<guid isPermaLink="false">https://techantidote.com/?p=3499</guid>

					<description><![CDATA[<p>I am using &#8220;termite&#8221; on my ArchLinux machine but when I try to SSH to a remote linux machine(Ubuntu) to run some commands, it throws me an error &#8220;Error opening terminal: xterm-termite&#8220;. This a post on how to fix it. Quick Fix: If you are already SSH&#8217;ed into the remote machine and you see this &#8230; <a href="https://techantidote.com/how-to-fix-error-opening-terminal-xterm-termite-when-trying-to-ssh-to-a-remote-host/" class="more-link">Continue reading <span class="screen-reader-text">How to fix &#8220;Error opening terminal: xterm-termite&#8221; when trying to SSH to a remote host</span> <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://techantidote.com/how-to-fix-error-opening-terminal-xterm-termite-when-trying-to-ssh-to-a-remote-host/">How to fix &#8220;Error opening terminal: xterm-termite&#8221; when trying to SSH to a remote host</a> appeared first on <a href="https://techantidote.com">Tech Antidote</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I am using &#8220;<strong>termite</strong>&#8221; on my ArchLinux machine but when I try to SSH to a remote linux machine(Ubuntu) to run some commands, it throws me an error &#8220;<strong><em>Error opening terminal: xterm-termite</em></strong>&#8220;. This a post on how to fix it.</p>
<p><span style="text-decoration: underline;"><strong>Quick Fix:</strong></span></p>
<p>If you are already SSH&#8217;ed into the remote machine and you see this issue, you could update the <strong>TERM</strong> variable on the remote system: (Run on remote system)</p>
<pre><span style="color: #ff9900;"><strong>export TERM=xterm-256color</strong></span></pre>
<p><span style="text-decoration: underline;"><strong>Permanent Fix:</strong></span></p>
<p>The permanent fix is to edit <strong>your local</strong> <strong>~/.bashrc</strong> file to include the following:</p>
<pre><span style="color: #ff9900;"><strong>if [ "$TERM" = xterm ]; then
TERM=xterm-256color;
fi
export TERM=xterm-256color</strong>
</span></pre>
<p>In my case, I had to add it to my Arch Linux&#8217;s ~/.bashrc file. (i.e not on the remote Ubuntu machine that I am connecting to)</p>
<p>Here is a screenshot from my box: (Right click image and open in new team to view in full screen)</p>
<p><img loading="lazy" decoding="async" data-attachment-id="3507" data-permalink="https://techantidote.com/how-to-fix-error-opening-terminal-xterm-termite-when-trying-to-ssh-to-a-remote-host/my-arch-i3-gaps-rice/" data-orig-file="https://techantidote.com/wp-content/uploads/2021/06/my-arch-i3-gaps-rice.png" data-orig-size="1926,1080" data-comments-opened="1" data-image-title="my-arch-i3-gaps-rice" data-image-description="" data-image-caption="" data-large-file="https://techantidote.com/wp-content/uploads/2021/06/my-arch-i3-gaps-rice-1024x574.png" class="alignnone wp-image-3507 size-full" src="https://techantidote.com/wp-content/uploads/2021/06/my-arch-i3-gaps-rice.png" alt="arch linux termite i3-gaps" width="1926" height="1080" srcset="https://techantidote.com/wp-content/uploads/2021/06/my-arch-i3-gaps-rice.png 1926w, https://techantidote.com/wp-content/uploads/2021/06/my-arch-i3-gaps-rice-300x168.png 300w, https://techantidote.com/wp-content/uploads/2021/06/my-arch-i3-gaps-rice-1024x574.png 1024w, https://techantidote.com/wp-content/uploads/2021/06/my-arch-i3-gaps-rice-768x431.png 768w, https://techantidote.com/wp-content/uploads/2021/06/my-arch-i3-gaps-rice-1536x861.png 1536w" sizes="auto, (max-width: 1926px) 100vw, 1926px" /></p>
<p>To verify its fixed, open a new terminal (or source ~/.bashrc again) and SSH into the remote machine. Ideally this should be fixed.</p>
<p>Hope this helps!</p>
<p><strong>Note:</strong> If you terminal does not support 256-color, then you may need to change the TERM variable to &#8220;xterm-color&#8221; instead of &#8220;xterm-256color&#8221;.</p>
<p><span style="text-decoration: underline;"><strong>Credits/References:</strong></span></p>
<p><a href="https://github.com/thestinger/termite/issues/630">Github</a></p>
<p>The post <a href="https://techantidote.com/how-to-fix-error-opening-terminal-xterm-termite-when-trying-to-ssh-to-a-remote-host/">How to fix &#8220;Error opening terminal: xterm-termite&#8221; when trying to SSH to a remote host</a> appeared first on <a href="https://techantidote.com">Tech Antidote</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techantidote.com/how-to-fix-error-opening-terminal-xterm-termite-when-trying-to-ssh-to-a-remote-host/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3499</post-id>	</item>
		<item>
		<title>Filter top using process name in Linux</title>
		<link>https://techantidote.com/filter-top-using-process-name-in-linux/</link>
					<comments>https://techantidote.com/filter-top-using-process-name-in-linux/#comments</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Sun, 04 Oct 2020 09:27:25 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[pgrep]]></category>
		<category><![CDATA[top]]></category>
		<category><![CDATA[top command]]></category>
		<category><![CDATA[troubleshooting]]></category>
		<category><![CDATA[ubuntu]]></category>
		<guid isPermaLink="false">https://techantidote.com/?p=3372</guid>

					<description><![CDATA[<p>To display statistics only for a process name that match a string using top, you could use the following: top -c -p $(pgrep -d',' -f firefox) Here is a screenshot which only shows stats for firefox: Hope this helps! Cheers! &#160; Source/Credits/Reference: StackOverflow</p>
<p>The post <a href="https://techantidote.com/filter-top-using-process-name-in-linux/">Filter top using process name in Linux</a> appeared first on <a href="https://techantidote.com">Tech Antidote</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>To display statistics only for a process name that match a string using top, you could use the following:</p>
<pre>top -c -p $(pgrep -d',' -f <span style="color: #ff0000;"><strong>firefox</strong></span>)</pre>
<p>Here is a screenshot which only shows stats for firefox:</p>
<p><img loading="lazy" decoding="async" data-attachment-id="3375" data-permalink="https://techantidote.com/filter-top-using-process-name-in-linux/top-filtered-output/" data-orig-file="https://techantidote.com/wp-content/uploads/2020/10/top-filtered-output.png" data-orig-size="1920,431" data-comments-opened="1" data-image-title="top-filtered-output" data-image-description="" data-image-caption="" data-large-file="https://techantidote.com/wp-content/uploads/2020/10/top-filtered-output-1024x230.png" class="alignnone wp-image-3375 size-full" src="https://techantidote.com/wp-content/uploads/2020/10/top-filtered-output.png" alt="top filtered output screenshot in Linux" width="1920" height="431" srcset="https://techantidote.com/wp-content/uploads/2020/10/top-filtered-output.png 1920w, https://techantidote.com/wp-content/uploads/2020/10/top-filtered-output-300x67.png 300w, https://techantidote.com/wp-content/uploads/2020/10/top-filtered-output-1024x230.png 1024w, https://techantidote.com/wp-content/uploads/2020/10/top-filtered-output-768x172.png 768w, https://techantidote.com/wp-content/uploads/2020/10/top-filtered-output-1536x345.png 1536w" sizes="auto, (max-width: 1920px) 100vw, 1920px" /></p>
<p>Hope this helps! Cheers!</p>
<p>&nbsp;</p>
<p><strong>Source/Credits/Reference:</strong> <a href="https://stackoverflow.com/questions/12075591/top-c-command-in-linux-to-filter-processes-listed-based-on-processname#12075782" target="_blank" rel="noopener noreferrer">StackOverflow</a></p>
<p>The post <a href="https://techantidote.com/filter-top-using-process-name-in-linux/">Filter top using process name in Linux</a> appeared first on <a href="https://techantidote.com">Tech Antidote</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techantidote.com/filter-top-using-process-name-in-linux/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3372</post-id>	</item>
		<item>
		<title>Mount TrueNAS Core Samba share on Linux</title>
		<link>https://techantidote.com/mount-truenas-core-samba-share-on-linux/</link>
					<comments>https://techantidote.com/mount-truenas-core-samba-share-on-linux/#respond</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Sun, 12 Jul 2020 14:52:08 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[linux mint]]></category>
		<category><![CDATA[mount]]></category>
		<category><![CDATA[samba]]></category>
		<category><![CDATA[smb]]></category>
		<category><![CDATA[smb share]]></category>
		<category><![CDATA[truenas]]></category>
		<category><![CDATA[truenas core]]></category>
		<category><![CDATA[truenas12]]></category>
		<guid isPermaLink="false">https://techantidote.com/?p=3183</guid>

					<description><![CDATA[<p>This is a guide that describes on how to mount a remote Samba share configured on TrueNAS on to a Linux machine. &#160; Login in your Linux machine. (I am using a Linux Mint 19.3 in this demo. This should technically work on other Debian/Ubuntu based systems as well). Use the following commands to get &#8230; <a href="https://techantidote.com/mount-truenas-core-samba-share-on-linux/" class="more-link">Continue reading <span class="screen-reader-text">Mount TrueNAS Core Samba share on Linux</span> <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://techantidote.com/mount-truenas-core-samba-share-on-linux/">Mount TrueNAS Core Samba share on Linux</a> appeared first on <a href="https://techantidote.com">Tech Antidote</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This is a guide that describes on how to mount a remote Samba share configured on TrueNAS on to a Linux machine.</p>
<p>&nbsp;</p>
<p>Login in your Linux machine. (I am using a Linux Mint 19.3 in this demo. This should technically work on other Debian/Ubuntu based systems as well).</p>
<p>Use the following commands to get your current user&#8217;s <em>user ID</em> (UID) and <em>group ID</em> (GID) respectively.</p>
<pre>id -u $USER
id -G $USER
</pre>
<p>Create a file <span style="color: #00ff00;">/etc/.truenas_creds</span>. This is where you would store the samba credentials.</p>
<p>Replace text in <span style="color: #ff0000;">red</span> with the username and password of the remote SMB share which was configured in TrueNas.</p>
<pre>cat <span style="color: #00ff00;">/etc/.truenas_creds</span>
username=<span style="color: #ff0000;">enter_username_here</span>
password=<span style="color: #ff0000;">enter_password_here
</span></pre>
<p>Modify the file permissions so that root is the owner and set the file permission to 600.</p>
<pre>sudo chown root: /etc/.truenas_creds
sudo chmod 600 /etc/.truenas_creds
</pre>
<p>In your linux machine, create a folder to where you want the contents of the remote samba share to be mounts. For example: create a directory named <span style="color: #00ccff;"><em>/mnt/truenas/</em></span>.</p>
<pre>sudo mkdir <span style="color: #00ccff;">/mnt/truenas/
</span></pre>
<p>-Below is a sample syntax that can be used for populating <strong>/etc/fstab</strong>.</p>
<pre>//ip-of-nas-server/enter-remote-samba-share/location /enter-local-mount/location/here/ cifs credentials=<span style="color: #00ff00;">/etc/.truenas_creds</span>,iocharset=utf8,uid=enter_your_uid_here,gid=enter_your_gid_here,noperm 0 0
</pre>
<p>-Here is what that I added in /etc/fstab.</p>
<pre>//<span style="color: #ff0000;">192.168.1.12<span style="color: #ff00ff;">/mnt/truenas</span></span> <span style="color: #00ccff;">/mnt/truenas/</span> cifs credentials=<span style="color: #00ff00;">/etc/.truenas_creds</span>,iocharset=utf8,uid=1000,gid=1000,noperm 0 0
</pre>
<p>My TrueNAS server&#8217;s IP =&gt; <span style="color: #ff0000;">192.168.1.12</span></p>
<p>Remote samba share =&gt; <span style="color: #ff00ff;">/mnt/truenas</span></p>
<p>Local mount location =&gt; <span style="color: #00ccff;">/mnt/truenas/</span></p>
<p>Credentials for samba share =&gt; <span style="color: #00ff00;">/etc/.truenas_creds</span></p>
<p>-Once complete, run the following to mount all entries looking at /etc/fstab.</p>
<pre>mount -a</pre>
<p>-If there are no errors in the above command, check your local mount path to verify that the mount was successful.</p>
<pre>ls -l /mnt/truenas/</pre>
<p><strong>References:</strong></p>
<p><a href="https://linuxize.com/post/how-to-mount-cifs-windows-share-on-linux/">linuxize</a></p>
<p><a href="https://askubuntu.com/questions/295302/permissions-of-mounted-cifs-share-shared-from-freenas">Askubuntu</a></p>
<p>The post <a href="https://techantidote.com/mount-truenas-core-samba-share-on-linux/">Mount TrueNAS Core Samba share on Linux</a> appeared first on <a href="https://techantidote.com">Tech Antidote</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techantidote.com/mount-truenas-core-samba-share-on-linux/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3183</post-id>	</item>
		<item>
		<title>Bash script to loop through values in a file with space as a separator</title>
		<link>https://techantidote.com/bash-script-to-loop-through-values-in-a-file-with-space-as-a-separator/</link>
					<comments>https://techantidote.com/bash-script-to-loop-through-values-in-a-file-with-space-as-a-separator/#comments</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Wed, 06 May 2020 17:00:18 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[bash script]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[IFS]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[ping]]></category>
		<category><![CDATA[whitespace]]></category>
		<guid isPermaLink="false">https://techantidote.com/?p=3138</guid>

					<description><![CDATA[<p>Lets say we have a file with list of IPs that are space separated and you want to read each of the values to pass to a loop to perform an operation. Here is an example file with IP Addresses separated  by a space: cat ips.txt 192.168.1.1 192.168.1.10 Now, lets say you want to loop &#8230; <a href="https://techantidote.com/bash-script-to-loop-through-values-in-a-file-with-space-as-a-separator/" class="more-link">Continue reading <span class="screen-reader-text">Bash script to loop through values in a file with space as a separator</span> <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://techantidote.com/bash-script-to-loop-through-values-in-a-file-with-space-as-a-separator/">Bash script to loop through values in a file with space as a separator</a> appeared first on <a href="https://techantidote.com">Tech Antidote</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Lets say we have a file with list of IPs that are space separated and you want to read each of the values to pass to a loop to perform an operation. Here is an example file with IP Addresses separated  by a space:</p>
<pre><strong>cat ips.txt</strong>
192.168.1.1 192.168.1.10</pre>
<p>Now, lets say you want to loop through these IPs and run a ping command against each of them.</p>
<pre><strong>cat ping.sh</strong>
#!/bin/bash

# IFS is an internal bash variable. Here, we set its value as space.
<span style="color: #ff0000;"><strong>IFS=$" "</strong></span>
# Read the file "ips.txt" and store the list of values to a variable "ips"
<span style="color: #ff0000;">ips="$(cat ips.txt)"</span>

# Run the following loop which will loop through each of the ips and run a ping test
<span style="color: #ff0000;">for ip in $ips; do ping -c 1 $ip; done</span>
# Unset the IFS variable so that it wont mess with the reset of the script
unset IFS</pre>
<p>-Running this loop, will loop through the list of IP addresses and perform a ping.</p>
<pre><strong>./ping.sh</strong>
<span style="color: #ff0000;"><strong>PING</strong> <strong>192.168.1.1</strong> </span>(192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.660 ms

--- 192.168.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.660/0.660/0.660/0.000 ms
<span style="color: #ff0000;"><strong>PING</strong> <strong>192.168.1.10</strong> </span>(192.168.1.10) 56(84) bytes of data.
64 bytes from 192.168.1.10: icmp_seq=1 ttl=64 time=0.108 ms

--- 192.168.1.10 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.108/0.108/0.108/0.000 ms</pre>
<p>Hope this helps!</p>
<p>Happy scripting folks! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>Source/References: <a href="http://mindspill.net/computing/linux-notes/using-the-bash-ifs-variable-to-make-for-loops-split-with-non-whitespace-characters/">Link</a></p>
<p>The post <a href="https://techantidote.com/bash-script-to-loop-through-values-in-a-file-with-space-as-a-separator/">Bash script to loop through values in a file with space as a separator</a> appeared first on <a href="https://techantidote.com">Tech Antidote</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techantidote.com/bash-script-to-loop-through-values-in-a-file-with-space-as-a-separator/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3138</post-id>	</item>
		<item>
		<title>Run bash script from a Perl script</title>
		<link>https://techantidote.com/run-bash-script-from-a-perl-script/</link>
					<comments>https://techantidote.com/run-bash-script-from-a-perl-script/#respond</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Sat, 28 Dec 2019 10:27:54 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[bash script]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[run]]></category>
		<guid isPermaLink="false">https://techantidote.com/?p=3088</guid>

					<description><![CDATA[<p>To run a bash script (Example: bash-script.sh) from inside a perl script, you could use the following syntax: system("sh", "bash-script.sh") Note: Here, once the bash script completes execution it will continue with the execution of the perl script. Example: Perl Script: perl-script.pl Bash Script: bash-script.sh Below is a perl script  &#8220;perl-script.pl&#8221; which calls an external &#8230; <a href="https://techantidote.com/run-bash-script-from-a-perl-script/" class="more-link">Continue reading <span class="screen-reader-text">Run bash script from a Perl script</span> <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://techantidote.com/run-bash-script-from-a-perl-script/">Run bash script from a Perl script</a> appeared first on <a href="https://techantidote.com">Tech Antidote</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>To run a bash script (Example: <em>bash-script.sh)</em> from inside a perl script, you could use the following syntax:</p>
<pre>system("sh", "bash-script.sh")
</pre>
<p><strong>Note</strong>: Here, once the bash script completes execution it will continue with the execution of the perl script.</p>
<p><span style="text-decoration: underline; color: #808080;"><strong>Example:</strong></span></p>
<p><strong><span style="color: #3366ff;">Perl Script</span>:</strong> perl-script.pl<br />
<strong><span style="color: #3366ff;">Bash Script</span>:</strong> bash-script.sh</p>
<p>Below is a perl script  &#8220;perl-script.pl&#8221; which calls an external bash script &#8220;bash-script.sh&#8221;.</p>
<pre>#!/usr/bin/perl
use strict;
use warnings;

print "Running parent perl script. \n";
print "Starting to call external bash script\n";

# Sample Argument to be passed to the bash script
my $my_arg = "ARG1";

# With arguments - pass them inside quotes seperated by commas 
<span style="color: #ff0000;">system("sh", "bash-script.sh","$my_arg");</span>

print "Back to parent perl script\n";
</pre>
<p>Below is the sample &#8220;bash-script.sh&#8221; which prints the variable.</p>
<pre>#!/bin/bash
echo "---Start of Bash script---"

a=$1
echo "Argument from Perl script is" $a
</pre>
<p>To test, execute the perl script:</p>
<pre>./perl-script.pl</pre>
<p>&nbsp;</p>
<p><strong>Credits/References</strong><br />
https://stackoverflow.com/questions/3200801/how-can-i-call-a-shell-command-in-my-perl-script</p>
<p>The post <a href="https://techantidote.com/run-bash-script-from-a-perl-script/">Run bash script from a Perl script</a> appeared first on <a href="https://techantidote.com">Tech Antidote</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techantidote.com/run-bash-script-from-a-perl-script/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3088</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Minified using Disk

Served from: techantidote.com @ 2026-10-23 13:15:24 by W3 Total Cache
-->