The Z shell is one of the most powerful shells ever developed, and it's also one of the fastest. It offers features you won't find anywhere else, such as built-in spell-checking, syntax highlighting for code, and much more. You can even configure the command prompt to display helpful information about your system status without having to type 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.
What is ZSH?
ZSH, or Z-Shell, is an advanced Unix shell for Linux/Unix systems, enhancing user experience with features like better scriptability, completion options, and theme support, making command-line interaction more efficient and user-friendly.
Prerequisites
- A fresh install of Ubuntu 22.04 or Ubuntu 20.04 on the server.
- A non-root with root privileges is configured on the server.
Updating the System
First, we need to update the system to ensure we have the latest software and security patches.
sudo apt update && sudo apt dist-upgrade -y

sudo apt 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
You will be asked if you would like to continue with the Z shell installation during the installation. Press Y and hit Enter to confirm your selection.

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 them.
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

If you do not see the ZSH version number after executing the zsh --version command, something went wrong during installation. Recheck your path 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.

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 the 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 a 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, that the default theme is robbyrussel.

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"

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")

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"
![]()
You also can set the number of days for the 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

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 install it.
Frequently Asked Questions
Here are some answers to frequently asked questions that users asked me about ZSH.
What is ZSH Shell?
ZSH (Z-Shell) is an advanced, interactive shell for Unix systems, known for its improvements over the standard bash shell, including features like advanced tab completion, theme support, and scripting enhancements.
How do I install ZSH on Ubuntu?
To install ZSH on Ubuntu, use the command `sudo apt-get install zsh`. This will download and install ZSH from the Ubuntu package repository.
How do I set ZSH as my default shell?
After installing ZSH, make it your default shell by running `chsh -s $(which zsh)`. You'll need to log out and back in for the change to take effect.
What are ZSH themes and how can I use them?
ZSH themes change the appearance of your command prompt. You can use them by configuring the `.zshrc` file, often using a framework like Oh-My-Zsh which offers numerous themes.
How does ZSH improve autocomplete features?
ZSH enhances autocomplete by providing more intelligent and context-aware suggestions, including options for commands, file names, and more. It's more intuitive and faster than traditional bash autocompletion.
Can I use bash scripts with ZSH?
Yes, ZSH is largely compatible with bash scripts. However, for complex scripts, there might be slight differences in behavior due to advanced features in ZSH.
What is Oh-My-Zsh and how does it relate to ZSH?
Oh-My-Zsh is a popular framework for managing ZSH configuration. It includes a rich collection of themes, plugins, and helper tools to enhance the ZSH experience.
How can I customize my ZSH environment?
Customize ZSH by editing the `.zshrc` file in your home directory. You can set options, aliases, themes, and more in this configuration file.
Is ZSH better than bash?
"Better" depends on user preference and needs. ZSH offers more advanced features and customization options compared to bash, making it popular among power users.
Are there any GUI-based configuration tools for ZSH?
While most ZSH configuration is done via text files, there are GUI-based tools like ZSH Configurator and Oh My Zsh's online theme selector for ease of setup and customization.
Conclusion
This tutorial taught us how to configure and use the Oh-My-ZSH on Ubuntu. 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.