I think ... - serverhttps://blog.kmonsoor.com/2020-10-20T00:00:00+06:00Install the latest Zsh onĀ CentOS2020-10-20T00:00:00+06:002020-10-20T00:00:00+06:00Khaled Monsoortag:blog.kmonsoor.com,2020-10-20:/install-latest-Zsh-on-CentOS/<p>If you&rsquo;re trying to install the latest version of Zsh instead of the default old one, here you&nbsp;go.</p><p>As the <strong>default</strong> Zsh on CentOS is usually an older version, many cool things are not possible on this version of Zsh, like installing <a href="https://ohmyz.sh/">oh-my-zsh</a> or using awesome <a href="https://github.com/romkatv/powerlevel10k">powerlevel10k</a> prompt system, it&rsquo;s understandable if you&rsquo;d like to have the latest Zsh on your system. Easy peasy&nbsp;!! </p> <p><strong>Note</strong>: Please remember to remove the <code>sudo</code> from the commands if you are already in &ldquo;root&rdquo; or sudo-er&nbsp;mode </p> <p>We&rsquo;ll be following these&nbsp;steps:</p> <div class="toc"> <ul> <li><a href="#install-the-pre-requisites">Install the&nbsp;pre-requisites</a></li> <li><a href="#download-the-latest-source">Download the latest&nbsp;source</a></li> <li><a href="#build-install">Build <span class="amp">&amp;</span>&nbsp;Install</a></li> <li><a href="#final-steps">Final&nbsp;steps</a></li> <li><a href="#related">Related</a></li> </ul> </div> <h1 id="install-the-pre-requisites">Install the pre-requisites<a class="headerlink" href="#install-the-pre-requisites" title="Permanent link">&para;</a></h1> <p>We need <span class="caps">GCC</span> (C++ compiler) and other related stuffs for building Zsh from the source&nbsp;code. </p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>sudo yum groupinstall <span class="s2">&quot;Development tools&quot;</span> <span class="linenos" data-linenos="2 "></span><span class="gp">$ </span>sudo yum install ncurses-devel </code></pre></div> <p>Now, check if <span class="caps">GCC</span> is installed properly, by<br> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>gcc -v </code></pre></div></p> <h1 id="download-the-latest-source">Download the latest source<a class="headerlink" href="#download-the-latest-source" title="Permanent link">&para;</a></h1> <p>Now, we gonna get the latest code of Zsh.<br> Please update the link (in the shown command) with the latest by checking <a href="https://www.zsh.org/pub/">this web-folder</a>.<br> Don&rsquo;t forget to update the filename as well, if&nbsp;needed.</p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span><span class="nb">cd</span> /usr/local/src <span class="linenos" data-linenos="2 "></span><span class="gp">$ </span>sudo curl -L https://www.zsh.org/pub/zsh-5.8.tar.xz <span class="se">\</span> <span class="linenos" data-linenos="3 "></span>-o zsh-5.8.tar.xz </code></pre></div> <h1 id="build-install">Build <span class="amp">&amp;</span> Install<a class="headerlink" href="#build-install" title="Permanent link">&para;</a></h1> <p>Unzip the file, &ldquo;dig in&rdquo; to the folder, and build <span class="amp">&amp;</span> install from the&nbsp;source. </p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>sudo tar -xf zsh-5.8.tar.xz <span class="c1"># the actual version of the downloaded file might be different</span> <span class="linenos" data-linenos="2 "></span><span class="gp">$ </span><span class="nb">cd</span> zsh-5.8 <span class="linenos" data-linenos="3 "></span><span class="gp">$ </span>sudo ./configure <span class="o">&amp;&amp;</span> sudo make <span class="o">&amp;&amp;</span> sudo make install </code></pre></div> <h1 id="final-steps">Final steps<a class="headerlink" href="#final-steps" title="Permanent link">&para;</a></h1> <p>Add Zsh to the login shells by adding &lsquo;/usr/local/bin/zsh&rsquo; on the last line of the config file, <code>/etc/shells</code> </p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>sudo -e /etc/shells <span class="linenos" data-linenos="2 "></span><span class="gp">$ </span>sudo chsh <span class="nv">$USER</span> </code></pre></div> <p>Update the system&rsquo;s default symlink to the new Zsh version.<br> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>sudo ln -sf /usr/local/bin/zsh /bin/zsh <span class="linenos" data-linenos="2 "></span><span class="gp">$ </span>zsh --version </code></pre></div></p> <p>It&rsquo;s always a good habit to clean up after doing stuffs. ;) <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>sudo make clean </code></pre></div></p> <p>That&rsquo;s it&nbsp;!</p> <p><img alt="voila" class="noZoom" src="https://i.imgur.com/BEFIOXfm.jpg"></p> <h1 id="related">Related<a class="headerlink" href="#related" title="Permanent link">&para;</a></h1> <p>Want to have a super, cool-looking command shell? Gotcha, fam. Check out my blog on <strong><a href="https://blog.kmonsoor.com/pimp-up-my-terminal/">Pimping up My Linux Terminal</a></strong>.</p> <hr> <p>If you find this post helpful, you can show your support <a href="https://www.patreon.com/kmonsoor">through Patreon</a> or <a href="https://paypal.me/KhaledMonsoor/">Paypal</a> or by <a href="https://ko-fi.com/kmonsoor">buying me a coffee</a>. <em>Thanks!</em></p>Ubuntu - Update APT-GET Server to Use FastestĀ Mirror2016-10-10T00:00:00+06:002016-10-10T00:00:00+06:00Khaled Monsoortag:blog.kmonsoor.com,2016-10-10:/ubuntu-update-apt-get-server-to-use-fastest-mirror/<p>Updating Ubuntu from it&rsquo;s default server takes too damn long. Give it a 10x&nbsp;boost.</p><h2 id="prelude">Prelude<a class="headerlink" href="#prelude" title="Permanent link">&para;</a></h2> <p>By default, Ubuntu sets the update server pointing to its own (<a href="http://archive.ubuntu.com">http://archive.ubuntu.com</a>). It is the safest bet for Ubuntu. But, that&rsquo;s not the case for users, especially who are outside <span class="caps">USA</span>. To make it smoother as well as distribute the load, Ubuntu also provides a list of mirror sites. You can find the official mirror list <a href="https://launchpad.net/ubuntu/+archivemirrors">here</a>. </p> <p>However, it needs some&nbsp;configuration.</p> <h2 id="on-gui">On <span class="caps">GUI</span><a class="headerlink" href="#on-gui" title="Permanent link">&para;</a></h2> <p>Yes, you can do the selection on Ubuntu using its <span class="caps">GUI</span> tool. But, the problem is it don&rsquo;t always work as you&nbsp;want.</p> <blockquote> <p>It works on geolocation, giving me the local server, which is waaaayy slower where I am. The network temporal distance is the important factor here, not spatial distance (<a href="http://askubuntu.com/a/9035/113604">http://askubuntu.com/a/9035/113604</a>)</p> </blockquote> <p><img alt="Ubuntu-select-update-server-GUI" src="http://i.imgur.com/sCWr0zrl.png"></p> <h2 id="so-what-else-do-we-have">so, what else do we have ?<a class="headerlink" href="#so-what-else-do-we-have" title="Permanent link">&para;</a></h2> <p>I use a handy tool for this purpose to point me to the fastest server <span class="caps">FOR</span> <span class="caps">ME</span>. It&rsquo;s <a href="https://github.com/jblakeman/apt-select">apt-select</a>.</p> <p>To install it, i found this method most hassle-free. You may also try <code>pip install</code> method described on the repo&rsquo;s <span class="caps">README</span>&nbsp;file.</p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>git clone https://github.com/jblakeman/apt-select.git </code></pre></div> <p>That&rsquo;s it. Now to execute it, just run the &ldquo;main&rdquo; Python&nbsp;file.</p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span><span class="nb">cd</span> apt-select <span class="hll"><span class="linenos" data-linenos="2 "></span><span class="gp">$ </span>./apt-select.py -c -t <span class="m">3</span> -m one-week-behind </span></code></pre></div> <p>We are choosing here the best 3 mirrors(due to <code>-t 3</code>) which are at most <code>one week behind</code> from the main Ubuntu server. For general purposes, that&rsquo;s good&nbsp;enough.</p> <p>It will choose one using the latency <span class="amp">&amp;</span> ping time, and also show servers&rsquo; bandwidth. Then the tool asks you to select new mirror from the <code>3</code> options came up. Usually, stick to the top option, hence <code>1</code>. For example in my case, it&nbsp;shows:</p> <div class="highlight"><pre><span></span><code><span class="hll"><span class="linenos" data-linenos=" 1 "></span><span class="gp">[khaled:~] $ </span>apt-select -c -t <span class="m">3</span> -m one-week-behind </span><span class="linenos" data-linenos=" 2 "></span><span class="go">Getting list of mirrors...done.</span> <span class="linenos" data-linenos=" 3 "></span><span class="go">Testing latency to mirror(s)</span> <span class="linenos" data-linenos=" 4 "></span><span class="go">[3/3] 100%</span> <span class="linenos" data-linenos=" 5 "></span><span class="go">Getting list of launchpad URLs...done.</span> <span class="linenos" data-linenos=" 6 "></span><span class="go">Looking up 3 status(es)</span> <span class="linenos" data-linenos=" 7 "></span><span class="go">[3/3] 100%</span> <span class="linenos" data-linenos=" 8 "></span><span class="go">1. mirror.dhakacom.com (current)</span> <span class="linenos" data-linenos=" 9 "></span><span class="go"> Latency: 1.89 ms</span> <span class="linenos" data-linenos="10 "></span><span class="go"> Org: dhakaCom Limited</span> <span class="linenos" data-linenos="11 "></span><span class="go"> Status: Up to date</span> <span class="linenos" data-linenos="12 "></span><span class="go"> Speed: 1 Gbps</span> <span class="linenos" data-linenos="13 "></span><span class="go">2. mirror.dhakacom.com</span> <span class="linenos" data-linenos="14 "></span><span class="go"> Latency: 1.96 ms</span> <span class="linenos" data-linenos="15 "></span><span class="go"> Org: dhakaCom Limited</span> <span class="linenos" data-linenos="16 "></span><span class="go"> Status: Up to date</span> <span class="linenos" data-linenos="17 "></span><span class="go"> Speed: 1 Gbps</span> <span class="linenos" data-linenos="18 "></span><span class="go">3. archive.ubuntu.com</span> <span class="linenos" data-linenos="19 "></span><span class="go"> Latency: 205.23 ms</span> <span class="linenos" data-linenos="20 "></span><span class="go"> Org: Canonical Ltd.</span> <span class="linenos" data-linenos="21 "></span><span class="go"> Status: Up to date</span> <span class="linenos" data-linenos="22 "></span><span class="go"> Speed: 100 Mbps</span> <span class="linenos" data-linenos="23 "></span><span class="go">Choose a mirror (1 - 3)</span> <span class="linenos" data-linenos="24 "></span><span class="go">&#39;q&#39; to quit 1</span> <span class="linenos" data-linenos="25 "></span><span class="go">New config file saved to /home/khaled/sources.list</span> </code></pre></div> <p>Then, the tool prepares a new <code>sources.list</code> file to replace the system&rsquo;s one&nbsp;with.</p> <p>Now, replace the file with the new one which will be now used by the <code>apt-get *</code> commands. As it overwrites a system config file, you need to do with <code>sudo</code>.</p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>sudo mv /etc/apt/sources.list /etc/apt/sources.list.backup <span class="o">&amp;&amp;</span> sudo mv sources.list /etc/apt/ </code></pre></div> <p>That&rsquo;s it. Now, all you update/upgrade will be fetched from the newly selected&nbsp;mirror.</p> <p>However, I highly recommend to run <code>update</code> once right&nbsp;away.</p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>sudo apt-get update </code></pre></div> <p>Then, only if you want, run <code>upgrade</code>:</p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>sudo apt-get upgrade </code></pre></div> <hr> <h2 id="you-may-also-like">You may also like<a class="headerlink" href="#you-may-also-like" title="Permanent link">&para;</a></h2> <ul> <li><a href="https://blog.kmonsoor.com/open-source-as-if-you-gonna-die-tonight/?utm_source=related_footer&amp;utm_keyword=coding">Open Source as-if You Gonna Die&nbsp;Tonight</a></li> <li><a href="https://blog.kmonsoor.com/pelican-how-to-make-seo-friendly/?utm_source=related_footer&amp;utm_keyword=python">Pelican Static sites - <span class="caps">SEO</span>&nbsp;Optimization</a></li> <li><a href="https://blog.kmonsoor.com/generate-er-diagram-from-sql-database/?utm_source=related_footer&amp;utm_keyword=coding">Generate <span class="caps">ER</span> diagram from a <span class="caps">SQL</span>-based&nbsp;database</a></li> </ul>