How To Install ZSH & OH MY ZSH on Ubuntu & CentOS

Learn how to install and configure zsh and oh my zsh in CentOS 7 or Ubuntu.

In the Linux world, we have the opportunity to install and configure thousands of options to expand the capabilities of the equipment for free thanks to being free code.

One of these options is the Shell Z, also called ZSH, which has its origins in the year 1990 and since then has been used as one of the best command line interpreters for UNIX which supports the scripting language.

Now, another of the best-known shell for Linux is Oh my zsh which has been designed as a framework capable of managing ZSH.

By using Oh my zsh we have benefits like:

  • It has more than 200 accessories
  • Includes more than 900 themes
  • Supports multiple languages such as PHP, PostgreSQL, Python, Scala, Django and more.

Today I will explain in depth how to install and configure these two Shell in CentOS 7 to have one more level of server scalability.

Previous requirements:

  • CentOS 7, or Ubuntu 16.04 & Higher.
  • Root Privileges.

Step 1: Install & Configure ZSH

For this case, we will install the Z shell from the official repository and then configure a user to use the Z shell as the default theme.

Basically, the default shell in Ubuntu and CentOS is bash, so we'll configure a root user to use zsh as the default shell.

In the case of using CentOS 7 we will execute the following command:

yum install zsh

If we use Ubuntu 16 or 17 we can run the following command for the installation of zsh:

apt install zsh

Step 2: ZSH Settings

Once the installation process is complete, we can change the default shell of the root user to zsh with the chsh command as follows:

In CentOS 7

chsh -s /bin/zsh root

On Ubuntu

which zsh

Now we can close the session from the root user, we will log in again and we will obtain the zsh shell: We will
check the current shell by executing the following command.

echo $SHELL

Step 3: Install & Configure Oh my zsh

With the Z shell installed on the system, the next step is to install the Oh my zsh framework to manage Z shell zsh.

Oh my zsh provides an installer script to install the framework, and we need to install some other necessary packages, including wget to download the installer script and Git to download the Oh my zsh shell from GitHub.

The first step is to install wget and git in the system, we will execute the following commands for it:

In CentOS 7

yum install wget git

On Ubuntu

apt install wget git

Once installed, we proceed to download the installer script and run it using the next line:

wget -O - | zsh

With this we have installed Oh my zsh in ~ / .oh-my-zsh.

We will copy the template configuration file .zshrc.zsh-template in the .zshrc home directory and apply the configuration by executing the source command, as follows:

cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
source ~/.zshrc

OH MY ZSH Theme Settings

The default configuration of .zshrc provided by Oh my zsh is using the ‘robbyrusell' theme.

In this step, we will edit the configuration and change the default theme.

The Oh-my-zsh framework provides many themes for your zsh shell, we can go to the following link to see more available options:

Another option is to go to the directory of themes of the application by executing the following lines:

cd ~/.oh-my-zsh/themes/
ls -a

To edit the theme we go to the next directory using nano:

nano ~/.zshrc

There we will place the line “ZSH_THEME” and we will specify the desired theme:


Save the changes using the following key combination Ctrl + O and exit the editor using Ctrl + X.

We can reload the configuration using:

source ~/.zshrc.

So we have the option to install and configure these two tools in Linux to give a new functionality to the system.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *