How to Install and Use Zsh on Ubuntu
Learn how to install and use zsh on ubuntu with Oh My Zsh framework, zsh-autosuggestions, syntax highlighting, and custom terminal themes.

5 min read
Learn how to install and use zsh on ubuntu with Oh My Zsh framework, zsh-autosuggestions, syntax highlighting, and custom terminal themes.
- Prerequisites and Supported Releases
- Step 1: Installing Zsh and Prerequisite Packages
- Step 2: Setting Zsh as Your Default Login Shell
The default command shell on Ubuntu is Bash (Bourne Again SHell), a battle-tested and reliable tool for general system administration.
However, developers and system administrators who spend hours every day inside a terminal shell frequently seek productivity enhancements.
Zsh (Z Shell) is an advanced interactive shell designed with powerful autocomplete algorithms, intelligent path expansion, spelling correction, and extensive plugin capabilities.
When paired with the popular open-source Oh My Zsh framework, Zsh transforms the Linux command line into a modern, customizable development environment.
In this guide, we walk through how to install and use zsh on ubuntu, set it as your default login shell, install themes, and enable high-productivity plugins.
Complete step-by-step developer tutorial for installing, configuring, and mastering Zsh (Z Shell) on Ubuntu 24.04 LTS and 22.04 LTS. Covers setting Zsh as your default user shell with chsh, installing the Oh My Zsh community framework, enabling intelligent autosuggestions and syntax highlighting plugins, and tuning performance.
Prerequisites and Supported Releases
This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat) & Ubuntu 22.04 LTS. The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.
Before proceeding, ensure you have the following requirements satisfied:
- A computer or server running Ubuntu 24.04 LTS or Ubuntu 22.04 LTS.
- An unprivileged user account with
sudoadministrative privileges. - Git and curl installed on the system.
- Access to a terminal window or SSH session.
Step 1: Installing Zsh and Prerequisite Packages
Ubuntu repositories package Zsh natively in the main component.
First, refresh your local package index, then install zsh along with curl and git:
# Update package index:
sudo apt update
# Install Zsh, Git, and Curl:
sudo apt install -y zsh git curl
# Verify installed Zsh version:
zsh --version
# Expected output: zsh 5.9 (x86_64-ubuntu-linux-gnu)
Step 2: Setting Zsh as Your Default Login Shell
Installing Zsh does not automatically replace Bash as your default login shell.
Use the chsh (change shell) utility to update your user account record in /etc/passwd:
Specify the absolute path to the Zsh binary (/bin/zsh or /usr/bin/zsh):
# Identify the binary path of Zsh:
which zsh
# Output: /usr/bin/zsh
# Change the default shell for the CURRENT user (NO sudo!):
chsh -s $(which zsh)
# Confirm that /etc/passwd reflects the new default shell:
grep $USER /etc/passwd
# Output: sysadmin:x:1001:1001:sysadmin,,,:/home/sysadmin:/usr/bin/zsh
Activating Your New Shell Session
Log out of your terminal session and log back in, or launch Zsh directly in your current session by typing zsh:
# Launch Zsh immediately:
zsh
# Verify the active running shell environment variable:
echo $SHELL
# Output: /usr/bin/zsh
Step 3: Installing the Oh My Zsh Framework
Oh My Zsh is a community-driven framework for managing your Zsh configuration with hundreds of plugins and themes.
Run the automated installation script via curl from your terminal:
# Install Oh My Zsh via official automated script:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# Expected confirmation ASCII banner:
# ____ / /_ ____ ___ __ __ ____ _____/ /_
# / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \
# / /_/ / / / / / / / / / / /_/ / / /_(__ ) / / /
# \____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/
# /____/
Step 4: Configuring Themes and Productivity Plugins
The main Zsh user configuration file resides at ~/.zshrc.
Two essential plugins that dramatically accelerate terminal productivity are zsh-autosuggestions (which suggests commands as you type based on your history) and zsh-syntax-highlighting (which highlights valid commands in green and errors in red).
Clone both plugins into the custom plugin directory:
# Clone zsh-autosuggestions plugin:
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# Clone zsh-syntax-highlighting plugin:
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
Enabling Plugins in ~/.zshrc
Open ~/.zshrc and update the plugins=(...) array to enable your installed extensions:
Remember that zsh-syntax-highlighting must always be the last plugin in the list:
# In ~/.zshrc, update the plugins line:
plugins=(
git
sudo
copypath
copyfile
zsh-autosuggestions
zsh-syntax-highlighting
)
# Apply configuration changes immediately:
source ~/.zshrc
Practical Zsh Productivity Features and Shortcuts
Zsh introduces several powerful command-line features that make navigation significantly faster than standard Bash:
Review this summary of daily productivity shortcuts enabled in Zsh:
| Feature / Shortcut | Zsh Behavior | Example Usage |
|---|---|---|
| Tab Completion Menu | Interactive arrow-key navigation through directories and flags | Type cd /v/w/ and press Tab to expand to /var/www/ |
| Spelling Auto-Correction | Prompts with suggested corrections for mistyped commands | Type sl -> prompts correct 'sl' to 'ls' [nyae]? |
| Directory Auto-Jump | Type directory name directly without the cd command | Type /etc/nginx and press Enter |
| Double-Esc for Sudo | Press Esc twice to prepend sudo to current or previous command | Quickly elevate forgotten sudo commands |
Step 5: Configuring Custom Aliases and Reverting to Bash
You can configure shell shortcuts and environment variables by adding custom alias definitions directly at the bottom of your ~/.zshrc file.
Add time-saving command aliases for common administrative operations:
If you ever need to revert your default login shell back to Bash, invoke chsh again with the path to the Bash executable:
# Add custom aliases to ~/.zshrc:
cat << 'EOF' >> ~/.zshrc
# Useful sysadmin aliases:
alias ll='ls -lah --color=auto'
alias update='sudo apt update && sudo apt upgrade -y'
alias ports='sudo ss -tulpn'
EOF
# Apply updated aliases:
source ~/.zshrc
# To revert your default login shell back to Bash at any time:
chsh -s /bin/bash
Troubleshooting and Common Errors
When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:
chsh: PAM: Authentication failure
Cause: Entering the wrong user password when invoking chsh.
Resolution: Ensure you enter your current user's password, or change the shell with root privileges: sudo chsh -s /bin/zsh username.
sudo chsh -s $(which zsh) $USER
Corrupted characters or question marks in prompt theme
Cause: The active theme requires a Powerline or Nerd Font that is not installed on your client terminal.
Resolution: Switch to a non-font-dependent theme like ZSH_THEME="robbyrussell" or install a Nerd Font (e.g. MesloLGS NF) on your local terminal.
sed -i 's/ZSH_THEME=".*"/ZSH_THEME="robbyrussell"/' ~/.zshrc && source ~/.zshrc
Slow terminal startup with Oh My Zsh
Cause: Too many active plugins or slow Git status parsing on large repositories.
Resolution: Disable unnecessary plugins in ~/.zshrc and benchmark startup using time zsh -i -c exit.
time zsh -i -c exit
Security Best Practices and Hardening
Always inspect external shell installation scripts before piping them into sh or bash.
Avoid storing plaintext passwords or sensitive API tokens directly in ~/.zshrc; use external environment files with restricted permissions.
Regularly update Oh My Zsh and plugins by running omz update.
Related Ubuntu Tutorials and Documentation
Deepen your Linux system administration skills with our related production-tested guides:
- Initial Server Setup on Ubuntu 24.04 LTS — Configure user accounts, SSH keys, and security baselines.
- How to Create a Sudo User on Ubuntu — Manage non-root user shells and administrative privileges.
- How to Install Ansible on Ubuntu 24.04 and Write Your First Playbook — Automate shell setup and developer workstations with Ansible.
Authoritative References and Official Documentation

The Linux Command Line, 2nd Edition: A Complete Introduction
Frequently Asked Questions
Quick answers to common questions and configurations
#!/bin/bash). Ubuntu always executes those scripts with /bin/bash regardless of your interactive login shell.chsh -s /bin/bash in your terminal and log out. Your default shell will immediately return to standard Bash.omz update in your terminal. It pulls the latest upstream commits from GitHub and updates your installation automatically.~/.zshrc, add the line: [ -f ~/.bash_aliases ] && source ~/.bash_aliases to inherit all your existing aliases.Editorial Disclosure: Website Vidya is supported by our readers. When you purchase hosting, tools, or software through our verified partner links, we may earn an affiliate commission at no extra cost to you. We only recommend solutions we trust and rigorously verify.
Rajesh Ray
I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.
Most Read Guides
TrendingUbuntu Server Not Booting? 10 Simple Steps to Fix It Fast
How to Create a 3D Button in HTML and CSS: Easy Steps
How to Install Python and Pip on Ubuntu 24.04 LTS
How to Install Nginx on Ubuntu 24.04
How to Install Python on Ubuntu 24.04 LTS
Related Technical Guides
Tested runbooks, server administration walkthroughs, and troubleshooting guides
Join the Conversation & Perspective
Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.
No comments on this guide yet. Be the first to share your thoughts or ask a question!