The Z shell is one of the most powerful shells ever developed, and it’s also one of the fastest. It includes features that you won’t find anywhere else like built-in spell checking, syntax highlighting for code, and more. You can even configure your prompt to show useful information about your system status without typing anything.

Some features you will find useful are:

  • Spelling correction
  • Tab completion for your files and commands and much more.

Check the resources for a full list of Z shell’s features.

Prerequisites

  • A fresh install of Ubuntu 20.04 on the server.
  • A non-root with root privileges is configured on the server.

Updating the System

First of all we need to update the system to make sure we have the latest software and security patches.

sudo apt-get update && sudo apt-get dist-upgrade -y
sudo apt-get install build-essential curl file git

Installing ZSH on Ubuntu

Now that your system is updated, you are all set to install ZSH with the apt command.

sudo apt install zsh

During the installation process, you will be asked if you would like to continue with the Z shell installation. Press Y and hit Enter to confirm your selection.

How to Install ZSH Shell and Oh-My-Zsh on Ubuntu 20.04 ubuntu

The command above will take some time to install. The installation process will go over the basic configuration of ZSH. You can always change these settings later, but for now, we don’t need to configure it.

Now that ZSH is installed, you can check the version number with the zsh –version command. This command will print out the version number of ZSH on the server.

The Version command is a useful way of checking which version you’re currently using but it won’t give any information if something isn’t installed or just partly installed. Your version number may be different from the one in this picture. That’s normal.

zsh --version

How to Install ZSH Shell and Oh-My-Zsh on Ubuntu 20.04 ubuntu

If you do not see the ZSH version number after executing the zsh –version command, it means that something went wrong during installation. Check your path again or try to reinstall the ZSH using this command:

sudo apt install zsh && sudo dpkg-reconfigure dash && sudo reboot

The default directory where your ZSH is installed is /usr/bin. You can confirm this by printing the location of zsh using the which command:

whereis szh

The whereis command prints out exactly what its name suggests, the path to a terminal program or script. In our case, it is the exact location of ZSH.

Installing Oh-My-Zsh Plugin

On-My-Zsh plugin provides some amazing shell enhancements to ZSH.

You can install the plugin by typing this command in your terminal:

sudo apt install git-core curl fonts-powerline
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

This command will set up Zsh as the default set shell for all users. So you don’t need to log out or reboot the server. Type Y and hit Enter to continue. The installation will complete within a few seconds.

How to Install ZSH Shell and Oh-My-Zsh on Ubuntu 20.04 ubuntu

Open your browser and go to GitHub to get a list of all available plugins.

https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins

When you’ve finished browsing the available plugins and found one you want to use, add its name to the plugin() function in the /.zshrc file to activate it.For example, to activate the python plugin, simply add the following line to the ~/.zshrc file.

plugins=(python pip)

After changing the theme, use Ctrl-O to save and Ctrl-X to exit. Then reload Oh My ZSH plugin by typing:

source ~/.zshrc

Configuring the Oh-My-Zsh Theme

The default directory for Oh-My-Zsh Theme is ~/.oh-my-zsh/themes/. You can find all the themes there.

To view the list of the available themes, open your browser and navigate to:

https://github.com/ohmyzsh/ohmyzsh/wiki/Themes

It’s not wise to use rainbow colors or other hard -to-read colors. Also the themes with white and light words on black background are not recommended for users whose vision is compromised or who use headless servers without a monitor.

You can preview the theme in your browser. Once you found a theme that you like, open the ~/.zshrc file with any code editor.

sudo nano ~/.zshrc

You can see in the screenshot above, the default theme is robbyrussel.

How to Install ZSH Shell and Oh-My-Zsh on Ubuntu 20.04 ubuntu

You can change the theme by replacing this text in the line ZSH_THEME= with the one you like. For example, if you want to set the agnoster theme as your ZSH style, you need to replace robbyrussel with agnoster.

ZSH_THEME="agnoster"

How to Install ZSH Shell and Oh-My-Zsh on Ubuntu 20.04 ubuntu

If you want to alternate between multiple themes on a regular basis, change the ZSH_THEME= parameter to random.

sudo nano ~/.zshrc
ZSH_THEME="random"

If you want to alternate between multiple themes on a regular basis with a specific set of themes, define the ZSH_THEME_RANDOM_CANDIDATES parameter with the themes you choose to use. For example, we will use agnoster, grml and robbyrussel at random.

ZSH_THEME_RANDOM_CANDIDATES=("agnoster" "grml" "robbyrussell")

How to Install ZSH Shell and Oh-My-Zsh on Ubuntu 20.04 ubuntu

After changing the theme, use Ctrl-O to save and Ctrl-X to exit. Then reload Oh My ZSH plugin by typing:

source ~/.zshrc

Configuring OH-MY-ZSH Automatic Update

OH-MY-ZSH updates automatically once in two weeks. To disable it, uncomment the DISABLE_AUTO_UPDATE and set parameter DISABLE_AUTO_UPDATE=“true” in the ~/.zshrc file.

sudo nano ~/.zshrc
DISABLE_AUTO_UPDATE="true"

How to Install ZSH Shell and Oh-My-Zsh on Ubuntu 20.04 ubuntu

You also can set the number of days for update check. For example, if you want to skip Auto Update every day, set parameter UPDATE_ZSH_DAYS=1

UPDATE_ZSH_DAYS=1

Type Ctrl-O followed by Enter to save and Ctrl-X to exit. Then reload Oh My ZSH plugin by typing:

source ~/.zshrc

You can also run the update manually by typing:

omz update

How to Install ZSH Shell and Oh-My-Zsh on Ubuntu 20.04 ubuntu

Finally, restart your system to apply the changes.

sudo reboot now

That’s it! You have successfully installed and configured OH-MY-ZSH on Ubuntu 20.04.

Uninstalling OH-MY-ZSH

For any reason, if you wish to uninstall OH-MY-ZSH and their plugins and themes from Ubuntu 20.04, simply remove the ‘oh-my-zsh’ package by typing this command in your terminal:

sudo uninstall oh_my_zsh

This command will delete all of the files and folders that came with oh-my-zsh and return the server to the state before you installed it.

Conclusion

In this tutorial, we have learned how to configure and use the Oh-My-ZSH on Ubuntu 20.04. The steps in this guide should work equally well on other Linux systems. If you have any questions or thoughts to share, feel free to leave a comment below.