<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<title>My Blog</title>
	<subtitle>My blog site.</subtitle>
	<link rel="self" type="application/atom+xml" href="https://ashraddhansh.github.io/posts/feed.xml"/>
  <link rel="alternate" type="text/html" href="https://ashraddhansh.github.io/posts/"/>
  
	<updated>2026-06-05T00:00:00+00:00</updated>
	
	<id>https://ashraddhansh.github.io/posts/feed.xml</id>
	<entry xml:lang="en">
		<title>SSH Getting Started</title>
		<published>2026-06-05T00:00:00+00:00</published>
		<updated>2026-06-05T00:00:00+00:00</updated>
		<link rel="alternate" type="text/html" href="https://ashraddhansh.github.io/posts/ssh-getting-started/"/>
		<id>https://ashraddhansh.github.io/posts/ssh-getting-started/</id>
    
		<content type="html" xml:base="https://ashraddhansh.github.io/posts/ssh-getting-started/">&lt;p&gt;First, install OpenSSH on both the server and the client:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; pacman&lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt; -&lt;&#x2F;span&gt;S&lt;&#x2F;span&gt; openssh&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ul&gt;
&lt;li&gt;Enable the SSH service on both machines using the following command. Enabling &lt;code&gt;sshd&lt;&#x2F;code&gt; on the client is not necessary unless you want the client to accept incoming SSH connections.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; systemctl enable&lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt; --&lt;&#x2F;span&gt;now&lt;&#x2F;span&gt; sshd.service&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ul&gt;
&lt;li&gt;Generate an SSH key pair on the client:&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;ssh-keygen&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ul&gt;
&lt;li&gt;Copy the public key to the server. You will be prompted for the password of the user account you are connecting to.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;ssh-copy-id&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-redirection z-shell&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;username&lt;span class=&quot;z-keyword z-operator z-assignment z-redirection z-shell&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;@&lt;span class=&quot;z-keyword z-operator z-assignment z-redirection z-shell&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;remote_host&lt;span class=&quot;z-keyword z-operator z-assignment z-redirection z-shell&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ul&gt;
&lt;li&gt;Connect to the server:&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;ssh&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-redirection z-shell&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;username&lt;span class=&quot;z-keyword z-operator z-assignment z-redirection z-shell&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;@&lt;span class=&quot;z-keyword z-operator z-assignment z-redirection z-shell&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;remote_host&lt;span class=&quot;z-keyword z-operator z-assignment z-redirection z-shell&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</content>
	</entry>
	<entry xml:lang="en">
		<title>On Typst</title>
		<published>2026-05-24T00:00:00+00:00</published>
		<updated>2026-05-24T00:00:00+00:00</updated>
		<link rel="alternate" type="text/html" href="https://ashraddhansh.github.io/posts/on-typst/"/>
		<id>https://ashraddhansh.github.io/posts/on-typst/</id>
    
		<content type="html" xml:base="https://ashraddhansh.github.io/posts/on-typst/">&lt;p&gt;Around more than a year ago, I had to submit my lab practical files. In my university, they are submitted as physical prints. Since I needed to produce PDFs, I did what a normal person would obviously do: I opened a GUI text editor, LibreOffice Writer because I use Linux (Arch BTW). And it was a horrible experience trying to type and format text that had a lot of code in it.&lt;&#x2F;p&gt;
&lt;p&gt;I am not saying LibreOffice is a bad tool; it&#x27;s actually a fantastic open-source project that offers a pretty close experience to MS Word in a Linux environment. A few reasons listed below made my experience not so good:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;I had to use the mouse a lot (I knew shortcuts, but I was a newbie to LibreOffice)&lt;&#x2F;li&gt;
&lt;li&gt;To keep the document consistent, I had to put in a lot of manual effort&lt;&#x2F;li&gt;
&lt;li&gt;There is no good way to insert raw code without breaking its formatting&lt;&#x2F;li&gt;
&lt;li&gt;Lack of Vim motions (I know I am asking too much, but yeah, it&#x27;s a nice-to-have feature and makes text editing much faster)&lt;&#x2F;li&gt;
&lt;li&gt;Images are horrible to deal with&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;I have a gripe with GUI tools: usually there is no single way of doing things. Since no explicit training is required to use GUI tools, users often end up using less-recommended methods, like inserting a lot of line breaks instead of using page breaks.&lt;&#x2F;p&gt;
&lt;p&gt;Somehow I managed to format the files and submit them. But I was still searching for a tool that fit my needs. Around that time I was introduced to LaTeX through Luke Smith&#x27;s YouTube channel. And man, I was so blown away seeing a program where I could edit text using Neovim, use custom automation, format raw code with syntax highlighting, and even draw diagrams and graphs using code.&lt;&#x2F;p&gt;
&lt;p&gt;So I installed and set up LaTeX with Neovim and Zathura. After playing around with it for some time, it wasn&#x27;t as intuitive as I initially thought. Here are some problems I encountered while using LaTeX:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;The package system is a mess. I even considered using a Docker container to isolate the packages instead of bloating my main system.&lt;&#x2F;li&gt;
&lt;li&gt;LaTeX lacks a good set of defaults. Yeah, it&#x27;s highly customizable, but customizing everything takes time.&lt;&#x2F;li&gt;
&lt;li&gt;The syntax is too... how do I say it... too descriptive. For example, using &lt;code&gt;\section{}&lt;&#x2F;code&gt; for a level-1 heading. I think it&#x27;s because of Donald Knuth&#x27;s &lt;a rel=&quot;nofollow noreferrer&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Literate_programming&quot;&gt;Literate Programming&lt;&#x2F;a&gt; philosophy.&lt;&#x2F;li&gt;
&lt;li&gt;Compilation is noticeably slow, and so is the preview.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Seasoned LaTeX users may argue that you encounter these problems when using LaTeX for cases it wasn&#x27;t really intended for. Maybe they are right.&lt;&#x2F;p&gt;
&lt;p&gt;I needed a program that could replace GUI word processors for me. I needed something that I could use to quickly write things down and compile a decently formatted PDF.&lt;&#x2F;p&gt;
&lt;p&gt;So the search went on, and then I found Typst (I don&#x27;t remember where). I installed and set up Typst in Neovim with the &lt;code&gt;typst-preview.nvim&lt;&#x2F;code&gt; plugin.&lt;&#x2F;p&gt;
&lt;p&gt;The first thing I noticed was how fast the preview was. After playing around with Typst for a little while, I realized it offered pretty much everything I wanted:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Fast preview&lt;&#x2F;li&gt;
&lt;li&gt;Markdown-like syntax&lt;&#x2F;li&gt;
&lt;li&gt;Good defaults (for example, default fonts that remain readable when printed on modern printers)&lt;&#x2F;li&gt;
&lt;li&gt;Vim support&lt;&#x2F;li&gt;
&lt;li&gt;Easy yet powerful scripting&lt;&#x2F;li&gt;
&lt;li&gt;Ability to use fonts installed on my system&lt;&#x2F;li&gt;
&lt;li&gt;Default auto-pairing of inverted commas (I don&#x27;t know why this isn&#x27;t default in LaTeX, or at least why there isn&#x27;t a flag or config option to enable it)&lt;&#x2F;li&gt;
&lt;li&gt;Built-in basic features that required external packages in LaTeX&lt;&#x2F;li&gt;
&lt;li&gt;Consistent formatting with pretty much no manual effort&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;I used Typst to typeset lab files, generate bulk documents, write letters, create resumes, reports, casual lists, etc., and Typst never seemed incapable.&lt;&#x2F;p&gt;
&lt;p&gt;It&#x27;s been about a year now, and I never looked for an alternative. It may not be as powerful or customizable as LaTeX, but for me it was the LibreOffice Writer&#x2F;Word replacement I was looking for. I even managed to get my friends to use Typst, and now they hate using GUI-based text editors.&lt;&#x2F;p&gt;
&lt;p&gt;If anyone is reading this article, consider this the sign you may or may not have been looking for to try Typst.&lt;&#x2F;p&gt;
</content>
	</entry>
	<entry xml:lang="en">
		<title>Install Apache Hadoop in Archlinux</title>
		<published>2026-02-28T00:00:00+00:00</published>
		<updated>2026-02-28T00:00:00+00:00</updated>
		<link rel="alternate" type="text/html" href="https://ashraddhansh.github.io/posts/install-hadoop-in-archlinux/"/>
		<id>https://ashraddhansh.github.io/posts/install-hadoop-in-archlinux/</id>
    
		<content type="html" xml:base="https://ashraddhansh.github.io/posts/install-hadoop-in-archlinux/">&lt;h1 id=&quot;download-java-version&quot;&gt;Download Java Version&lt;a class=&quot;zola-anchor&quot; href=&quot;#download-java-version&quot; aria-label=&quot;Anchor link for: download-java-version&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;For the hadoop version we are going to install, that will need java11 so first we need to install and set that to default.&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;sudo pacman -S jdk11-opnjdk
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;sudo archlinux-java set jdk11-opnjdk
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;download-the-hadoop-binary&quot;&gt;Download the Hadoop Binary&lt;a class=&quot;zola-anchor&quot; href=&quot;#download-the-hadoop-binary&quot; aria-label=&quot;Anchor link for: download-the-hadoop-binary&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;First download the latest hadoop binary. I am using &lt;code&gt;curl&lt;&#x2F;code&gt; but you can use browser to download from this url &lt;a rel=&quot;nofollow noreferrer&quot; href=&quot;https:&#x2F;&#x2F;downloads.apache.org&#x2F;hadoop&#x2F;common&#x2F;&quot;&gt;Index of &#x2F;hadoop&#x2F;common&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;curl -O https:&#x2F;&#x2F;downloads.apache.org&#x2F;hadoop&#x2F;common&#x2F;hadoop-3.4.3&#x2F;hadoop-3.4.3.tar.gz
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;After downloading the compressed binary we have to extract it&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;tar -xf hadoop-3.4.3.tar.gz
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Now we will move the hadoop directory to the &lt;code&gt;&#x2F;opt&lt;&#x2F;code&gt; directory&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;sudo mv hadoop-3.4.3 &#x2F;opt&#x2F;hadoop
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;set-ownership&quot;&gt;Set Ownership&lt;a class=&quot;zola-anchor&quot; href=&quot;#set-ownership&quot; aria-label=&quot;Anchor link for: set-ownership&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;sudo chown -R $USER:$(id -gn) &#x2F;opt&#x2F;hadoop
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;set-environment-variables&quot;&gt;Set Environment Variables&lt;a class=&quot;zola-anchor&quot; href=&quot;#set-environment-variables&quot; aria-label=&quot;Anchor link for: set-environment-variables&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;Let&#x27;s set some environment variables.
In your dafault shell&#x27;s configuration file &lt;code&gt;.bashrc&lt;&#x2F;code&gt; or &lt;code&gt;.zshrc&lt;&#x2F;code&gt; set these environment variables.&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;export HADOOP_HOME=&#x2F;opt&#x2F;hadoop
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;export HADOOP_CONF_DIR=$HADOOP_HOME&#x2F;etc&#x2F;hadoop
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;export JAVA_HOME=&#x2F;usr&#x2F;lib&#x2F;jvm&#x2F;default
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;export PATH=$PATH:$HADOOP_HOME&#x2F;bin:$HADOOP_HOME&#x2F;sbin
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;To apply these changes open new terminal or run&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;source ~&#x2F;.bashrc
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;verify-installation&quot;&gt;Verify Installation&lt;a class=&quot;zola-anchor&quot; href=&quot;#verify-installation&quot; aria-label=&quot;Anchor link for: verify-installation&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;hadoop version
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This will return the hadoop version and other information.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;configuring-hadoop-pseudo-distributed-mode&quot;&gt;Configuring Hadoop(Pseudo-Distributed Mode)&lt;a class=&quot;zola-anchor&quot; href=&quot;#configuring-hadoop-pseudo-distributed-mode&quot; aria-label=&quot;Anchor link for: configuring-hadoop-pseudo-distributed-mode&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;First change directory to&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;cd &#x2F;opt&#x2F;hadoop&#x2F;etc&#x2F;hadoop
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Edit the &lt;code&gt;core-site.xml&lt;&#x2F;code&gt; file. Inside &lt;code&gt;&amp;lt;configuration&amp;gt;&lt;&#x2F;code&gt; tag add:&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;lt;property&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;name&amp;gt;fs.defaultFS&amp;lt;&#x2F;name&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;value&amp;gt;hdfs:&#x2F;&#x2F;localhost:9000&amp;lt;&#x2F;value&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;lt;&#x2F;property&amp;gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Now edit the &lt;code&gt;hdfs-site.xml&lt;&#x2F;code&gt;. Inside &lt;code&gt;&amp;lt;configuration&amp;gt;&lt;&#x2F;code&gt; tag add:&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;lt;property&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;name&amp;gt;dfs.replication&amp;lt;&#x2F;name&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;value&amp;gt;1&amp;lt;&#x2F;value&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;lt;&#x2F;property&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;lt;property&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;name&amp;gt;dfs.namenode.name.dir&amp;lt;&#x2F;name&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;value&amp;gt;file:&#x2F;&#x2F;&#x2F;opt&#x2F;hadoop&#x2F;hdfs&#x2F;namenode&amp;lt;&#x2F;value&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;lt;&#x2F;property&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;lt;property&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;name&amp;gt;dfs.datanode.data.dir&amp;lt;&#x2F;name&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;value&amp;gt;file:&#x2F;&#x2F;&#x2F;opt&#x2F;hadoop&#x2F;hdfs&#x2F;datanode&amp;lt;&#x2F;value&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;lt;&#x2F;property&amp;gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Similarily in &lt;code&gt;mapred-site.xml&lt;&#x2F;code&gt;, inside &lt;code&gt;&amp;lt;configuration&amp;gt;&lt;&#x2F;code&gt; tag add:&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;lt;property&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;name&amp;gt;mapreduce.framework.name&amp;lt;&#x2F;name&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;value&amp;gt;yarn&amp;lt;&#x2F;value&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;lt;&#x2F;property&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;lt;property&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;name&amp;gt;yarn.app.mapreduce.am.env&amp;lt;&#x2F;name&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;value&amp;gt;HADOOP_MAPRED_HOME=&#x2F;opt&#x2F;hadoop&amp;lt;&#x2F;value&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;lt;&#x2F;property&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;lt;property&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;name&amp;gt;mapreduce.map.env&amp;lt;&#x2F;name&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;value&amp;gt;HADOOP_MAPRED_HOME=&#x2F;opt&#x2F;hadoop&amp;lt;&#x2F;value&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;lt;&#x2F;property&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;lt;property&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;name&amp;gt;mapreduce.reduce.env&amp;lt;&#x2F;name&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;value&amp;gt;HADOOP_MAPRED_HOME=&#x2F;opt&#x2F;hadoop&amp;lt;&#x2F;value&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;lt;&#x2F;property&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;lt;property&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;name&amp;gt;mapreduce.application.classpath&amp;lt;&#x2F;name&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;value&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;    $HADOOP_MAPRED_HOME&#x2F;share&#x2F;hadoop&#x2F;mapreduce&#x2F;*,
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;    $HADOOP_MAPRED_HOME&#x2F;share&#x2F;hadoop&#x2F;mapreduce&#x2F;lib&#x2F;*,
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;    $HADOOP_MAPRED_HOME&#x2F;share&#x2F;hadoop&#x2F;common&#x2F;*,
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;    $HADOOP_MAPRED_HOME&#x2F;share&#x2F;hadoop&#x2F;common&#x2F;lib&#x2F;*,
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;    $HADOOP_MAPRED_HOME&#x2F;share&#x2F;hadoop&#x2F;yarn&#x2F;*,
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;    $HADOOP_MAPRED_HOME&#x2F;share&#x2F;hadoop&#x2F;yarn&#x2F;lib&#x2F;*
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;&#x2F;value&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;lt;&#x2F;property&amp;gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;And now in &lt;code&gt;yarn-site.xml&lt;&#x2F;code&gt; add:&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;lt;property&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;name&amp;gt;yarn.nodemanager.aux-services&amp;lt;&#x2F;name&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;value&amp;gt;mapreduce_shuffle&amp;lt;&#x2F;value&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;lt;&#x2F;property&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;lt;property&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;name&amp;gt;yarn.nodemanager.env-whitelist&amp;lt;&#x2F;name&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;value&amp;gt;JAVA_HOME,HADOOP_HOME,HADOOP_MAPRED_HOME&amp;lt;&#x2F;value&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;lt;&#x2F;property&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;lt;property&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;name&amp;gt;yarn.application.classpath&amp;lt;&#x2F;name&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;value&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;    &#x2F;opt&#x2F;hadoop&#x2F;share&#x2F;hadoop&#x2F;common&#x2F;*,
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;    &#x2F;opt&#x2F;hadoop&#x2F;share&#x2F;hadoop&#x2F;common&#x2F;lib&#x2F;*,
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;    &#x2F;opt&#x2F;hadoop&#x2F;share&#x2F;hadoop&#x2F;hdfs&#x2F;*,
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;    &#x2F;opt&#x2F;hadoop&#x2F;share&#x2F;hadoop&#x2F;hdfs&#x2F;lib&#x2F;*,
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;    &#x2F;opt&#x2F;hadoop&#x2F;share&#x2F;hadoop&#x2F;mapreduce&#x2F;*,
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;    &#x2F;opt&#x2F;hadoop&#x2F;share&#x2F;hadoop&#x2F;mapreduce&#x2F;lib&#x2F;*,
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;    &#x2F;opt&#x2F;hadoop&#x2F;share&#x2F;hadoop&#x2F;yarn&#x2F;*,
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;    &#x2F;opt&#x2F;hadoop&#x2F;share&#x2F;hadoop&#x2F;yarn&#x2F;lib&#x2F;*
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;  &amp;lt;&#x2F;value&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;lt;&#x2F;property&amp;gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;configuring-ssh&quot;&gt;Configuring SSH&lt;a class=&quot;zola-anchor&quot; href=&quot;#configuring-ssh&quot; aria-label=&quot;Anchor link for: configuring-ssh&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;To acces the hadoop we need to configue the SSH. First install the SSH if not installed already:&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;sudo pacman -S openssh
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Enable and start the SSH service:&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;sudo systemctl enable sshd
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;sudo systemctl start sshd
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Generate SSH Keys:&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;ssh-keygen -t rsa -P &amp;quot;&amp;quot;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;cat ~&#x2F;.ssh&#x2F;id_rsa.pub &amp;gt;&amp;gt; ~&#x2F;.ssh&#x2F;authorized_keys
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;chmod 600 ~&#x2F;.ssh&#x2F;authorized_keys
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;install-inetutils&quot;&gt;Install &lt;code&gt;inetutils&lt;&#x2F;code&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#install-inetutils&quot; aria-label=&quot;Anchor link for: install-inetutils&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;&lt;code&gt;hostname&lt;&#x2F;code&gt; is a dependency and is provided by this utility:&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;sudo pacman -S inetutils
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;set-java-home&quot;&gt;Set JAVA_HOME&lt;a class=&quot;zola-anchor&quot; href=&quot;#set-java-home&quot; aria-label=&quot;Anchor link for: set-java-home&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;Edit &lt;code&gt;&#x2F;opt&#x2F;hadoop&#x2F;etc&#x2F;hadoop&#x2F;hadoop-env.sh&lt;&#x2F;code&gt; file. Find the line:&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;# export JAVA_HOME=
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Uncomment the line and set:&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;export JAVA_HOME=&#x2F;usr&#x2F;lib&#x2F;jvm&#x2F;java-11-openjdk
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;test-the-ssh-setup&quot;&gt;Test the SSH Setup&lt;a class=&quot;zola-anchor&quot; href=&quot;#test-the-ssh-setup&quot; aria-label=&quot;Anchor link for: test-the-ssh-setup&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;ssh localhost
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;You will be connected to the new shell. Run the below command in that shell.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;format-the-hdfs&quot;&gt;Format the HDFS&lt;a class=&quot;zola-anchor&quot; href=&quot;#format-the-hdfs&quot; aria-label=&quot;Anchor link for: format-the-hdfs&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;hdfs namenode -format
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;start-hadoop-services&quot;&gt;Start Hadoop Services&lt;a class=&quot;zola-anchor&quot; href=&quot;#start-hadoop-services&quot; aria-label=&quot;Anchor link for: start-hadoop-services&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;start-dfs.sh
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;start-yarn.sh
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Check the running daemons:&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;jps
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;You should see something like:&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;481619 NodeManager
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;480751 NameNode
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;480942 DataNode
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;573619 Jps
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;481497 ResourceManager
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;481193 SecondaryNameNode
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;access-web-interfaces&quot;&gt;Access Web Interfaces&lt;a class=&quot;zola-anchor&quot; href=&quot;#access-web-interfaces&quot; aria-label=&quot;Anchor link for: access-web-interfaces&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Service&lt;&#x2F;th&gt;&lt;th&gt;URL&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;NameNode&lt;&#x2F;td&gt;&lt;td&gt;&lt;a rel=&quot;nofollow noreferrer&quot; href=&quot;http:&#x2F;&#x2F;localhost:9870&quot;&gt;http:&#x2F;&#x2F;localhost:9870&lt;&#x2F;a&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;ResourceManager&lt;&#x2F;td&gt;&lt;td&gt;&lt;a rel=&quot;nofollow noreferrer&quot; href=&quot;http:&#x2F;&#x2F;localhost:8088&quot;&gt;http:&#x2F;&#x2F;localhost:8088&lt;&#x2F;a&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
</content>
	</entry>
	<entry xml:lang="en">
		<title>Tmux</title>
		<published>2025-05-07T00:00:00+00:00</published>
		<updated>2025-05-07T00:00:00+00:00</updated>
		<link rel="alternate" type="text/html" href="https://ashraddhansh.github.io/posts/tmux/"/>
		<id>https://ashraddhansh.github.io/posts/tmux/</id>
    
		<content type="html" xml:base="https://ashraddhansh.github.io/posts/tmux/">&lt;p&gt;&lt;strong&gt;tmux is a terminal multiplexer tool&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;installation&quot;&gt;Installation&lt;a class=&quot;zola-anchor&quot; href=&quot;#installation&quot; aria-label=&quot;Anchor link for: installation&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; pacman&lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt; -&lt;&#x2F;span&gt;S&lt;&#x2F;span&gt; tmux&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;launch&quot;&gt;Launch&lt;a class=&quot;zola-anchor&quot; href=&quot;#launch&quot; aria-label=&quot;Anchor link for: launch&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;tmux&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;this will open a new tmux window with a footer at bottom.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;detaching-from-tmux-session&quot;&gt;Detaching from tmux Session&lt;a class=&quot;zola-anchor&quot; href=&quot;#detaching-from-tmux-session&quot; aria-label=&quot;Anchor link for: detaching-from-tmux-session&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;Press CTRL+B to enter tmux command mode then  press  &#x27;d&#x27; to detach from that window and back to normal terminal.&lt;&#x2F;p&gt;
&lt;p&gt;By using this we can run multiple processes at once.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;going-back-to-most-recent-session&quot;&gt;Going back to Most Recent Session&lt;a class=&quot;zola-anchor&quot; href=&quot;#going-back-to-most-recent-session&quot; aria-label=&quot;Anchor link for: going-back-to-most-recent-session&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;tmux&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; attach&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;list-all-running-sessions&quot;&gt;List all running Sessions&lt;a class=&quot;zola-anchor&quot; href=&quot;#list-all-running-sessions&quot; aria-label=&quot;Anchor link for: list-all-running-sessions&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;tmux&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; list-sessions&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;or&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;tmux&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; ls&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;exiting&quot;&gt;Exiting&lt;a class=&quot;zola-anchor&quot; href=&quot;#exiting&quot; aria-label=&quot;Anchor link for: exiting&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;type exit on that session to exit from that&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-exit z-shell&quot;&gt;exit&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;or
Go to command mode then press x then press y.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;detaching-from-tmux-session-1&quot;&gt;Detaching from tmux Session&lt;a class=&quot;zola-anchor&quot; href=&quot;#detaching-from-tmux-session-1&quot; aria-label=&quot;Anchor link for: detaching-from-tmux-session-1&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;go to command mode and then press D to detach from the session.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;vertically-split-tmux-panes&quot;&gt;Vertically Split tmux Panes&lt;a class=&quot;zola-anchor&quot; href=&quot;#vertically-split-tmux-panes&quot; aria-label=&quot;Anchor link for: vertically-split-tmux-panes&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;Go to command mode by pressing CTRL+B then press &lt;code&gt;%&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h1 id=&quot;horizontally-split-tmux-panes&quot;&gt;Horizontally Split tmux Panes&lt;a class=&quot;zola-anchor&quot; href=&quot;#horizontally-split-tmux-panes&quot; aria-label=&quot;Anchor link for: horizontally-split-tmux-panes&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;Go to command mode by pressing CTRL+B then  press &lt;code&gt;&quot;&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h1 id=&quot;change-focus-between-multiple-tmux-panes&quot;&gt;Change Focus Between Multiple tmux Panes&lt;a class=&quot;zola-anchor&quot; href=&quot;#change-focus-between-multiple-tmux-panes&quot; aria-label=&quot;Anchor link for: change-focus-between-multiple-tmux-panes&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;Press left, right, top, bottom arrow keys to move focus to left, right, top and bottom panes respectively.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;images&#x2F;tmux.png&quot; alt=&quot;image&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;create-a-new-window-in-tmux&quot;&gt;Create a New Window in tmux&lt;a class=&quot;zola-anchor&quot; href=&quot;#create-a-new-window-in-tmux&quot; aria-label=&quot;Anchor link for: create-a-new-window-in-tmux&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;tmux&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; new-window&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;or
Press leader key then &lt;code&gt;c&lt;&#x2F;code&gt;  to create a new window.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;navigation-between-windows&quot;&gt;Navigation Between Windows&lt;a class=&quot;zola-anchor&quot; href=&quot;#navigation-between-windows&quot; aria-label=&quot;Anchor link for: navigation-between-windows&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;Press &lt;code&gt;n&lt;&#x2F;code&gt;  or &lt;code&gt;p&lt;&#x2F;code&gt;  followed by leader key to navigate to next and previous window.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;killing-a-tmux-window&quot;&gt;Killing a Tmux Window&lt;a class=&quot;zola-anchor&quot; href=&quot;#killing-a-tmux-window&quot; aria-label=&quot;Anchor link for: killing-a-tmux-window&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;Press &lt;code&gt;&amp;amp;&lt;&#x2F;code&gt;  followed by leader key to kill the active window.
Or&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;tmux&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; kill-window&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;in that window you want to kill.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;renaming-tmux-window&quot;&gt;Renaming Tmux Window&lt;a class=&quot;zola-anchor&quot; href=&quot;#renaming-tmux-window&quot; aria-label=&quot;Anchor link for: renaming-tmux-window&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;Press &lt;code&gt;,&lt;&#x2F;code&gt;  followed by leader key to rename a window.
Or&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;tmux&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; rename-window &lt;span class=&quot;z-string z-quoted z-single z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;new name&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;renaming-session&quot;&gt;Renaming Session&lt;a class=&quot;zola-anchor&quot; href=&quot;#renaming-session&quot; aria-label=&quot;Anchor link for: renaming-session&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;Press &lt;code&gt;$&lt;&#x2F;code&gt; followed by leader key to rename a session.&lt;&#x2F;p&gt;
</content>
	</entry>
	<entry xml:lang="en">
		<title>File Types in Unix Based OSs</title>
		<published>2025-05-05T00:00:00+00:00</published>
		<updated>2025-05-05T00:00:00+00:00</updated>
		<link rel="alternate" type="text/html" href="https://ashraddhansh.github.io/posts/file-types-in-unix-based-os/"/>
		<id>https://ashraddhansh.github.io/posts/file-types-in-unix-based-os/</id>
    
		<content type="html" xml:base="https://ashraddhansh.github.io/posts/file-types-in-unix-based-os/">&lt;p&gt;There are 7 types of files in a UNIX like environment:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Regular File&lt;&#x2F;li&gt;
&lt;li&gt;Directories&lt;&#x2F;li&gt;
&lt;li&gt;Character device files&lt;&#x2F;li&gt;
&lt;li&gt;Block device files&lt;&#x2F;li&gt;
&lt;li&gt;Local domain sockets&lt;&#x2F;li&gt;
&lt;li&gt;Named pipes(FIFOs)&lt;&#x2F;li&gt;
&lt;li&gt;Symbolic links&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;h1 id=&quot;determining-file-types-using-ls&quot;&gt;Determining File Types using &lt;code&gt;ls&lt;&#x2F;code&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#determining-file-types-using-ls&quot; aria-label=&quot;Anchor link for: determining-file-types-using-ls&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;You can determine the file type of an existing file with &lt;code&gt;ls -ld&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;The flag &lt;code&gt;-l&lt;&#x2F;code&gt; displays detailed information about the file or directory like permission, number of links, owner, group, size etc.&lt;&#x2F;li&gt;
&lt;li&gt;Flag &lt;code&gt;-d&lt;&#x2F;code&gt; prevents ls from listing the content of directories, instead it shows the information about the directory itself. For example:&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; ls&lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt; -&lt;&#x2F;span&gt;l&lt;&#x2F;span&gt; &#x2F;usr&#x2F;man&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;total&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; 12&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;drwxr-xr-x&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; 2 root root 4096 Apr 10 16:42 man1&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;drwxr-xr-x&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; 2 root root 4096 Apr 10 16:42 man3&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;drwxr-xr-x&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; 2 root root 4096 Apr 10 16:42 man7&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; ls&lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt; -&lt;&#x2F;span&gt;ld&lt;&#x2F;span&gt; &#x2F;usr&#x2F;man&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;drwxr-xr-x&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; 5 root root 4096 Apr 10 16:42 &#x2F;usr&#x2F;man&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;file-type-encoding-used-by-ls&quot;&gt;File Type encoding Used by &lt;code&gt;ls&lt;&#x2F;code&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#file-type-encoding-used-by-ls&quot; aria-label=&quot;Anchor link for: file-type-encoding-used-by-ls&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;&lt;strong&gt;File Type&lt;&#x2F;strong&gt;&lt;&#x2F;th&gt;&lt;th&gt;&lt;strong&gt;Symbol&lt;&#x2F;strong&gt;&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;Regular file&lt;&#x2F;td&gt;&lt;td&gt;-&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Directory&lt;&#x2F;td&gt;&lt;td&gt;d&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Character device file&lt;&#x2F;td&gt;&lt;td&gt;c&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Block device file&lt;&#x2F;td&gt;&lt;td&gt;b&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Local domain socket&lt;&#x2F;td&gt;&lt;td&gt;s&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Name pipe&lt;&#x2F;td&gt;&lt;td&gt;p&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Symbolic link&lt;&#x2F;td&gt;&lt;td&gt;l&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;h1 id=&quot;regular-files&quot;&gt;Regular Files&lt;a class=&quot;zola-anchor&quot; href=&quot;#regular-files&quot; aria-label=&quot;Anchor link for: regular-files&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;Regular files consist of a series of bytes.&lt;&#x2F;li&gt;
&lt;li&gt;The filesystems impose no structure on their contents.&lt;&#x2F;li&gt;
&lt;li&gt;Both sequential and random access is allowed.&lt;&#x2F;li&gt;
&lt;li&gt;Example: Text files, data files, executable programs and shared libraries.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h1 id=&quot;directories&quot;&gt;Directories&lt;a class=&quot;zola-anchor&quot; href=&quot;#directories&quot; aria-label=&quot;Anchor link for: directories&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;A directory contains named references to other files.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;mkdir&lt;&#x2F;code&gt; and &lt;code&gt;rmdir&lt;&#x2F;code&gt; is used to create and delete directories respectively.&lt;&#x2F;li&gt;
&lt;li&gt;The special entries &lt;code&gt;.&lt;&#x2F;code&gt; and &lt;code&gt;..&lt;&#x2F;code&gt; refer to the directory itself and its parent directory.&lt;&#x2F;li&gt;
&lt;li&gt;A file&#x27;s name is stored within its parent directory, not with the file itself.&lt;&#x2F;li&gt;
&lt;li&gt;More than one file inside a directory&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
	</entry>
	<entry xml:lang="en">
		<title>Soft and Hard Links in Linux</title>
		<published>2025-05-05T00:00:00+00:00</published>
		<updated>2025-05-05T00:00:00+00:00</updated>
		<link rel="alternate" type="text/html" href="https://ashraddhansh.github.io/posts/soft-and-hard-link-in-linux/"/>
		<id>https://ashraddhansh.github.io/posts/soft-and-hard-link-in-linux/</id>
    
		<content type="html" xml:base="https://ashraddhansh.github.io/posts/soft-and-hard-link-in-linux/">&lt;h1 id=&quot;links-in-linux-filesystem&quot;&gt;Links in Linux Filesystem&lt;a class=&quot;zola-anchor&quot; href=&quot;#links-in-linux-filesystem&quot; aria-label=&quot;Anchor link for: links-in-linux-filesystem&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;A link is a mechanism that allows multiple references (names or path) to point at single file or directory within the filesystem.&lt;&#x2F;li&gt;
&lt;li&gt;It is essentially a way to create alternate access points to data that already exists in the disk, either by referencing the actual data or by referencing the file&#x27;s path.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;So in short:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;In the Linux filesystem, &lt;strong&gt;links&lt;&#x2F;strong&gt; are references to files or directories.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h1 id=&quot;inode-index-node&quot;&gt;Inode(Index-node)&lt;a class=&quot;zola-anchor&quot; href=&quot;#inode-index-node&quot; aria-label=&quot;Anchor link for: inode-index-node&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;Before understanding more about links first we need to understand about inode.&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Inode is a data structure.&lt;&#x2F;li&gt;
&lt;li&gt;It is used to store metadata about the files and directories.&lt;&#x2F;li&gt;
&lt;li&gt;An inode is a unique identifier for a file within a specific filesystem.&lt;&#x2F;li&gt;
&lt;li&gt;Each file and directory has it&#x27;s own unique inode number.(except hard links)&lt;&#x2F;li&gt;
&lt;li&gt;It can be accessed by using &lt;code&gt;-i&lt;&#x2F;code&gt; flag in &lt;code&gt;ls&lt;&#x2F;code&gt; command.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; ls&lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt; -&lt;&#x2F;span&gt;i&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;6685071&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; Clone  6834739 Desktop    6708661 Documents  6707926 Music     6837431 packettracer  7112736 Projects  6708639 Scripts  6834960 Templates  6708514 Wallpaper&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;8394325&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; data   6708934 Developer  6707119 Downloads  6708058 Obsidian  6704479 Pictures      6834961 Public    6708492 temp     6708587 Videos&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Here you can see the inode numbers of directories in my home directory.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;types-of-links&quot;&gt;Types of Links&lt;a class=&quot;zola-anchor&quot; href=&quot;#types-of-links&quot; aria-label=&quot;Anchor link for: types-of-links&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;There are two types of links:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Hard Link&lt;&#x2F;li&gt;
&lt;li&gt;Soft Link(Symbolic Link)&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;h1 id=&quot;hard-link&quot;&gt;Hard Link&lt;a class=&quot;zola-anchor&quot; href=&quot;#hard-link&quot; aria-label=&quot;Anchor link for: hard-link&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;Let&#x27;s say I have a file named &lt;code&gt;file1.txt&lt;&#x2F;code&gt; and I created a hard link of &lt;code&gt;file1.txt&lt;&#x2F;code&gt; as &lt;code&gt;file2.txt&lt;&#x2F;code&gt; which is essentially a reference to the &lt;code&gt;file1.txt&lt;&#x2F;code&gt;.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;images&#x2F;soft-and-hard-links-in-linux-1.png&quot; alt=&quot;image&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;As it appears to be that there are two files here but actually in disk the content of the file is stored only once and both files points to that memory location&lt;&#x2F;li&gt;
&lt;li&gt;So now when I try to access any of two files the filesystem point to the highlighted disk space.&lt;&#x2F;li&gt;
&lt;li&gt;Both files will have same inode numbers because inode numbers are allotted according to disk space, as both files points to the same disk address they will have the same inode number.&lt;&#x2F;li&gt;
&lt;li&gt;When you delete any one of the file the other one will be unaffected, but when you make changes in one file, it will reflect in the other file, because at the low level you are manipulating the bits stored in the disk address which is linked to both files.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;creating-hard-link&quot;&gt;Creating Hard Link&lt;a class=&quot;zola-anchor&quot; href=&quot;#creating-hard-link&quot; aria-label=&quot;Anchor link for: creating-hard-link&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;Let&#x27;s create a file and populate it with some text.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;touch&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; hello.txt&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-echo z-shell&quot;&gt;echo&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; &lt;span class=&quot;z-string z-quoted z-double z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;hello, world&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-redirection z-shell&quot;&gt;&amp;gt;&amp;gt;&lt;&#x2F;span&gt; hello.txt&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Now let&#x27;s create a hard link of &lt;code&gt;hello.txt&lt;&#x2F;code&gt; to &lt;code&gt;hello2.txt&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;ln&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; hello.txt hello2.txt&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Now check the contents of the &lt;code&gt;hello2.txt&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; cat hello2.txt &lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;hello,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; world&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;It is same as of &lt;code&gt;hello.txt&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Now let&#x27;s see the inodes of these files, they are same it means both files points to the same location in the disk.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; ls&lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt; -&lt;&#x2F;span&gt;i&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;9708270&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; hello2.txt  9708270 hello.txt&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Try to make changes in one file and then see if the changes reflect in other file. Delete one file and see if it affects the other file.
The advantage of hard link is it provides file redundancy without data duplication.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;soft-link-symbolic-link&quot;&gt;Soft Link(Symbolic Link)&lt;a class=&quot;zola-anchor&quot; href=&quot;#soft-link-symbolic-link&quot; aria-label=&quot;Anchor link for: soft-link-symbolic-link&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;In soft link the linked file points to the file not the disk location.&lt;&#x2F;li&gt;
&lt;li&gt;The &lt;code&gt;file2.txt&lt;&#x2F;code&gt; contains the pathname of &lt;code&gt;file1.txt&lt;&#x2F;code&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;Unlike hard links, a symlink doesn&#x27;t point directory to the files&#x27;s inode.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;images&#x2F;soft-and-hard-links-in-linux-2.png&quot; alt=&quot;image&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Let&#x27;s create a file and populate it&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;touch&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; test1.txt&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-echo z-shell&quot;&gt;echo&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; &lt;span class=&quot;z-string z-quoted z-double z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;this is test1 file&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-redirection z-shell&quot;&gt;&amp;gt;&amp;gt;&lt;&#x2F;span&gt; test1.txt &lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ul&gt;
&lt;li&gt;Now create a symbolic link&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;ln&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt;&lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt; -&lt;&#x2F;span&gt;s&lt;&#x2F;span&gt; test1.txt test2.txt&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ul&gt;
&lt;li&gt;Let&#x27;s see the inode of these files. They are different because they are not pointing to the same disk address. The file &lt;code&gt;test2.txt&lt;&#x2F;code&gt; actually contains a string that holds the path of the &lt;code&gt;test1.txt&lt;&#x2F;code&gt; not the contents of the target file.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;ls&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt;&lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt; -&lt;&#x2F;span&gt;i&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;9708272&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; test1.txt  9708274 test2.txt&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ul&gt;
&lt;li&gt;in this case also the changes of one file will reflect on other file also.&lt;&#x2F;li&gt;
&lt;li&gt;If you delete the &lt;code&gt;test1.txt&lt;&#x2F;code&gt; then &lt;code&gt;test2.txt&lt;&#x2F;code&gt; will be useless. But vice-versa will not be true.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h1 id=&quot;advantage-of-symbolic-link-over-hard-link&quot;&gt;Advantage of Symbolic Link over Hard Link&lt;a class=&quot;zola-anchor&quot; href=&quot;#advantage-of-symbolic-link-over-hard-link&quot; aria-label=&quot;Anchor link for: advantage-of-symbolic-link-over-hard-link&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;ol&gt;
&lt;li&gt;Can link to directories.&lt;&#x2F;li&gt;
&lt;li&gt;A soft link can point to a file or directory &lt;strong&gt;on a different mounted filesystem&lt;&#x2F;strong&gt;, partition, or device. Hard link can&#x27;t link files between different devices or filesystem because hard links point directly to inodes, and inodes are only meaningful within the filesystem where they were created.&lt;&#x2F;li&gt;
&lt;li&gt;Can link to non-existent targets. Useful in scripting, where the target might appear later.&lt;&#x2F;li&gt;
&lt;li&gt;Dynamic path resolution. Symbolic links resolve to the &lt;strong&gt;current location of the target path&lt;&#x2F;strong&gt;. If the symlink is updated (e.g., re-pointed to a different version of a file), it reflects the change immediately. Useful for switching between different versions of software.&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
</content>
	</entry>
	<entry xml:lang="en">
		<title>File Conditional Expressions in Bash</title>
		<published>2025-05-04T00:00:00+00:00</published>
		<updated>2025-05-04T00:00:00+00:00</updated>
		<link rel="alternate" type="text/html" href="https://ashraddhansh.github.io/posts/file-conditional-expressions-in-bash/"/>
		<id>https://ashraddhansh.github.io/posts/file-conditional-expressions-in-bash/</id>
    
		<content type="html" xml:base="https://ashraddhansh.github.io/posts/file-conditional-expressions-in-bash/">&lt;h1 id=&quot;what-are-conditional-expressions&quot;&gt;What are conditional expressions?&lt;a class=&quot;zola-anchor&quot; href=&quot;#what-are-conditional-expressions&quot; aria-label=&quot;Anchor link for: what-are-conditional-expressions&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;When we use conditional statements like &lt;code&gt;if&lt;&#x2F;code&gt; we need to pass some conditions to check whether it&#x27;s true or not and based on that information we execute some commands.
For example:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;python&quot; class=&quot;language-python z-code&quot;&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;z-source z-python&quot;&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;i&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-assignment z-python&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-python&quot;&gt;4&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-python&quot;&gt;&lt;span class=&quot;z-meta z-statement z-conditional z-if z-python&quot;&gt;&lt;span class=&quot;z-keyword z-control z-conditional z-if z-python&quot;&gt;if&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;i&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-comparison z-python&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-python&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-block z-conditional z-if z-python&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-python&quot;&gt;	&lt;span class=&quot;z-meta z-function-call z-python&quot;&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-variable z-function z-python&quot;&gt;&lt;span class=&quot;z-support z-function z-builtin z-python&quot;&gt;print&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-python&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-string z-python&quot;&gt;&lt;span class=&quot;z-string z-quoted z-double z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-python&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-string z-python&quot;&gt;&lt;span class=&quot;z-string z-quoted z-double z-python&quot;&gt;i is greater than 2&lt;span class=&quot;z-punctuation z-definition z-string z-end z-python&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-python&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-python&quot;&gt;&lt;span class=&quot;z-meta z-statement z-conditional z-else z-python&quot;&gt;&lt;span class=&quot;z-keyword z-control z-conditional z-else z-python&quot;&gt;else&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-block z-conditional z-else z-python&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-python&quot;&gt;	&lt;span class=&quot;z-meta z-function-call z-python&quot;&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-variable z-function z-python&quot;&gt;&lt;span class=&quot;z-support z-function z-builtin z-python&quot;&gt;print&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-python&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-string z-python&quot;&gt;&lt;span class=&quot;z-string z-quoted z-double z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-python&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-string z-python&quot;&gt;&lt;span class=&quot;z-string z-quoted z-double z-python&quot;&gt;i is lesser than 2&lt;span class=&quot;z-punctuation z-definition z-string z-end z-python&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-python&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The above program checks that if the value of i is greater than 2 or not if true it prints &quot;i is greater than 2&quot;.
The &lt;code&gt;i&amp;gt;2&lt;&#x2F;code&gt; is conditional expression.&lt;&#x2F;p&gt;
&lt;p&gt;Likewise bash also have conditional expressions but the syntax is unique.
Conditional expressions in bash are targeted more towards the Linux usability like checking conditions on files, directories etc.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;conditional-expressions-for-files&quot;&gt;Conditional Expressions for Files&lt;a class=&quot;zola-anchor&quot; href=&quot;#conditional-expressions-for-files&quot; aria-label=&quot;Anchor link for: conditional-expressions-for-files&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;Here is a example code:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-comment z-line z-number-sign z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-begin z-shell&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-number-sign z-shell&quot;&gt;! &#x2F;usr&#x2F;bin&#x2F;env bash&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-number-sign z-shell&quot;&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-variable z-other z-readwrite z-assignment z-shell&quot;&gt;filename&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-assignment z-shell&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-unquoted z-shell&quot;&gt;.&#x2F;array5.sh&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-keyword z-control z-conditional z-if z-shell&quot;&gt;if&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-double-brace z-begin z-shell&quot;&gt;[[&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt;-&lt;&#x2F;span&gt;a&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-variable z-shell&quot;&gt;$&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-expansion z-parameter z-begin z-shell&quot;&gt;{&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-variable z-other z-readwrite z-shell&quot;&gt;filename&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-expansion z-parameter z-end z-shell&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-support z-function z-double-brace z-end z-shell&quot;&gt;]]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-logical z-continue z-shell&quot;&gt;;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-control z-conditional z-then z-shell&quot;&gt;then&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;  &lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-echo z-shell&quot;&gt;echo&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; &lt;span class=&quot;z-string z-quoted z-double z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;The file exists!&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-keyword z-control z-conditional z-else z-shell&quot;&gt;else&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;  &lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-echo z-shell&quot;&gt;echo&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; &lt;span class=&quot;z-string z-quoted z-double z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;The file doesn&amp;#39;t exists!&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-keyword z-control z-conditional z-end z-shell&quot;&gt;fi&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-keyword z-control z-conditional z-if z-shell&quot;&gt;if&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-double-brace z-begin z-shell&quot;&gt;[[&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt;-&lt;&#x2F;span&gt;d&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-variable z-shell&quot;&gt;$&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-expansion z-parameter z-begin z-shell&quot;&gt;{&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-variable z-other z-readwrite z-shell&quot;&gt;filename&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-expansion z-parameter z-end z-shell&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-support z-function z-double-brace z-end z-shell&quot;&gt;]]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-logical z-continue z-shell&quot;&gt;;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-control z-conditional z-then z-shell&quot;&gt;then&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;  &lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-echo z-shell&quot;&gt;echo&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; &lt;span class=&quot;z-string z-quoted z-double z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;This is a directory!&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-keyword z-control z-conditional z-else z-shell&quot;&gt;else&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;  &lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-echo z-shell&quot;&gt;echo&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; &lt;span class=&quot;z-string z-quoted z-double z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;This is not a directory!&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-keyword z-control z-conditional z-end z-shell&quot;&gt;fi&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-keyword z-control z-conditional z-if z-shell&quot;&gt;if&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-double-brace z-begin z-shell&quot;&gt;[[&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt;-&lt;&#x2F;span&gt;r&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-variable z-shell&quot;&gt;$&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-expansion z-parameter z-begin z-shell&quot;&gt;{&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-variable z-other z-readwrite z-shell&quot;&gt;filename&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-expansion z-parameter z-end z-shell&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-support z-function z-double-brace z-end z-shell&quot;&gt;]]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-logical z-continue z-shell&quot;&gt;;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-control z-conditional z-then z-shell&quot;&gt;then&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;  &lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-echo z-shell&quot;&gt;echo&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; &lt;span class=&quot;z-string z-quoted z-double z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;The file exists and is readable&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-keyword z-control z-conditional z-end z-shell&quot;&gt;fi&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-keyword z-control z-conditional z-if z-shell&quot;&gt;if&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-double-brace z-begin z-shell&quot;&gt;[[&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt;-&lt;&#x2F;span&gt;s&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-variable z-shell&quot;&gt;$&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-expansion z-parameter z-begin z-shell&quot;&gt;{&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-variable z-other z-readwrite z-shell&quot;&gt;filename&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-expansion z-parameter z-end z-shell&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-support z-function z-double-brace z-end z-shell&quot;&gt;]]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-logical z-continue z-shell&quot;&gt;;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-control z-conditional z-then z-shell&quot;&gt;then&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;  &lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-echo z-shell&quot;&gt;echo&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; &lt;span class=&quot;z-string z-quoted z-double z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;The file exists and file size is greater than zero&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-keyword z-control z-conditional z-end z-shell&quot;&gt;fi&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-keyword z-control z-conditional z-if z-shell&quot;&gt;if&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-double-brace z-begin z-shell&quot;&gt;[[&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt;-&lt;&#x2F;span&gt;w&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-variable z-shell&quot;&gt;$&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-expansion z-parameter z-begin z-shell&quot;&gt;{&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-variable z-other z-readwrite z-shell&quot;&gt;filename&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-expansion z-parameter z-end z-shell&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-support z-function z-double-brace z-end z-shell&quot;&gt;]]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-logical z-continue z-shell&quot;&gt;;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-control z-conditional z-then z-shell&quot;&gt;then&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;  &lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-echo z-shell&quot;&gt;echo&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; &lt;span class=&quot;z-string z-quoted z-double z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;The file exists and file is writable&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-keyword z-control z-conditional z-end z-shell&quot;&gt;fi&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-keyword z-control z-conditional z-if z-shell&quot;&gt;if&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-double-brace z-begin z-shell&quot;&gt;[[&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt;-&lt;&#x2F;span&gt;x&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-variable z-shell&quot;&gt;$&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-expansion z-parameter z-begin z-shell&quot;&gt;{&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-variable z-other z-readwrite z-shell&quot;&gt;filename&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-expansion z-parameter z-end z-shell&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-support z-function z-double-brace z-end z-shell&quot;&gt;]]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-logical z-continue z-shell&quot;&gt;;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-control z-conditional z-then z-shell&quot;&gt;then&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;  &lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-echo z-shell&quot;&gt;echo&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; &lt;span class=&quot;z-string z-quoted z-double z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;The file exists and file is executable&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-keyword z-control z-conditional z-end z-shell&quot;&gt;fi&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-keyword z-control z-conditional z-if z-shell&quot;&gt;if&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-double-brace z-begin z-shell&quot;&gt;[[&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt;-&lt;&#x2F;span&gt;L&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-variable z-shell&quot;&gt;$&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-expansion z-parameter z-begin z-shell&quot;&gt;{&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-variable z-other z-readwrite z-shell&quot;&gt;filename&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-expansion z-parameter z-end z-shell&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-support z-function z-double-brace z-end z-shell&quot;&gt;]]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-logical z-continue z-shell&quot;&gt;;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-control z-conditional z-then z-shell&quot;&gt;then&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;  &lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-echo z-shell&quot;&gt;echo&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; &lt;span class=&quot;z-string z-quoted z-double z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;The file exists and file is symbolic link&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-keyword z-control z-conditional z-else z-shell&quot;&gt;else&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;  &lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-echo z-shell&quot;&gt;echo&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; &lt;span class=&quot;z-string z-quoted z-double z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Not a symbolic Link!&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-keyword z-control z-conditional z-end z-shell&quot;&gt;fi&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;In the above code we have multiple &lt;code&gt;if then&lt;&#x2F;code&gt; statements that the checking some conditions on file &lt;code&gt;array5.sh&lt;&#x2F;code&gt; whole name is stored at the top in the variable name &lt;code&gt;filename&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Let&#x27;s see the first &lt;code&gt;if then&lt;&#x2F;code&gt; statement block:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-variable z-other z-readwrite z-assignment z-shell&quot;&gt;filename&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-assignment z-shell&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-unquoted z-shell&quot;&gt;.&#x2F;array5.sh&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-keyword z-control z-conditional z-if z-shell&quot;&gt;if&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-double-brace z-begin z-shell&quot;&gt;[[&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt;-&lt;&#x2F;span&gt;a&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-variable z-shell&quot;&gt;$&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-expansion z-parameter z-begin z-shell&quot;&gt;{&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-variable z-other z-readwrite z-shell&quot;&gt;filename&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-expansion z-parameter z-end z-shell&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-support z-function z-double-brace z-end z-shell&quot;&gt;]]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-logical z-continue z-shell&quot;&gt;;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-control z-conditional z-then z-shell&quot;&gt;then&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;  &lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-echo z-shell&quot;&gt;echo&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; &lt;span class=&quot;z-string z-quoted z-double z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;The file exists!&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-keyword z-control z-conditional z-else z-shell&quot;&gt;else&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;  &lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-echo z-shell&quot;&gt;echo&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; &lt;span class=&quot;z-string z-quoted z-double z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;The file doesn&amp;#39;t exists!&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-keyword z-control z-conditional z-end z-shell&quot;&gt;fi&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ul&gt;
&lt;li&gt;Here I have condition &lt;code&gt;[[ -a ${filename} ]]&lt;&#x2F;code&gt; for if statement.&lt;&#x2F;li&gt;
&lt;li&gt;This will check whether the file exists or not in the current directory(because the file path is &lt;code&gt;.&#x2F;array5.sh&lt;&#x2F;code&gt;, &lt;code&gt;.&lt;&#x2F;code&gt; means the current directory) .&lt;&#x2F;li&gt;
&lt;li&gt;If the file exists then the program will execute the &lt;code&gt;then&lt;&#x2F;code&gt; block and message &lt;code&gt;The file exists!&lt;&#x2F;code&gt; will be printed.&lt;&#x2F;li&gt;
&lt;li&gt;If the file &lt;code&gt;array5.sh&lt;&#x2F;code&gt; doesn&#x27;t exists in the current directory then the program will execute &lt;code&gt;else&lt;&#x2F;code&gt; block and message &lt;code&gt;This file doesn&#x27;t exists!&lt;&#x2F;code&gt; will print in the console.&lt;&#x2F;li&gt;
&lt;li&gt;The ending &lt;code&gt;fi&lt;&#x2F;code&gt; is the syntax of the bash &lt;code&gt;if&lt;&#x2F;code&gt; statement, it is there to indicate the closing of the &lt;code&gt;if&lt;&#x2F;code&gt; block.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;There are other conditional expressions for files:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;[[ -d ${filename} ]]&lt;&#x2F;code&gt; : True if the file is a directory.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;[[ -r ${filename} ]]&lt;&#x2F;code&gt; : True if file exists and readable.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;[[ -s ${filename} ]]&lt;&#x2F;code&gt; : True if file exists and has size larger than zero.(To check empty files)&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;[[ -w ${filename} ]]&lt;&#x2F;code&gt; : True if file exists and writable.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;[[ -x ${filename} ]]&lt;&#x2F;code&gt; : True if file exists and executable.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;[[ -L ${filename} ]]&lt;&#x2F;code&gt; : True if file is a symbolic link.&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;&#x2F;strong&gt; The &lt;code&gt;-x&lt;&#x2F;code&gt; ,&lt;code&gt;-w&lt;&#x2F;code&gt;, &lt;code&gt;-r&lt;&#x2F;code&gt; flags check the file permissions for the user that is running the script.&lt;&#x2F;p&gt;
</content>
	</entry>
	<entry xml:lang="en">
		<title>Basics of Linux File System</title>
		<published>2025-03-05T00:00:00+00:00</published>
		<updated>2025-03-05T00:00:00+00:00</updated>
		<link rel="alternate" type="text/html" href="https://ashraddhansh.github.io/posts/basics-of-linux-file-system/"/>
		<id>https://ashraddhansh.github.io/posts/basics-of-linux-file-system/</id>
    
		<content type="html" xml:base="https://ashraddhansh.github.io/posts/basics-of-linux-file-system/">&lt;h1 id=&quot;directory&quot;&gt;Directory&lt;a class=&quot;zola-anchor&quot; href=&quot;#directory&quot; aria-label=&quot;Anchor link for: directory&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;It is a special type of file in a Linux file-system.&lt;&#x2F;li&gt;
&lt;li&gt;It acts as a container for other files and directories.&lt;&#x2F;li&gt;
&lt;li&gt;The content stored in a directory is essentially a list of &lt;a href=&quot;https:&#x2F;&#x2F;ashraddhansh.github.io&#x2F;posts&#x2F;directory-entry&#x2F;&quot;&gt;Directory Entry&lt;&#x2F;a&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;These are organized in hierarchical structure.&lt;&#x2F;li&gt;
&lt;li&gt;In Linux everything is a file.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h1 id=&quot;directory-entry&quot;&gt;Directory Entry&lt;a class=&quot;zola-anchor&quot; href=&quot;#directory-entry&quot; aria-label=&quot;Anchor link for: directory-entry&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;It is a record in a directory.&lt;&#x2F;li&gt;
&lt;li&gt;It associates or maps a file name(human readable) with its inode number in a file-system.&lt;&#x2F;li&gt;
&lt;li&gt;A directory entry contains the file name and pointer to the file&#x27;s inode.&lt;&#x2F;li&gt;
&lt;li&gt;It is stored in &lt;a href=&quot;https:&#x2F;&#x2F;ashraddhansh.github.io&#x2F;posts&#x2F;directory&#x2F;&quot;&gt;Directory&lt;&#x2F;a&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;It doesn&#x27;t store the file metadata that is done by &lt;a href=&quot;https:&#x2F;&#x2F;ashraddhansh.github.io&#x2F;posts&#x2F;inode&#x2F;&quot;&gt;Inode(Index Node)&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h1 id=&quot;inode-index-node&quot;&gt;Inode(Index Node)&lt;a class=&quot;zola-anchor&quot; href=&quot;#inode-index-node&quot; aria-label=&quot;Anchor link for: inode-index-node&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;Inode is a date structure.&lt;&#x2F;li&gt;
&lt;li&gt;It stores the metadata and other information of files except the file name.&lt;&#x2F;li&gt;
&lt;li&gt;Each file and &lt;a href=&quot;https:&#x2F;&#x2F;ashraddhansh.github.io&#x2F;posts&#x2F;directory&#x2F;&quot;&gt;Directory&lt;&#x2F;a&gt; has its own unique inode.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;type-of-info-stored-in-inode&quot;&gt;Type of Info stored in Inode&lt;a class=&quot;zola-anchor&quot; href=&quot;#type-of-info-stored-in-inode&quot; aria-label=&quot;Anchor link for: type-of-info-stored-in-inode&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;1-metadata&quot;&gt;1. Metadata&lt;a class=&quot;zola-anchor&quot; href=&quot;#1-metadata&quot; aria-label=&quot;Anchor link for: 1-metadata&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;File type&lt;&#x2F;li&gt;
&lt;li&gt;File permissions&lt;&#x2F;li&gt;
&lt;li&gt;Owner and Group ID(UID &amp;amp; GID)&lt;&#x2F;li&gt;
&lt;li&gt;File size&lt;&#x2F;li&gt;
&lt;li&gt;Timestamps (birth, access, modification, change times)&lt;&#x2F;li&gt;
&lt;li&gt;Number of &lt;a href=&quot;https:&#x2F;&#x2F;ashraddhansh.github.io&#x2F;posts&#x2F;hard-link&#x2F;&quot;&gt;Hard link&lt;&#x2F;a&gt; &amp;amp; &lt;a href=&quot;https:&#x2F;&#x2F;ashraddhansh.github.io&#x2F;posts&#x2F;soft-link&#x2F;&quot;&gt;Soft Link (Symbolic Link)&lt;&#x2F;a&gt;.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;2-location-of-data-blocks&quot;&gt;2. Location of Data blocks&lt;a class=&quot;zola-anchor&quot; href=&quot;#2-location-of-data-blocks&quot; aria-label=&quot;Anchor link for: 2-location-of-data-blocks&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h3&gt;
&lt;p&gt;Pointers of the disk blocks where data is stored.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;em&gt;the file name and the directory path is not stored in inode these info are managed separately by &lt;a href=&quot;https:&#x2F;&#x2F;ashraddhansh.github.io&#x2F;posts&#x2F;directory-entry&#x2F;&quot;&gt;Directory Entry&lt;&#x2F;a&gt; that map file names to inode numbers.&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;working-of-inode&quot;&gt;Working of Inode&lt;a class=&quot;zola-anchor&quot; href=&quot;#working-of-inode&quot; aria-label=&quot;Anchor link for: working-of-inode&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;Each file and directory has its inode.&lt;&#x2F;li&gt;
&lt;li&gt;When new file or directory is created the file-system assigns a unused inode to it.&lt;&#x2F;li&gt;
&lt;li&gt;It serves as identifier for file and directory.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;viewing-inode&quot;&gt;Viewing Inode&lt;a class=&quot;zola-anchor&quot; href=&quot;#viewing-inode&quot; aria-label=&quot;Anchor link for: viewing-inode&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;ls&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt;&lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt; -&lt;&#x2F;span&gt;i&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;output&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; -&lt;span class=&quot;z-keyword z-operator z-assignment z-redirection z-shell&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;4073139&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; bubble  4073136 bubble.c  4073141 bubble.png  4073138 insertion  4073137 insertion.c&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This will return the file names with it&#x27;s inode numbers.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;creation-of-inodes&quot;&gt;Creation of inodes&lt;a class=&quot;zola-anchor&quot; href=&quot;#creation-of-inodes&quot; aria-label=&quot;Anchor link for: creation-of-inodes&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;When a file system is created a fixed number of inodes are pre-allocated based on the size of file-system.&lt;&#x2F;li&gt;
&lt;li&gt;The number of inodes are in the ratio with the file system size. (like 1 inode per 16KB).&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;dynamic-assignment-of-inodes&quot;&gt;Dynamic assignment of inodes&lt;a class=&quot;zola-anchor&quot; href=&quot;#dynamic-assignment-of-inodes&quot; aria-label=&quot;Anchor link for: dynamic-assignment-of-inodes&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;When new file or directory is created the file-system looks for first available unallocated inode from the inode table and assign it.&lt;&#x2F;li&gt;
&lt;li&gt;inode number can be reused, when file or directories are deleted the inode of those are marked unallocated by the file-system and then can be reused.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h1 id=&quot;hard-link&quot;&gt;Hard link&lt;a class=&quot;zola-anchor&quot; href=&quot;#hard-link&quot; aria-label=&quot;Anchor link for: hard-link&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;Hard link is a directory entry that maps the file name with an inode in a file-system.&lt;&#x2F;li&gt;
&lt;li&gt;A hard link creates a additional name for the same file, pointing at the same inode thus referring the same data.&lt;&#x2F;li&gt;
&lt;li&gt;Hard links are indistinguishable from the original file even the timestamps will be the same(access time, modify time etc).&lt;&#x2F;li&gt;
&lt;li&gt;Each file must have atleast one hard link because the hard link maps the file name with its inode which contains the metadata and pointers to the file content.&lt;&#x2F;li&gt;
&lt;li&gt;Hard links can&#x27;t be created between different file systems or partitions.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;creating-a-hard-link&quot;&gt;Creating a hard link&lt;a class=&quot;zola-anchor&quot; href=&quot;#creating-a-hard-link&quot; aria-label=&quot;Anchor link for: creating-a-hard-link&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;touch&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; hello.txt&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;ln&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; hello.txt world.txt&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ul&gt;
&lt;li&gt;Here the &lt;code&gt;world.txt&lt;&#x2F;code&gt; is the hard link to &lt;code&gt;hello.txt&lt;&#x2F;code&gt;, they both are pointing to the same inode number thus the same data.&lt;&#x2F;li&gt;
&lt;li&gt;Both files now contains the same data changes done to one will reflect in other file.&lt;&#x2F;li&gt;
&lt;li&gt;Deleting one doesn&#x27;t affect the other.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
	</entry>
	<entry xml:lang="en">
		<title>Directory Entry</title>
		<published>2025-03-05T00:00:00+00:00</published>
		<updated>2025-03-05T00:00:00+00:00</updated>
		<link rel="alternate" type="text/html" href="https://ashraddhansh.github.io/posts/directory-entry/"/>
		<id>https://ashraddhansh.github.io/posts/directory-entry/</id>
    
		<content type="html" xml:base="https://ashraddhansh.github.io/posts/directory-entry/">&lt;ul&gt;
&lt;li&gt;It is a record in a directory.&lt;&#x2F;li&gt;
&lt;li&gt;It associates or maps a file name(human readable) with its inode number in a file-system.&lt;&#x2F;li&gt;
&lt;li&gt;A directory entry contains the file name and pointer to the file&#x27;s inode.&lt;&#x2F;li&gt;
&lt;li&gt;It is stored in &lt;a href=&quot;https:&#x2F;&#x2F;ashraddhansh.github.io&#x2F;posts&#x2F;directory&#x2F;&quot;&gt;Directory&lt;&#x2F;a&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;It doesn&#x27;t store the file metadata that is done by &lt;a href=&quot;https:&#x2F;&#x2F;ashraddhansh.github.io&#x2F;posts&#x2F;inode&#x2F;&quot;&gt;Inode(Index Node)&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
	</entry>
	<entry xml:lang="en">
		<title>Directory</title>
		<published>2025-03-05T00:00:00+00:00</published>
		<updated>2025-03-05T00:00:00+00:00</updated>
		<link rel="alternate" type="text/html" href="https://ashraddhansh.github.io/posts/directory/"/>
		<id>https://ashraddhansh.github.io/posts/directory/</id>
    
		<content type="html" xml:base="https://ashraddhansh.github.io/posts/directory/">&lt;ul&gt;
&lt;li&gt;It is a special type of file in a Linux file-system.&lt;&#x2F;li&gt;
&lt;li&gt;It acts as a container for other files and directories.&lt;&#x2F;li&gt;
&lt;li&gt;The content stored in a directory is essentially a list of &lt;a href=&quot;https:&#x2F;&#x2F;ashraddhansh.github.io&#x2F;posts&#x2F;directory-entry&#x2F;&quot;&gt;Directory Entry&lt;&#x2F;a&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;These are organized in hierarchical structure.&lt;&#x2F;li&gt;
&lt;li&gt;In Linux everything is a file.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
	</entry>
	<entry xml:lang="en">
		<title>Hard Link</title>
		<published>2025-03-05T00:00:00+00:00</published>
		<updated>2025-03-05T00:00:00+00:00</updated>
		<link rel="alternate" type="text/html" href="https://ashraddhansh.github.io/posts/hard-link/"/>
		<id>https://ashraddhansh.github.io/posts/hard-link/</id>
    
		<content type="html" xml:base="https://ashraddhansh.github.io/posts/hard-link/">&lt;ul&gt;
&lt;li&gt;Hard link is a directory entry that maps the file name with an inode in a file-system.&lt;&#x2F;li&gt;
&lt;li&gt;A hard link creates a additional name for the same file, pointing at the same inode thus referring the same data.&lt;&#x2F;li&gt;
&lt;li&gt;Hard links are indistinguishable from the original file even the timestamps will be the same(access time, modify time etc).&lt;&#x2F;li&gt;
&lt;li&gt;Each file must have atleast one hard link because the hard link maps the file name with its inode which contains the metadata and pointers to the file content.&lt;&#x2F;li&gt;
&lt;li&gt;Hard links can&#x27;t be created between different file systems or partitions.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h1 id=&quot;creation-of-hard-links&quot;&gt;Creation of Hard links&lt;a class=&quot;zola-anchor&quot; href=&quot;#creation-of-hard-links&quot; aria-label=&quot;Anchor link for: creation-of-hard-links&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;touch&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; hello.txt&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;ln&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; hello.txt world.txt&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ul&gt;
&lt;li&gt;Here the &lt;code&gt;world.txt&lt;&#x2F;code&gt; is the hard link to &lt;code&gt;hello.txt&lt;&#x2F;code&gt;, they both are pointing to the same inode number thus the same data.&lt;&#x2F;li&gt;
&lt;li&gt;Both files now contains the same data changes done to one will reflect in other file.&lt;&#x2F;li&gt;
&lt;li&gt;Deleting one doesn&#x27;t affect the other.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
	</entry>
	<entry xml:lang="en">
		<title>Inode(Index Node)</title>
		<published>2025-03-05T00:00:00+00:00</published>
		<updated>2025-03-05T00:00:00+00:00</updated>
		<link rel="alternate" type="text/html" href="https://ashraddhansh.github.io/posts/inode/"/>
		<id>https://ashraddhansh.github.io/posts/inode/</id>
    
		<content type="html" xml:base="https://ashraddhansh.github.io/posts/inode/">&lt;ul&gt;
&lt;li&gt;Inode is a date structure.&lt;&#x2F;li&gt;
&lt;li&gt;It stores the metadata and other information of files except the file name.&lt;&#x2F;li&gt;
&lt;li&gt;Each file and &lt;a href=&quot;https:&#x2F;&#x2F;ashraddhansh.github.io&#x2F;posts&#x2F;directory&#x2F;&quot;&gt;Directory&lt;&#x2F;a&gt; has its own unique inode.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h1 id=&quot;type-of-info-stored-in-inode&quot;&gt;Type of Info stored in Inode&lt;a class=&quot;zola-anchor&quot; href=&quot;#type-of-info-stored-in-inode&quot; aria-label=&quot;Anchor link for: type-of-info-stored-in-inode&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;h2 id=&quot;metadata&quot;&gt;Metadata&lt;a class=&quot;zola-anchor&quot; href=&quot;#metadata&quot; aria-label=&quot;Anchor link for: metadata&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;File type&lt;&#x2F;li&gt;
&lt;li&gt;File permissions&lt;&#x2F;li&gt;
&lt;li&gt;Owner and Group ID(UID &amp;amp; GID)&lt;&#x2F;li&gt;
&lt;li&gt;File size&lt;&#x2F;li&gt;
&lt;li&gt;Timestamps (birth, access, modification, change times)&lt;&#x2F;li&gt;
&lt;li&gt;Number of &lt;a href=&quot;https:&#x2F;&#x2F;ashraddhansh.github.io&#x2F;posts&#x2F;hard-link&#x2F;&quot;&gt;Hard link&lt;&#x2F;a&gt; &amp;amp; &lt;a href=&quot;https:&#x2F;&#x2F;ashraddhansh.github.io&#x2F;posts&#x2F;soft-link&#x2F;&quot;&gt;Soft Link (Symbolic Link)&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;location-of-data-blocks&quot;&gt;Location of Data blocks&lt;a class=&quot;zola-anchor&quot; href=&quot;#location-of-data-blocks&quot; aria-label=&quot;Anchor link for: location-of-data-blocks&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;Pointers of the disk blocks where data is stored.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;em&gt;the file name and the directory path is not stored in inode these info are managed separately in [[Directory Entry]] that map file names to inode numbers.&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;working-of-inode&quot;&gt;Working of Inode&lt;a class=&quot;zola-anchor&quot; href=&quot;#working-of-inode&quot; aria-label=&quot;Anchor link for: working-of-inode&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;Each file and directory has its inode.&lt;&#x2F;li&gt;
&lt;li&gt;When new file or directory is created the file-system assigns a unused inode to it.&lt;&#x2F;li&gt;
&lt;li&gt;It serves as identifier for file and directory.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h1 id=&quot;viewing-inode&quot;&gt;Viewing Inode&lt;a class=&quot;zola-anchor&quot; href=&quot;#viewing-inode&quot; aria-label=&quot;Anchor link for: viewing-inode&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;ls&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt;&lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt; -&lt;&#x2F;span&gt;i&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;creation-of-inodes&quot;&gt;Creation of inodes&lt;a class=&quot;zola-anchor&quot; href=&quot;#creation-of-inodes&quot; aria-label=&quot;Anchor link for: creation-of-inodes&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;When a file system is created a fixed number of inodes are pre-allocated based on the size of file-system.&lt;&#x2F;li&gt;
&lt;li&gt;The number of inodes are in the ratio with the file system size. (like 1 inode per 16KB).&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h1 id=&quot;dynamic-assignment-of-inodes&quot;&gt;Dynamic assignment of inodes&lt;a class=&quot;zola-anchor&quot; href=&quot;#dynamic-assignment-of-inodes&quot; aria-label=&quot;Anchor link for: dynamic-assignment-of-inodes&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;When new file or directory is created the file-system looks for first available unallocated inode from the inode table and assign it.&lt;&#x2F;li&gt;
&lt;li&gt;inode number can be reused, when file or directories are deleted the inode of those are marked unallocated by the file-system and then can be reused.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
	</entry>
	<entry xml:lang="en">
		<title>Install Packettracer in Archlinux</title>
		<published>2025-03-05T00:00:00+00:00</published>
		<updated>2025-03-05T00:00:00+00:00</updated>
		<link rel="alternate" type="text/html" href="https://ashraddhansh.github.io/posts/install-packettracer-in-archlinux/"/>
		<id>https://ashraddhansh.github.io/posts/install-packettracer-in-archlinux/</id>
    
		<content type="html" xml:base="https://ashraddhansh.github.io/posts/install-packettracer-in-archlinux/">&lt;ol&gt;
&lt;li&gt;Go to https:&#x2F;&#x2F;www.netacad.com&#x2F;about-networking-academy&#x2F;packet-tracer&#x2F; and create a account or login if you have an existing Network Academy Account.
&lt;img src=&quot;&#x2F;images&#x2F;install-packettracer-1.png&quot; alt=&quot;image&quot; &#x2F;&gt;&lt;&#x2F;li&gt;
&lt;li&gt;After login search for Cisco Packet Tracer in the search bar and click on learning collection one.
&lt;img src=&quot;&#x2F;images&#x2F;install-packettracer-2.png&quot; alt=&quot;image&quot; &#x2F;&gt;&lt;&#x2F;li&gt;
&lt;li&gt;Scroll down and click on Getting Started with Cisco Packet Tracer.
&lt;img src=&quot;&#x2F;images&#x2F;install-packettracer-3.png&quot; alt=&quot;image&quot; &#x2F;&gt;&lt;&#x2F;li&gt;
&lt;li&gt;Now click on Get Started With Self-Paced, new page will load.
&lt;img src=&quot;&#x2F;images&#x2F;install-packettracer-4.png&quot; alt=&quot;image&quot; &#x2F;&gt;&lt;&#x2F;li&gt;
&lt;li&gt;Scroll down and click on the link to download
&lt;img src=&quot;&#x2F;images&#x2F;install-packettracer-5.png&quot; alt=&quot;image&quot; &#x2F;&gt;
![[Pasted image 20250212210454.png]]&lt;&#x2F;li&gt;
&lt;li&gt;Scroll down and click on the link to download the ubuntu version.
&lt;img src=&quot;&#x2F;images&#x2F;install-packettracer-6.png&quot; alt=&quot;image&quot; &#x2F;&gt;&lt;&#x2F;li&gt;
&lt;li&gt;Then install packettracer from AUR(Arch User Repository) using any AUR helper, I use yay.&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;yay&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt;&lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt; -&lt;&#x2F;span&gt;S&lt;&#x2F;span&gt; packettracer&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ol start=&quot;8&quot;&gt;
&lt;li&gt;It will give you error to put the download file in build directory. Now move to your download directory or where you downloaded the installer file and rename that file to &lt;code&gt;CiscoPacketTracer822_amd64_signed.deb&lt;&#x2F;code&gt;.&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;mv&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; &lt;span class=&quot;z-meta z-group z-expansion z-tilde&quot;&gt;&lt;span class=&quot;z-variable z-language z-tilde z-shell&quot;&gt;~&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&#x2F;Downloads&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;mv&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; Packet_Tracer822_amd64_signed.deb CiscoPacketTracer822_amd64_signed.deb&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ol&gt;
&lt;li&gt;Now copy this file to the build directory of AUR package, which is located at &lt;code&gt;~&#x2F;.cache&#x2F;yay&#x2F;packettracer&lt;&#x2F;code&gt;.&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;cp&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; CiscoPacketTracer822_amd64_signed.deb &lt;span class=&quot;z-meta z-group z-expansion z-tilde&quot;&gt;&lt;span class=&quot;z-variable z-language z-tilde z-shell&quot;&gt;~&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&#x2F;.cache&#x2F;yay&#x2F;packettracer&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ol&gt;
&lt;li&gt;Now move to build directory and build the package.&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;mv&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; &lt;span class=&quot;z-meta z-group z-expansion z-tilde&quot;&gt;&lt;span class=&quot;z-variable z-language z-tilde z-shell&quot;&gt;~&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&#x2F;.cache&#x2F;yay&#x2F;packettracer&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;makepkg&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt;&lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt; -&lt;&#x2F;span&gt;si&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ol&gt;
&lt;li&gt;Now the Cisco Packet Tracer should be installed.&lt;&#x2F;li&gt;
&lt;li&gt;Now open the app it will prompt you for login and then you can use it.
&lt;img src=&quot;&#x2F;images&#x2F;install-packettracer-7.png&quot; alt=&quot;image&quot; &#x2F;&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
</content>
	</entry>
	<entry xml:lang="en">
		<title>Segmentation Fault(segfault)</title>
		<published>2025-01-14T00:00:00+00:00</published>
		<updated>2025-01-14T00:00:00+00:00</updated>
		<link rel="alternate" type="text/html" href="https://ashraddhansh.github.io/posts/segmentation-fault/"/>
		<id>https://ashraddhansh.github.io/posts/segmentation-fault/</id>
    
		<content type="html" xml:base="https://ashraddhansh.github.io/posts/segmentation-fault/">&lt;ul&gt;
&lt;li&gt;Segmentation fault or segfault is a type of error generated by programs.&lt;&#x2F;li&gt;
&lt;li&gt;Segmentation fault happen when program tries to access the memory that doesn&#x27;t belong to it.&lt;&#x2F;li&gt;
&lt;li&gt;Segfault occurs in those programming languages where you can directly access and manipulate the memory.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h1 id=&quot;example&quot;&gt;Example&lt;a class=&quot;zola-anchor&quot; href=&quot;#example&quot; aria-label=&quot;Anchor link for: example&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;ol&gt;
&lt;li&gt;Referencing a NULL pointer:&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;pre data-lang=&quot;c&quot; class=&quot;language-c z-code&quot;&gt;&lt;code class=&quot;language-c&quot; data-lang=&quot;c&quot;&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-storage z-type z-c&quot;&gt;int&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-c&quot;&gt;*&lt;&#x2F;span&gt;p &lt;span class=&quot;z-keyword z-operator z-assignment z-c&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-language z-c&quot;&gt;NULL&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-keyword z-operator z-c&quot;&gt;*&lt;&#x2F;span&gt;p &lt;span class=&quot;z-keyword z-operator z-assignment z-c&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-c&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;When program tries to access read-only memory:&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;pre data-lang=&quot;c&quot; class=&quot;language-c z-code&quot;&gt;&lt;code class=&quot;language-c&quot; data-lang=&quot;c&quot;&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-storage z-type z-c&quot;&gt;char&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-c&quot;&gt;*&lt;&#x2F;span&gt;str &lt;span class=&quot;z-keyword z-operator z-assignment z-c&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-c&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;hello&lt;span class=&quot;z-punctuation z-definition z-string z-end z-c&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt; &lt;span class=&quot;z-comment z-line z-double-slash z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-c&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt; constant strings are read only.
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-keyword z-operator z-c&quot;&gt;*&lt;&#x2F;span&gt;str &lt;span class=&quot;z-keyword z-operator z-assignment z-c&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-c&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;bao&lt;span class=&quot;z-punctuation z-definition z-string z-end z-c&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt; 
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ol start=&quot;3&quot;&gt;
&lt;li&gt;Dangling Pointer:&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;pre data-lang=&quot;c&quot; class=&quot;language-c z-code&quot;&gt;&lt;code class=&quot;language-c&quot; data-lang=&quot;c&quot;&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-storage z-type z-c&quot;&gt;char&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-c&quot;&gt;*&lt;&#x2F;span&gt;p &lt;span class=&quot;z-keyword z-operator z-assignment z-c&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-language z-c&quot;&gt;NULL&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-c&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;	&lt;span class=&quot;z-storage z-type z-c&quot;&gt;char&lt;&#x2F;span&gt; c&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;	p &lt;span class=&quot;z-keyword z-operator z-assignment z-c&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-c&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;c&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-c&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-keyword z-operator z-c&quot;&gt;*&lt;&#x2F;span&gt;p &lt;span class=&quot;z-keyword z-operator z-assignment z-c&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-c&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt; &lt;span class=&quot;z-comment z-line z-double-slash z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-c&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt; Now p is dangling pointer as it cease to exist after upper block.
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ol start=&quot;4&quot;&gt;
&lt;li&gt;Accessing the address that doesn&#x27;t exists in the memory.&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
</content>
	</entry>
	<entry xml:lang="en">
		<title>Soft Link(Symbolic Link)</title>
		<published>2025-01-14T00:00:00+00:00</published>
		<updated>2025-01-14T00:00:00+00:00</updated>
		<link rel="alternate" type="text/html" href="https://ashraddhansh.github.io/posts/soft-link/"/>
		<id>https://ashraddhansh.github.io/posts/soft-link/</id>
    
		<content type="html" xml:base="https://ashraddhansh.github.io/posts/soft-link/">&lt;ul&gt;
&lt;li&gt;Soft links(symbolic links) are specific files that points to the &lt;strong&gt;path&lt;&#x2F;strong&gt; of another file or directory.&lt;&#x2F;li&gt;
&lt;li&gt;Acts as a shortcut of the original file.&lt;&#x2F;li&gt;
&lt;li&gt;Soft links don&#x27;t share the same inode or file data, they act as shortcut or reference to another file.&lt;&#x2F;li&gt;
&lt;li&gt;Each soft link has it&#x27;s own inode.&lt;&#x2F;li&gt;
&lt;li&gt;The original file inode points to the actual data block in the disk space while the inode of the soft-link file points to the path of the original file.&lt;&#x2F;li&gt;
&lt;li&gt;So when we delete the original file the inode of that file is reclaimed by inode table.&lt;&#x2F;li&gt;
&lt;li&gt;The reason why soft-link files are inaccessible after original file deleted is because the inode of main file doesn&#x27;t points to the disk space anymore, after that the inode of soft link can&#x27;t fetch that location of the original file of the file system.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;images&#x2F;soft-link.png&quot; alt=&quot;image&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
</content>
	</entry>
</feed>
