How to set up ZSH and Oh-my-zsh on Linux

How to set up ZSH and Oh-my-zsh on Linux

Z Shell or zsh is an interactive UNIX Shell, a powerful command line interpreter for scripting languages ​​(including Shell scripts). Zsh was developed by “Paul Fastad” since 1990, and the name of “zsh” comes from Professor Zong Shao of Yale University.

Z-Shell has become one of the most popular shells of the Linux operating system. It has rich functions and is easy to configure and customize. The following are some important zsh functions:

  • Command completion
  • Improved variable handling
  • Spelling correction
  • Shared command history
  • Kill tab completion
  • Environment variables are easy to set
  • Customizable

My goodness

Oh-my-zsh is an open source framework for managing Z Shell (Z Shell). The Z shell also has other frameworks, such as prezto, Zgen, Antigen, etc. In this tutorial, we use “oh-my-zsh” for zsh configuration.

Oh-my-zsh is a community-based framework with many functions. It comes with a customizable design and has a large catalog of plugins for system administrators and developers.

In this tutorial, we show you how to install Z-Shell or zsh under Ubuntu Linux and CentOS . Then, we configure the oh-my-zsh framework to manage zsh. We will also show you how to change the zsh theme and activate the plugin.


  • Linux-Ubuntu 20.04 or CentOS 8
  • Root privilege

What are we going to do

  1. Install and configure ZSH
  2. Install and configure the Oh-my-zsh framework
  3. Change the default theme
  4. Enable oh-my-zsh plugin

Step 1-install and configure ZSH

In this step, we will install Z Shell from the repository and then configure the user to use Z Shell as the default theme. Basically, the default shell on Ubuntu and CentOS is bash, so we will configure a root user to use zsh as the default shell.

To install zsh from the repository, use the following command.

On Ubuntu:

                        apt install zsh

On CentOS:

                        dnf install zsh

After the installation is complete, use the following chsh command to change the default shell of the root user to zsh.

On Ubuntu:

                        chsh -s /usr/bin/zsh root

On CentOS:

                        chsh -s /bin/zsh root

Now log out from the root user, log in again, and you will get a zsh shell.

Use the following command to check the currently used shell.

                        echo $SHELL

The output should be zsh. This is the result on Ubuntu.

This is the result on CentOS.

Change Shell to zsh on centOS

Z shell zsh is installed.

Step 2-Install and configure the Oh-my-zsh framework

Therefore, Z shell is now installed on the system. Next, we have to install the oh-my-zsh framework to manage the Z shell zsh. Oh-my-zsh provides an installer script for installing the framework. We need to install some other necessary packages, including wget for downloading the installer script from GitHub and the oh-my-zsh shell for downloading from GitHub Git.

Therefore, the first step is to install wget and git on the system. This is the command you need to run:

On Ubuntu:

                        apt install wget git

On CentOS:

                        dnf install wget git

Now download and execute the installer script.

                        wget -O - | zsh

The result/output should be similar to the one shown below.

nstall Oh-my-zsh

Therefore, oh-my-zsh is installed in the home directory “~/.oh-my-zsh”.

Next, we need to create a new configuration for zsh. As with the Bash shell, for zsh, its configuration is named “.bashrc” and we need a “.zshrc” configuration file. Available in the oh-my-zsh template directory.

Copy the template .zshrc.zsh-template configuration file to the main directory .zshrc and apply the configuration by running the source command, as shown below.

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

Oh-my-zsh is now installed on the system, and the Z shell is configured to use the oh-my-zsh framework and has a default configuration.

The following results are on Ubuntu.

Oh-my-zsh installation on Ubuntu

This is what you see on CentOS.

Install Oh-my-zsh on CentOS

Step 3-change the default theme

The default .zshrc configuration provided by oh-my-zsh uses the “robbyrusell” theme. In this step, we will edit the configuration and change the default theme.

The Oh-my-zsh framework provides many topics for zsh shell, please go to the link below to see the available options.

Alternatively, you can go to the “Themes” directory and view the list of available themes.

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

zsh theme list

In order to change the default theme, we need to edit the .zshrc configuration file. Use the vim editor to edit the configuration.

                        vim ~/.zshrc

Choose a zsh theme-say “risto” theme.

Then, change the “ZSH_THEME” line 10 to the “risto” theme as shown below.


Save and exit.

Now, reload the configuration .zshrc and you will see that the’risto’ theme is currently used as your shell theme.

                        source ~/.zshrc

The result on Ubuntu.

Reload configuration .zshrc on Ubuntu

The result on CentOS.

Reload the configuration .zshrc on CentOS

Therefore, you can apply the new oh-my-zsh theme.

Step 4-enable Oh-my-zsh plugin

Oh-my-zsh provides great plugins. Our environment has many plugins for developers, system administrators and everyone else.

The default plugins are located in the “plugins” directory.

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

List available zsh plugins

In this step, we will use the’oh-my-zsh’ framework to adjust zsh by enabling certain plugins. In order to enable the plugin, we need to edit the .zshrc configuration file.

Edit the .zshrc configuration file.

                        vim ~/.zshrc

Go to line 54 of “Plugins” and add some plug-ins you want to enable within brackets (). For example, this is the change I made in the situation:

                      plugins=(git extract web-search yum git-extras docker vagrant)

Here are the results when using the “Extract” plugin-you can use the “Extract” command to extract zip and tar files.

Install zsh decompression plugin

Yum Commands-only contains Yum information for “yp” commands.

yum command information

Vagrant plugin for automatic command completion.

zsh vagrant plugin

In short, Z shell and oh-my-zsh framework have been installed. In addition, after enabling certain plug-ins, the default theme of oh-my-zsh has also been changed.


Related Posts