<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Infinite Verma's Blog]]></title><description><![CDATA[Infinite Verma's Blog]]></description><link>https://infiniteverma.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 05 Sep 2026 01:24:09 GMT</lastBuildDate><atom:link href="https://infiniteverma.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How to use Alias to enter commands faster]]></title><description><![CDATA[Have you repeatedly used Linux commands with flags etc that were tedious to enter? Using CTRL + Arrow Keys only gets you so far. The next step from simply using Linux history to bring up commands is to alias them.
Motivation
One of the tasks of a pro...]]></description><link>https://infiniteverma.hashnode.dev/introduction-to-alias</link><guid isPermaLink="true">https://infiniteverma.hashnode.dev/introduction-to-alias</guid><category><![CDATA[Linux]]></category><category><![CDATA[linux-basics]]></category><category><![CDATA[linux for beginners]]></category><dc:creator><![CDATA[InfiniteVerma]]></dc:creator><pubDate>Wed, 27 Apr 2022 13:48:59 GMT</pubDate><content:encoded><![CDATA[<p>Have you repeatedly used Linux commands with flags etc that were tedious to enter? Using CTRL + Arrow Keys only gets you so far. The next step from simply using Linux history to bring up commands is to alias them.</p>
<h3 id="heading-motivation">Motivation</h3>
<p>One of the tasks of a programmer is to automate repetitive things. Sometimes it adds a little overhead to actually doing the task but after automating it, changing it to the new requirements is usually faster than doing the task again manually. In this article, I shall explain how to automate one such range of tasks. </p>
<p>Quite often one needs to enter a specific Linux command. Few examples from my experience:</p>
<ul>
<li>List all process threads with a particular name</li>
<li>Find a file and navigate to that directory</li>
<li>Run a script with a bunch of flags</li>
</ul>
<p>And sure, one can enter them correctly once, and then if required again, one can make use of the bash history. But that takes time too. There should be a way to refer to them with fewer keystrokes. An alias does just that. </p>
<p>Interested? Read ahead.</p>
<h3 id="heading-using-alias">Using alias</h3>
<p>Here's a line from the alias man page:</p>
<blockquote>
<p>An alias definition provides a string value that shall
       replace a command name when it is encountered</p>
</blockquote>
<p>In simple terms, we can create small (albeit meaningful) variables for our commands and enter those instead. </p>
<p>To get the current list of aliases stored currently, enter the command <em>alias</em>.</p>
<pre><code class="lang-bash"><span class="hljs-built_in">alias</span>
</code></pre>
<h4 id="heading-1-create-a-new-alias">1. Create a new alias</h4>
<p>Adding a new alias is as simple as creating a variable in a programming language:</p>
<pre><code class="lang-bash"><span class="hljs-built_in">alias</span> <span class="hljs-built_in">test</span>=<span class="hljs-string">'ps'</span>
</code></pre>
<p>ps gives information about active processes. After the command above is entered, we can enter <em>test</em> to get the same output.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1651064767238/AjmehOlwo.png" alt="image.png" /></p>
<h4 id="heading-2-add-a-script-file-as-an-alias">2. Add a script file as an alias</h4>
<p>Similarly, one can alias a bash script as a command as well.</p>
<pre><code class="lang-bash"><span class="hljs-built_in">alias</span> myscript=<span class="hljs-string">'bash /path/to/script.sh'</span>
</code></pre>
<p>An advantage of using a script file is that one can edit the file but still <em>myscript</em> doesn't need to be changed since it's just executing the script. </p>
<h3 id="heading-persist-alias-through-terminal-sessions">Persist alias through terminal sessions</h3>
<p>To make your aliases remain after closing terminals, one needs to enter them in your terminal rc files. For example, here are a few lines of my .bashrc file:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1651065734722/k4keTukyT.png" alt="image.png" /></p>
<p>Similarly, to add new aliases, simply type them in your .rc file and use the source command to bring up them in the same terminal session.</p>
<h3 id="heading-summary">Summary</h3>
<p>Use alias to envoke repetitive and long commands with shorter words. Add them to the terminal rc file to make them permanent.</p>
]]></content:encoded></item></channel></rss>