AlmaLinuxRHEL Based

How To Install Zsh on AlmaLinux 9

Install Zsh on AlmaLinux 9

In this tutorial, we will show you how to install Zsh on AlmaLinux 9. For those of you who didn’t know, Zsh, short for Z Shell, is a feature-rich shell that surpasses its predecessors in terms of usability and customization. With an array of plugins, themes, and configuration options, Zsh empowers users to tailor their command line environment to perfection.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of Zsh on AlmaLinux 9. You can follow the same instructions for CentOS and Rocky Linux or RHEL-based.

Prerequisites

  • A server running one of the following operating systems: AlmaLinux 9.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for Zsh.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Zsh on AlmaLinux 9

Step 1. Before diving into the installation process, ensure your AlmaLinux 9 system is up-to-date. Run the following commands in your terminal:

sudo dnf clean all
sudo dnf update

Step 2. Installing Zsh on AlmaLinux 9.

AlmaLinux 9 uses Dnf as its package manager, making it a straightforward choice for installing Zsh. To install Zsh using Dnf, run the following command:

sudo dnf install zsh

Set Zsh as your default shell:

chsh -s /bin/zsh

To confirm that Zsh is now your default shell, log out and log back in or simply open a new terminal window. You should now be using Zsh.

Step 3. Understanding Zsh Configuration Files.

Zsh uses two primary configuration files to manage its settings:

  • ~/.zshrc

The ~/.zshrc file contains user-specific Zsh configurations, including aliases, prompts, and custom settings. This file plays a pivotal role in tailoring Zsh to your preferences.

  • ~/.zshenv

The ~/.zshenv file stores environment variables that Zsh uses. While it is less commonly customized, it’s essential to be aware of its existence.

Step 4. Customizing Zsh.

Customizing Zsh allows you to mold it into a tool that aligns perfectly with your workflow and preferences. Here are some common customizations you can apply:

  • Customizing Your Shell Prompt

One of the most noticeable changes you can make is customizing your shell prompt. Zsh offers a range of options, including various prompt themes and the ability to create your custom prompt. To customize your prompt, open ~/.zshrc with your preferred text editor:

nano ~/.zshrc

Within this file, you can adjust the PS1 variable to define your prompt. For example, you can change it to:

PS1="[\u@\h \W]\$ "

This prompt displays the username (\u), host (\h), and the current working directory (\W) in square brackets.

  • Creating Aliases

Aliases are shortcuts for frequently used commands. You can define aliases in ~/.zshrc to make your workflow more efficient. Here’s an example:

alias ll='ls -l'

Now, whenever you type ll in your terminal, it will be equivalent to running ls -l.

  • Adding Plugins

Zsh’s plugin system extends its functionality. Popular frameworks like Oh-My-Zsh (which we’ll cover shortly) provide a vast selection of plugins. To add plugins, you’ll typically update your ~/.zshrc file. For example, to enable the git plugin:

plugins=(git)

After making changes to ~/.zshrc, save the file and apply the changes without restarting your shell:

source ~/.zshrc

With these customizations in place, your Zsh shell will become a personalized and powerful tool tailored to your preferences and needs.

Step 5. Installing Oh-My-Zsh.

To install Oh-My-Zsh, execute the following command:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

This command downloads and runs a script that installs Oh-My-Zsh. Once the installation is complete, you can start exploring its themes and plugins.

Congratulations! You have successfully installed Zsh. Thanks for using this tutorial for installing Zsh on your AlmaLinux 9 system. For additional help or useful information, we recommend you check the official Zsh website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button