Install Zsh Shell on Ubuntu 22.04 LTS – Turn Your Terminal Into a Power‑User’s Playground
If you’ve ever been annoyed by the bland default Bash prompt or want to get that fancy auto‑completion for git, Docker, and kubectl, this guide shows how to install Zsh on Ubuntu 22.04 LTS in less than ten minutes. We’ll cover the basic `apt` install, make it your default shell, and optionally hook up Oh‑My‑Zsh if you’re ready for a splash of extra flair.
1. Why Swap Out Bash?
I’ve seen people still use Bash because “it’s built‑in” and “I don’t want to mess with defaults.” That’s fine if you only run simple scripts, but Zsh gives you dozens of out‑of‑the‑box completions and a more informative prompt without any extra effort. If you’re running `docker`, `git`, or even just typing `cd` into random directories, Zsh makes those keystrokes feel like magic.
2. Install the Core Shell
sudo apt update sudo apt install zsh
Why this matters: Updating first pulls the latest package lists so you’re getting the newest Ubuntu‑maintained build of Zsh (5.9 at the time of writing). The `install` command brings in the shell itself plus a small set of utilities that work out of the box.
3. Switch to Zsh as Your Default
chsh -s $(which zsh)
Why this matters: `chsh` changes your login shell so the next time you log in (or open a new terminal window), Zsh starts automatically instead of Bash. The `$(which zsh)` part guarantees we’re pointing to the exact binary that just got installed.
After running that, close and reopen your terminal or log out and back in. If you see a welcome screen from Zsh asking if you want to set it up now, hit “no” – we’ll do it manually later.
4. Optional: Add Oh‑My‑Zsh for Extra Features
Oh‑My‑Zsh is the popular community framework that bundles themes, plugins, and handy aliases. If you’re comfortable with a bit of extra download size (the repo is ~15 MB after installation) and want auto‑suggestions for `kubectl`, it’s worth adding.
# Install dependencies first sudo apt install curl git # Grab the installer script curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -o ~/install_oh_my_zsh.sh # Run it non‑interactive (it’ll skip the Bash prompt) sh ~/install_oh_my_zsh.sh --unattended
Why this matters: The unattended flag keeps the install from asking you to confirm Bash as your default again. Oh‑My‑Zsh also configures a useful `.zshrc` file automatically, so you’re not staring at an empty settings page.
5. Fine‑Tune Your Prompt
If you want the “pretty” prompt that shows Git branches and exit codes, open your `~/.zshrc`:
nano ~/.zshrc
Search for `ZSH_THEME=` and change it to `robbyrussell` (the default) or any of the dozens of themes bundled with Oh‑My‑Zsh. Then reload:
source ~/.zshrc
Why this matters: A clear prompt saves you from guessing which directory you’re in after a long run, and it can even tell you when a command failed with a non‑zero exit code.
6. Common Pitfalls (and How to Avoid Them)
- “Zsh starts but prints errors.” That usually means your `.zshrc` contains Bash syntax or references variables that don’t exist in Zsh. Comment out the problematic lines, reload, and try again.
- “After `chsh`, I’m still in Bash.” Remember you have to log out completely; a new terminal session won’t pick up the change until it starts fresh.
- “Oh‑My‑Zsh installs but doesn’t load plugins.” Open `.zshrc` and ensure `plugins=(git)` (or whatever you want) is not commented out.
7. A Real‑World Scenario
I once had a coworker who upgraded from Ubuntu 18.04 to 22.04 and kept Bash. She complained about the prompt being too plain after she started working with multiple Git branches nightly. After switching her to Zsh, her productivity shot up – she could see which branch she was on at a glance, and auto‑completion saved her dozens of keystrokes every day.
That’s all you need. Install, switch, optionally pimp it, and enjoy your new shell.