How To Install Zsh (Z Shell) on Ubuntu 24.04

Introduction
Zsh (Z Shell) is a powerful and feature-rich command-line interpreter designed as an extension of the Bourne shell (sh), incorporating features from bash, ksh, and tcsh. It offers improved scripting capabilities, enhanced customization, and an intuitive user experience, making it a preferred choice for many developers and system administrators.
In this guide, we’ll explore what Zsh is, its benefits, and how to install and customize it on Ubuntu. Here’s a step-by-step guide on how to install and configure Zsh (Z Shell) on Ubuntu.
- Update Your System
- Install Zsh
- Change the Default Shell to Zsh
- Configure Zsh (First-Time Setup)
- Install Oh My Zsh (Optional but Recommended)
- Customize Zsh
- Install Additional Plugins (Optional)
- Restart and Enjoy Zsh
The detail step will be explained briefly on the next sub topic.
Step 1: Update Your System
Before installing Zsh, it’s a good practice to update the package list:
sudo apt update && sudo apt upgrade -y
Step 2: Install Zsh
Run the following command to install Zsh:
sudo apt install zsh -y

Once the installation is complete, verify the installed version:
zsh --version
Output :
ramansah@bckinfo:~$ zsh --version
zsh 5.9 (x86_64-ubuntu-linux-gnu)

Step 3: Change the Default Shell to Zsh
To make Zsh your default shell, use folowing command :
chsh -s $(which zsh)
After running the command, restart your terminal or log out and log back in. To verify that Zsh is now your default shell, run:
echo $SHELL
It should output /usr/bin/zsh
.
Step 4: Configure Zsh (First-Time Setup)
The first time you run Zsh, it will ask for initial configuration. You can type 1
to create a .zshrc
configuration file. To start Zsh, simply type:
zsh

Step 5: Install Oh My Zsh (Optional but Recommended)
Oh My Zsh is a powerful Zsh framework that enhances the shell experience with themes and plugins.
Install Oh My Zsh using curl:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Or using wget:
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Once installed, restart your terminal to see the Oh My Zsh theme applied.

Step 6: Customize Zsh
Edit the .zshrc
file to change the Oh My Zsh theme:
vi ~/.zshrc
Find the line:
ZSH_THEME="robbyrussell"
Change "robbyrussell"
to any other theme, like "agnoster"
:
ZSH_THEME="agnoster"
Save the file and apply changes:
source ~/.zshrc
#Enable Plugins
You can also enable plugins in .zshrc
:
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
Step 7: Install Additional Plugins (Optional)
Enhance your Zsh experience with plugins:
zsh-autosuggestions (Command suggestions based on history):
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
zsh-syntax-highlighting (Syntax highlighting in terminal):
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
After installation, add the plugin names to the plugins=()
section in ~/.zshrc
and apply changes:
source ~/.zshrc
Step 8: Restart and Enjoy Zsh
Restart your terminal or log out and log back in to fully apply the changes. You now have Zsh installed and customized on Ubuntu!
Conclusion
On this short tutorial we have learned how to install Z Shell (zsh) on Ubuntu 24.04 LTS operating system.