How to Install and Use Zsh on Ubuntu

Bash has been the default login shell on Ubuntu for years, and it works fine for running scripts and one-off commands. When we spend most of the day inside a terminal, though, small details start to matter: smarter tab completion, spell correction on commands, recursive globs, and rich theming. Zsh adds those features without breaking the Bash scripts we already rely on.
This guide explains how to install Zsh on Ubuntu, set it as the default shell, configure ~/.zshrc, and bolt on the Oh My Zsh framework for plugins and themes.
Quick Reference
| Task | Command |
|---|---|
| Install Zsh | sudo apt install zsh |
| Check version | zsh --version |
| Set as default shell | chsh -s $(which zsh) |
| Reload config | source ~/.zshrc |
| List shells | cat /etc/shells |
| Switch back to Bash | chsh -s /bin/bash |
| Install Oh My Zsh | sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" |
Prerequisites
You need an Ubuntu system with a user account that has sudo privileges. The Zsh package comes from the default Ubuntu repositories, while the Oh My Zsh installer needs curl and git.
Install those helper packages if they are missing:
sudo apt update
sudo apt install curl gitInstall Zsh
Zsh is available in the default Ubuntu repositories. Refresh the package index and install it:
sudo apt update
sudo apt install zshVerify the installation by checking the Zsh version:
zsh --versionThe output looks similar to:
zsh 5.9 (x86_64-ubuntu-linux-gnu)Run Zsh for the First Time
Start Zsh without changing your default shell yet:
zshThe first launch opens the zsh-newuser-install configuration wizard. The relevant choices are:
0exits the wizard and creates an empty~/.zshrcso Zsh stops asking on every start.1continues to the interactive menu, where we can pick defaults for history, completion, key bindings, and a few other behaviors.2populates~/.zshrcwith the system-wide recommended defaults.qquits without creating a config file at all, which means the wizard runs again next time.
Pick option 0 or q if you plan to install Oh My Zsh next, since it ships its own template and will overwrite the file anyway. Otherwise, run the interactive setup to generate a sensible starting point.
Set Zsh as the Default Shell
Once you are happy with the way Zsh behaves, change the default login shell for your user:
chsh -s $(which zsh)Log out and log back in so the new shell takes effect. Confirm the change with:
echo $SHELLThe output should be /usr/bin/zsh or /bin/zsh, depending on your Ubuntu release and shell path layout.
If you prefer to keep Bash as the login shell and only run Zsh on demand, skip this step and start Zsh manually with zsh whenever you need it.
Edit ~/.zshrc
The ~/.zshrc file runs every time an interactive Zsh session starts. Open it with your editor:
nano ~/.zshrcA minimal useful starting point looks like this:
# History
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
setopt SHARE_HISTORY
setopt HIST_IGNORE_DUPS
# Completion
autoload -Uz compinit
compinit
# Aliases
alias ll='ls -lah'
alias gs='git status'
# Prompt
PROMPT='%n@%m %~ %# 'Reload the file in the current session without opening a new terminal:
source ~/.zshrcFor more on aliases, see how to create Bash aliases . The same syntax works in Zsh.
Install Oh My Zsh
Oh My Zsh is a popular framework that ships a large catalog of plugins and themes. The official installer is the most common setup path:
sh runs code from the network as your user. If you are setting up a shared or production machine, download the installer first, review it, and then run it locally.To inspect the script before running it, use:
curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -o install-oh-my-zsh.sh
less install-oh-my-zsh.sh
sh install-oh-my-zsh.shFor a quick personal workstation setup, you can run the installer directly:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"The installer clones Oh My Zsh into ~/.oh-my-zsh, backs up the existing ~/.zshrc to ~/.zshrc.pre-oh-my-zsh, and writes a new ~/.zshrc with sensible defaults.
Pick a Theme
Open ~/.zshrc and find the ZSH_THEME line. The default value is robbyrussell. Try a different theme by setting:
ZSH_THEME="agnoster"The agnoster theme uses powerline-style segments and requires a Nerd Font for the special glyphs. If you want to sample themes without installing extra fonts first, use ZSH_THEME="random" to cycle themes on every login until you find one you like.
Reload the configuration to apply the new theme:
source ~/.zshrcEnable Plugins
Plugins extend Zsh with completion definitions, shortcuts, and visual aids. Edit the plugins=() line in ~/.zshrc and add the plugins you want:
plugins=(git docker kubectl sudo zsh-autosuggestions zsh-syntax-highlighting)git, docker, kubectl, and sudo ship with Oh My Zsh. zsh-autosuggestions and zsh-syntax-highlighting are external plugins. Install them with:
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlightingReload ~/.zshrc to activate them:
source ~/.zshrczsh-autosuggestions shows a faded completion based on your history as you type. Press the right arrow key to accept it. zsh-syntax-highlighting colors valid commands green and unknown commands red, which catches typos before you press Enter.
Useful Built-in Features
Zsh ships several features that are not available in Bash without extra setup:
- Recursive glob patterns:
ls **/*.loglists every.logfile under the current directory. - Globbing qualifiers:
ls *(.)lists only regular files;ls *(/)lists only directories. - Spell correction:
setopt CORRECTprompts you to fix mistyped commands. - Sharing history across sessions in real time with
setopt SHARE_HISTORY.
Troubleshooting
chsh reports “non-standard shell”
Make sure /usr/bin/zsh is listed in /etc/shells. If it is missing, add it with echo $(which zsh) | sudo tee -a /etc/shells and run chsh again.
Zsh starts but the prompt is broken on a remote SSH session
The theme probably depends on a Nerd Font that the local terminal does not have. Switch to a simpler theme such as robbyrussell or install a Nerd Font in the terminal application.
Plugins are listed but nothing happens
Check the ZSH_CUSTOM path matches where you cloned the plugin. Run ls ~/.oh-my-zsh/custom/plugins to confirm the plugin directory exists, then reload ~/.zshrc.
Conclusion
From here we can keep tweaking ~/.zshrc to match the way we work: add aliases for repetitive commands, pin a theme that reads well in the terminal we use most, and pull in plugins as new tools enter the workflow. The alias syntax matches Bash, so existing alias workflows
carry over without changes.
Tags
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page