How To Install Zsh on Ubuntu- [2 Easy Ways]

To install Zsh on Ubuntu is a strong option because Ubuntu’s package ecosystem provides a stable, well-maintained build of Zsh that integrates cleanly with the system’s shell infrastructure. Zsh delivers advanced interactive features such as programmable completion, extended globbing, command correction, and customizable prompts that significantly improve productivity compared to Bash.

2 Ways to Install Zsh on Ubuntu

This guide will discuss two methods for installing Zsh on Ubuntu, along with the installation of Oh My Zsh, which is primarily used to add features such as auto-suggestion, syntax highlighting, and themes. Here, this guide will only install the auto-suggestion and syntax highlight features.

Method 1: Through Ubuntu Default Package Installer

To install Zsh via apt, it is recommended to upgrade the applications installed via apt to the latest versions and update the apt packages list on Ubuntu. Furthermore, execute the following command to install zsh:

sudo apt-get install zsh -y

Installing Zsh on Ubuntu via apt

Verify the Zsh installation by checking its version by executing:

zsh --version

Verifying Zsh version on Ubuntu to check its installation.

Method 2: Through Zsh Source File

An alternative method to install Zsh on Ubuntu is by using its source file, which is available on SourceForge. Typically, installing an application from its source file is beneficial, as it provides maximum control, the latest versions, performance optimisation, and customisation options. To download the Zsh source file, visit the Zsh download page:

Downloading Zsh source file on Ubuntu

Next, extract the tar file for Zsh using the tarball utility by executing:

sudo tar -xf zsh-5.9.tar.xz

Extracting Zsh source file on Ubuntu

Now, execute the configuration file for zsh, which will primarily prepare the build environment and create instructions for compilation:

sudo ./configure

preparing the build environment and creating instructions for compilation of zsh source file on Ubuntu

Next, run the make command that converts source code to executable files by reading the Makefile created by ./configure:

sudo make

Converting source code to executable files by reading the Makefile for Zsh on ubuntu

In the last step, install the compiled program for zsh using the make utility:

sudo make install

Installing the compiled program for zsh on Ubuntu via make utility

Next, run the version command to verify the installation of Zsh:

zsh --version

Verifying Zsh version on Ubuntu to check its installation.

Getting Started With Zsh on Ubuntu

On the first startup, Zsh comes with some configuration steps as it lists several different options. Execute the following command to start Zsh:

zsh

For beginners, opt for option (2) as it auto-generates a default .zshrc containing the system’s recommended Zsh configuration. It initialises core shell behaviours history handling, key bindings, prompt setup, and basic environment settings without requiring manual file creation. This provides a stable, functional Zsh runtime environment immediately, making it the most efficient starting point for new users who need a ready-to-use configuration that can be customised later:

Z shell configuration function setup on Ubuntu for new users

Furthermore, to manually load the wizard function, execute the following command in Zsh:

autoload -U zsh-newuser-install
zsh-newuser-install -f

Installing Oh My Zsh on Ubuntu

Oh My Zsh is primarily a framework that provides different utilities to Zsh, or in other words, it’s more like a customisation framework for Zsh. To install oh my zsh, download and execute its bash file in Zsh by using the following command:

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

Installing Oh My Zsh on ubuntu

Here, two prompts pop up while installing, one is for overwriting it with Oh My Zsh template and the other is for making it the default shell:

Installing Oh My Zsh on Ubuntu

Enabling auto-suggestion on Zsh

There are various plugins that Oh My Zsh provides for Zsh to add extra functionality, such as auto-suggestion. This basically suggests commands based on the input. To install this plugin, execute the following command:

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

Installing auto suggestions plugin for Zsh on Ubuntu

Once the installation is completed, add it to the .zshrc file in the plugins=(git) code line:

nano ~/.zshrc
zsh-autosuggestions

Adding auto-suggestion plugin in .zshrc file on Ubuntu

Here, in the image below, I am writing the update command, and it is already suggesting it, so by pressing the right arrow key, the whole command is entered, saving a lot of time:

Illustrating auto suggestion feature in Oh My Zsh on Ubuntu

Enabling Syntax Highlight on Zsh

Another necessary plugin, Oh My Zsh provides highlighting of incorrect commands by simply changing their color. This is quite helpful, especially for beginners who are not familiar with commands. To add the feature of highlighting of syntax, execute the following command:

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

Installing zsh syntax highlighting on Ubuntu via git clone

Next, add the plugin name in the .zshrc file in the plugins=(git) code line:

nano ~/.zshrc
zsh-syntax-highlighting

Adding zsh syntax hightlight plugin in .zshrc file on Ubuntu

Here, for illustration, I have incorrectly written the update command, and it highlights the issue in the command. Moreover, there is a disclaimer that if I misspell both apt and update, it only highlights ap, not the next word:

Illustrating syntax highlight feature in Oh My Zsh on Ubuntu

Conclusion

This guide discussed two ways to install Zsh on Ubuntu, along with the Oh My Zsh framework that adds extra functionality to it. The two methods include using the apt package installer and the other involves using the Zsh source file.

 

Index
Scroll to Top