I think ... - CentOShttps://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’re trying to install the latest version of Zsh instead of the default old one, here you 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’s understandable if you’d like to have the latest Zsh on your system.
Easy peasy !! </p>
<p><strong>Note</strong>: Please remember to remove the <code>sudo</code> from the commands if you are already in “root” or sudo-er mode </p>
<p>We’ll be following these steps:</p>
<div class="toc">
<ul>
<li><a href="#install-the-pre-requisites">Install the pre-requisites</a></li>
<li><a href="#download-the-latest-source">Download the latest source</a></li>
<li><a href="#build-install">Build <span class="amp">&</span> Install</a></li>
<li><a href="#final-steps">Final 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">¶</a></h1>
<p>We need <span class="caps">GCC</span> (C++ compiler) and other related stuffs for building Zsh from the source 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">"Development tools"</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">¶</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’t forget to update the filename as well, if 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">&</span> Install<a class="headerlink" href="#build-install" title="Permanent link">¶</a></h1>
<p>Unzip the file, “dig in” to the folder, and build <span class="amp">&</span> install from the 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">&&</span> sudo make <span class="o">&&</span> sudo make install
</code></pre></div>
<h1 id="final-steps">Final steps<a class="headerlink" href="#final-steps" title="Permanent link">¶</a></h1>
<p>Add Zsh to the login shells by adding ‘/usr/local/bin/zsh’ 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’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’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’s it !</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">¶</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>Install latest Python 3 on Linux CentOSĀ 72018-07-07T00:00:00+06:002018-07-07T00:00:00+06:00Khaled Monsoortag:blog.kmonsoor.com,2018-07-07:/install-latest-python3-on-centos-7/<p>Install the latest and greatest Python 3 on CentOS 7 systems</p><h2 id="why">Why<a class="headerlink" href="#why" title="Permanent link">¶</a></h2>
<p>Not all distro created equal. <br>
Some are created to join the space race, some are to hold unto the leagcy, some are cutting-edge, some are cutting edge. Some are born to boot-up IoT devices some are to push out heavy graphics.</p>
<p>That’s the fun (albeit, power) of Linux.</p>
<p><img alt="CentOS 7 logo" class="noZoom" src="https://i.imgur.com/6ZFCdoM.jpg"></p>
<p>CentOS 7 is a powerful and stable distro that runs on thousands (probably, millions) production-grade servers.<br>
In the matter of stability, it’s a beast. However, it doesn’t ship with Python 3, by default. You can install it via <span class="caps">EPEL</span> repository, or the below simple steps.</p>
<p>Also, take a note. The Python <strong>2</strong> comes with the system, which is probably 2.7.5, do <strong><span class="caps">NOT</span></strong> mess with it. Many system components rely on that specific version. If you need the latest versions of 2, use <code>virtualenv</code> or <code>pipenv</code>.</p>
<h3 id="prepare-your-system">Prepare your system<a class="headerlink" href="#prepare-your-system" title="Permanent link">¶</a></h3>
<p>Start with installing pre-requisite utilities for compilation and development support.</p>
<div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span>$ sudo yum update <span class="o">&&</span> sudo yum groupinstall -y <span class="s2">"development tools"</span>
<span class="linenos" data-linenos="2 "></span>$ sudo yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel <span class="se">\</span>
<span class="linenos" data-linenos="3 "></span> sqlite-devel readline-devel tk-devel gdbm-devel <span class="se">\</span>
<span class="linenos" data-linenos="4 "></span> db4-devel libpcap-devel xz-devel expat-devel
</code></pre></div>
<h3 id="download-latest-python-source-code-from-pythonorg">Download latest Python source code from Python.org<a class="headerlink" href="#download-latest-python-source-code-from-pythonorg" title="Permanent link">¶</a></h3>
<div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span>$ wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tar.xz
<span class="linenos" data-linenos="2 "></span>$ tar xf Python-3.6.6.tar.xz
<span class="linenos" data-linenos="3 "></span>$ <span class="nb">cd</span> Python-3.6.6
</code></pre></div>
<h3 id="enable-performance-optimizations-optional-but-highly-recommended">Enable performance optimizations (optional, but highly recommended)<a class="headerlink" href="#enable-performance-optimizations-optional-but-highly-recommended" title="Permanent link">¶</a></h3>
<div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span>$ ./configure --prefix<span class="o">=</span>/usr/local --enable-shared <span class="nv">LDFLAGS</span><span class="o">=</span><span class="s2">"-Wl,-rpath /usr/local/lib"</span>
<span class="linenos" data-linenos="2 "></span>$ ./configure --enable-optimizations
</code></pre></div>
<h3 id="build-and-install">Build and install<a class="headerlink" href="#build-and-install" title="Permanent link">¶</a></h3>
<div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span>$ make
<span class="linenos" data-linenos="2 "></span>$ sudo make altinstall
</code></pre></div>
<p>Now, Python 3.6.6 is ready to be used in your system; located in <code>/usr/local/bin/python3.6</code>
<div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span>$ which python3.6
<span class="linenos" data-linenos="2 "></span>/usr/local/bin/python3.6
<span class="linenos" data-linenos="3 "></span>
<span class="linenos" data-linenos="4 "></span>$ python3.6
<span class="linenos" data-linenos="5 "></span>Python <span class="m">3</span>.6.6 <span class="o">(</span>default, Jul <span class="m">10</span> <span class="m">2018</span>, <span class="m">14</span>:04:26<span class="o">)</span>
<span class="linenos" data-linenos="6 "></span><span class="o">[</span>GCC <span class="m">4</span>.8.5 <span class="m">20150623</span> <span class="o">(</span>Red Hat <span class="m">4</span>.8.5-28<span class="o">)]</span> on linux
<span class="linenos" data-linenos="7 "></span>Type <span class="s2">"help"</span>, <span class="s2">"copyright"</span>, <span class="s2">"credits"</span> or <span class="s2">"license"</span> <span class="k">for</span> more information.
<span class="linenos" data-linenos="8 "></span>>>>
</code></pre></div></p>
<p>For convenience, you can create a symbolic-link with a shorter name.
If you had system-installed Python3 (unlikely), <strong>don’t</strong> do this, as some system-components may depend on that specific older version of Python 3.
<div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span>$ sudo ln -s /usr/local/bin/python3.6 /usr/local/bin/python3
<span class="linenos" data-linenos="2 "></span>$ python3
<span class="linenos" data-linenos="3 "></span>Python <span class="m">3</span>.6.6 <span class="o">(</span>default, Jul <span class="m">10</span> <span class="m">2018</span>, <span class="m">14</span>:04:26<span class="o">)</span>
<span class="linenos" data-linenos="4 "></span><span class="o">[</span>GCC <span class="m">4</span>.8.5 <span class="m">20150623</span> <span class="o">(</span>Red Hat <span class="m">4</span>.8.5-28<span class="o">)]</span> on linux
<span class="linenos" data-linenos="5 "></span>Type <span class="s2">"help"</span>, <span class="s2">"copyright"</span>, <span class="s2">"credits"</span> or <span class="s2">"license"</span> <span class="k">for</span> more information.
<span class="linenos" data-linenos="6 "></span>>>>
</code></pre></div></p>
<h2 id="install-wheel-and-pip"><del>Install wheel and pip</del><a class="headerlink" href="#install-wheel-and-pip" title="Permanent link">¶</a></h2>
<p>You don’t need to, because <code>Python 3.6.6</code> includes these necessary tools included.
<div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span>$ pip3.6 -V
<span class="linenos" data-linenos="2 "></span>pip <span class="m">10</span>.0.1 from /usr/local/lib/python3.6/site-packages/pip <span class="o">(</span>python <span class="m">3</span>.6<span class="o">)</span>
<span class="linenos" data-linenos="3 "></span>$ wheel version
<span class="linenos" data-linenos="4 "></span>wheel <span class="m">0</span>.29.0
</code></pre></div></p>