How to Install Zsh in Ubuntu 22.04

In Ubuntu, the default shell is “bash”, but the good thing about Ubuntu is that it allows users to install and use other shells as well. The Zsh is the advanced form of the Bourne shell, and compared to Zsh, it provides different features to its users which are not available in the Bash shell. For example, it auto-corrects minor mistakes in typing and allows its users to navigate different directories by typing the directory name instead of the “cd” command.

In this blog, the installation method of Zsh will be discussed for Ubuntu 22.04 (codenamed Jammy Jellyfish).

How to Install Zsh in Ubuntu 22.04?

This section explains the important steps to install Zsh on Ubuntu 22.04. Let’s start:

Step 1(Optional): Locate the Zsh Utility

This is an optional step where you can locate the available version of “Zsh” on Ubuntu’s repository list:

$ apt show zsh

It can be seen that “5.8.1-1” version of zsh is available in the repository of Ubuntu.

Step 2: Install Zsh

To install the available version on Ubuntu 22.04, use the following command:

$ sudo apt install zsh -y

Step 3: Install Configuration Tool of Zsh

After the installation of Zsh in Ubuntu, the configuration tool of Zsh “oh-my-zsh” will be installed with the command:

$ sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

It will ask the permissions to set the Zsh to the default shell in the machine:

Type “y” to allow it:

The shell is switched from bash to Zsh.

Step 4: Test Zsh Shell

Let’s update all the packages while using the “Zsh”:

$ sudo apt update

To find out the zsh shell directory, run the command:

which zsh

To switch the bash shell from the zsh shell, use the command:

exec bash

Similarly, the “exec zsh” will switch the shell from bash to zsh.

Removing Zsh From Ubuntu 22.04

If you want to remove the zsh utility from Ubuntu 22.04, use the below-stated command:

$ sudo apt purge zsh -y

The “Zsh” package is uninstalled and also removed from Ubuntu with all its configuration files and data.

That’s all from this guide!

Conclusion

To install Zsh in Ubuntu 22.04, open the terminal and execute the command “sudo apt install zsh -y”. You can switch between zsh and bash shells using the “exec <shell-name>”. This post has briefly explained the installation method of Zsh on Ubuntu 22.04.