Zsh (Z Shell) provides smarter tab completion, persistent command history across terminal sessions, and a plugin ecosystem that simplifies daily command-line tasks. Developers use it for Git-aware prompts, system administrators rely on it for powerful globbing patterns, and power users customize it with themes that display real-time directory and repository status. This guide walks through installing Zsh on Ubuntu, setting it as your default shell, configuring the initial settings, and optionally enhancing it with Oh My Zsh and popular plugins for auto-suggestions and syntax highlighting.
Choose Your Zsh Setup Method
Zsh is available in Ubuntu’s default repositories, making installation straightforward. The setup complexity depends on how much customization you want:
| Method | Channel | Includes | Best For |
|---|---|---|---|
| Basic Zsh | Ubuntu Repos | Core shell with built-in features | Users who want a better shell without plugins |
| Zsh + APT Plugins | Ubuntu Repos | Core shell plus distro-packaged plugins | Users who prefer system package management |
| Zsh + Oh My Zsh | Oh My Zsh GitHub | Framework with 300+ plugins and themes | Users who want extensive customization |
These steps cover Ubuntu 26.04 LTS, 24.04 LTS, and 22.04 LTS. Zsh and plugin packages are available in Ubuntu’s default repositories across all supported releases, and commands are identical regardless of your specific Ubuntu version.
For most users, the Oh My Zsh setup offers the best experience because it provides a curated framework for managing themes and plugins with frequent upstream updates. If you prefer distro-managed packages or want minimal external dependencies, the APT plugins method provides auto-suggestions and syntax highlighting without third-party install scripts.
Install Zsh
Update your package index and install Zsh from Ubuntu’s default repositories:
sudo apt update
sudo apt install zsh -y
Verify the installation by checking the installed version:
zsh --version
Example output on Ubuntu 26.04 and 24.04:
zsh 5.9 (x86_64-ubuntu-linux-gnu)
On Ubuntu 22.04, the output shows an earlier version:
zsh 5.8.1 (x86_64-ubuntu-linux-gnu)
Run the Initial Configuration Wizard
The first time you start Zsh without a ~/.zshrc file, it launches a configuration wizard. If you already ran through the wizard or if a .zshrc file exists, Zsh skips directly to the shell prompt.
Start Zsh manually to trigger the wizard:
zsh
The wizard presents several options for creating your initial configuration:
- Press q: Exit without creating a configuration file. The wizard will appear again the next time you start Zsh.
- Press 0: Create an empty
~/.zshrcfile. Choose this if you want complete control or plan to install Oh My Zsh, which provides its own template. - Press 1: Open the main menu to configure history, completion, key bindings, and other settings interactively. Each submenu explains the options and lets you preview the generated configuration.
- Press 2: Create a
~/.zshrcwith recommended defaults. This is the quickest option for most users who want a working configuration immediately.
If you plan to install Oh My Zsh later, any option works. The framework backs up and replaces the configuration file during installation. For a standalone Zsh setup without Oh My Zsh, option 2 provides sensible defaults including command history and basic completion.
Set Zsh as Default Shell
Use the chsh command to change your login shell to Zsh:
chsh -s $(which zsh)
Enter your password when prompted. The change takes effect after you log out and log back in, or you can start a new terminal session immediately with:
zsh
After logging out and back in, verify Zsh is your default shell:
echo $SHELL
Expected output:
/usr/bin/zsh
Install Plugins via APT (Optional)
Ubuntu packages two popular Zsh plugins in its default repositories. This method provides system-managed updates through APT without requiring manual Git cloning or third-party install scripts:
sudo apt install zsh-autosuggestions zsh-syntax-highlighting -y
APT-packaged plugin versions may be slightly older than the upstream Git repositories. For example, Ubuntu 22.04 and 24.04 include zsh-autosuggestions 0.7.0, while the upstream repository offers 0.7.1+. The functionality is nearly identical; the APT method prioritizes stability and simplicity over cutting-edge features.
These packages install to /usr/share/ and must be sourced in your configuration file. Add the following lines to ~/.zshrc:
echo 'source /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh' >> ~/.zshrc
echo 'source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh' >> ~/.zshrc
Apply the changes immediately:
source ~/.zshrc
You can also open a new terminal window instead, which loads the updated configuration automatically.
How the Plugins Work
Auto-suggestions display commands from your history as faded text while you type. Press the right arrow key or End to accept the full suggestion, or press Ctrl+Right Arrow to accept one word at a time. This significantly speeds up repetitive command entry.
Syntax highlighting colors your command line in real time: valid commands appear green, unknown commands appear red, and file paths change color based on whether the file exists. This prevents typos before you press Enter.
Install Oh My Zsh (Optional)
Oh My Zsh is a community-driven framework that simplifies Zsh configuration with 300+ bundled plugins and 150+ themes. The framework requires Git and either curl or wget.
Install Prerequisites
Ensure Git is installed on Ubuntu before running the installer:
sudo apt install git curl -y
Run the Installer
Download and execute the Oh My Zsh installation script:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
The script backs up your existing ~/.zshrc to ~/.zshrc.pre-oh-my-zsh and creates a new configuration file. If prompted to change your default shell, enter y if you skipped that step earlier.
If the installer times out or fails to connect, some countries block
raw.githubusercontent.com. Use the mirror URL instead:sh -c "$(curl -fsSL https://install.ohmyz.sh)"
Example output:
Looking for an existing zsh config...
Found ~/.zshrc. Backing up to ~/.zshrc.pre-oh-my-zsh
Using the Oh My Zsh template file and adding it to ~/.zshrc.
__ __
____ / /_ ____ ___ __ __ ____ _____/ /_
/ __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \
/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / /
\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/
/____/
Oh My Zsh is now installed!
Enable Popular Plugins
Oh My Zsh manages plugins through the plugins array in ~/.zshrc. Clone the auto-suggestions and syntax highlighting plugins into the custom plugins directory:
git clone --depth 1 https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone --depth 1 https://github.com/zsh-users/zsh-syntax-highlighting ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
The --depth 1 flag downloads only the latest version without the full Git history, which is faster and uses less disk space.
Open the configuration file to enable the plugins:
nano ~/.zshrc
Find the line starting with plugins=( and add the new plugins:
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
Save the file with Ctrl+O, press Enter, then exit with Ctrl+X. Apply the changes:
source ~/.zshrc
Change the Theme
Oh My Zsh includes over 150 themes. View the available options in the theme gallery. To change themes, edit ~/.zshrc and modify the ZSH_THEME line:
ZSH_THEME="agnoster"
Some themes like
agnosterandpowerlevel10krequire powerline fonts for special characters to display correctly. Install them with:sudo apt install fonts-powerline
Apply the new theme:
source ~/.zshrc
Troubleshooting Common Zsh Issues
If you encounter problems with your Zsh installation, check these common solutions.
Default Shell Not Changing
If echo $SHELL still shows /bin/bash after changing the default shell, verify Zsh is listed in the authorized shells file:
cat /etc/shells | grep zsh
Expected output:
/bin/zsh /usr/bin/zsh
If Zsh is not listed, add it manually:
echo "$(which zsh)" | sudo tee -a /etc/shells
Run chsh -s $(which zsh) again and log out completely. A full logout is required because the shell assignment is read at login time, not when opening new terminal windows.
Slow Startup Time
If Zsh takes several seconds to start, the configuration file may contain slow operations. Profile the startup time to identify bottlenecks:
time zsh -i -c exit
A healthy startup time is under 0.5 seconds. Common causes of slow startup include network-dependent scripts, excessive plugins, or NFS-mounted home directories. Temporarily rename ~/.zshrc to test with a minimal configuration:
mv ~/.zshrc ~/.zshrc.bak
time zsh -i -c exit
If startup improves with a blank configuration, re-enable sections of your configuration file incrementally to find the culprit.
Missing Special Characters in Prompt
If your prompt displays boxes or question marks instead of arrows or Git symbols, install powerline fonts:
sudo apt install fonts-powerline -y
After installation, restart your terminal emulator or log out and back in for the fonts to take effect.
Plugins Not Loading
If auto-suggestions or syntax highlighting do not work after enabling them, verify the plugin files exist in the expected location:
ls ~/.oh-my-zsh/custom/plugins/
Expected output for Oh My Zsh plugins:
example zsh-autosuggestions zsh-syntax-highlighting
If the plugin directories are missing, re-run the git clone commands from the plugin installation section. Also verify the plugin names in ~/.zshrc match exactly (case-sensitive). Check your current plugins setting:
grep "^plugins=" ~/.zshrc
For APT-installed plugins, verify the source files exist:
ls /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
ls /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
If these files exist but plugins still do not work, check that your ~/.zshrc contains the source lines at the end of the file, after any other configuration.
Update Zsh
Zsh and APT-installed plugins receive updates through the standard system update process:
sudo apt update && sudo apt upgrade -y
To update only Zsh without upgrading other packages:
sudo apt install --only-upgrade zsh zsh-autosuggestions zsh-syntax-highlighting
Update Oh My Zsh
Oh My Zsh includes a built-in update command that pulls the latest version from GitHub:
omz update
To update the custom plugins you installed via Git, navigate to each plugin directory and pull the latest changes:
git -C ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions pull
git -C ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting pull
After updating, reload your configuration to apply any changes:
source ~/.zshrc
Remove Zsh
To completely remove Zsh and return to Bash, follow these steps.
Restore Bash as Default Shell
Change your default shell back to Bash before uninstalling Zsh:
chsh -s $(which bash)
Uninstall Packages
Remove Zsh and any plugins installed via APT:
sudo apt remove --purge zsh zsh-autosuggestions zsh-syntax-highlighting -y
sudo apt autoremove -y
Remove Configuration Files
The following commands permanently delete your Zsh configuration and Oh My Zsh installation. If you have custom aliases, functions, or other settings you want to keep, back up
~/.zshrcbefore proceeding.
rm -rf ~/.oh-my-zsh ~/.zcompdump*
rm -f ~/.zshrc ~/.zshrc.pre-oh-my-zsh ~/.zsh_history
Log out and log back in to complete the transition to Bash. Verify you are back on Bash:
echo $SHELL
Expected output:
/bin/bash
Conclusion
You now have Zsh configured as your default shell on Ubuntu. Whether you chose the minimal APT-based plugin approach or the full Oh My Zsh framework, your terminal now offers intelligent auto-suggestions, real-time syntax highlighting, and extensive customization options. The configuration file at ~/.zshrc controls everything from prompt appearance to plugin behavior and custom aliases.
Explore the Oh My Zsh plugin directory for additional productivity tools including Git integration, Docker shortcuts, kubectl aliases, and language-specific helpers for Python, Node.js, and Go development workflows.