Installing Zsh on Ubuntu: A Beginner-Friendly Guide
Introduction
After installing Ubuntu, one of the first things many users encounter is the Linux terminal. By default,Ubuntu uses Bash (Bourne Again Shell) as its command-line shell. While Bash is powerful and widely used,many developers and Linux enthusiasts prefer an alternative shell called Zsh (Z Shell).
This guide explains what Zsh is, why it is popular, how to install it on Ubuntu, and what happens during its
first-time setup. The explanations are written with beginners in mind, breaking down every command used
during the installation process.
What is a Shell?
Before understanding Zsh, it is important to understand what a shell is.
A shell is a program that allows users to interact with the operating system through commands. Whenever commands such as the following are executed:
ls
cd
mkdir
the shell interprets those commands and communicates with the operating system to perform the requested actions.
Ubuntu uses Bash (Bourne Again Shell) as its default shell.
What is Zsh?
Zsh stands for Z Shell. It is an advanced shell that provides all the features of Bash while adding many enhancements that improve the command-line experience.
Some of the most popular features of Zsh include:
• Better command auto-completion
• Easier navigation through directories
• Command suggestions and corrections
• Customizable themes
• Plugin support
• Improved productivity for developers
Because of these features, Zsh has become one of the most widely used shells in the Linux community.
Why Use Zsh?
Many users choose Zsh for the following reasons:
Better Auto-Completion
Zsh provides intelligent suggestions when typing commands, file names, and directories.
Improved Productivity
Frequently used commands can be executed more quickly with the help of plugins and shortcuts.
Customization
The terminal appearance can be customized using themes, making it more informative and visually appealing.
Learning Modern Linux Tools
Many developers use Zsh along with frameworks such as Oh My Zsh, making it a valuable tool for anyone learning Linux development environments.
Installing Zsh
Step 1: Updating Package Information
Before installing any software, Ubuntu's package information should be updated.
sudo apt update
Understanding the Command
• sudo = Super User DO. Temporarily grants administrator privileges.
• apt = Advanced Package Tool used to manage software packages.
• update = Downloads the latest package information from Ubuntu repositories.
This command does not upgrade software. It only refreshes the package database so Ubuntu knows which software versions are available.
Step 2: Installing Zsh
Install Zsh using the following command:
sudo apt install zsh -y
Understanding the Command
• sudo = Runs the command with administrator privileges.
• apt = Ubuntu package manager.
• install = Installs a software package.
• zsh = The package to be installed.
• -y = Automatically answers "Yes" to confirmation prompts.
This command downloads and installs Zsh along with any required dependencies.
Step 3: Verifying Installation
After installation, verify that Zsh has been installed correctly.
zsh --version
Understanding the Command
• zsh = Runs the Zsh executable.
• --version = Displays version information.
Example output:
zsh 5.9
Displaying a version number confirms that the installation was successful.
Step 4: Making Zsh the Default Shell
Installing Zsh does not automatically replace Bash. To make Zsh the default shell, execute:
chsh -s $(which zsh)
Understanding the Command
This command consists of multiple parts.
which zsh
• which = Finds the location of an executable program.
• zsh = The program being searched for.
Example output:
/usr/bin/zsh
This shows the location of the Zsh executable.
$(which zsh)
The $() syntax is known as command substitution.
It executes the command inside the brackets and uses its output.
Therefore:
$(which zsh)
becomes:
/usr/bin/zsh
chsh -s
• chsh = Change Shell.
• -s = Specifies which shell should be used.
Therefore:
chsh -s $(which zsh)
effectively becomes:
chsh -s /usr/bin/zsh
This tells Linux to use Zsh as the default login shell for the current user.
After running the command, log out and log back in.
First Launch of Zsh
After logging back in and opening the terminal, Zsh may display a configuration screen called zsh-newuser-install.
This happens because no Zsh configuration files currently exist in the user's home directory. Zsh therefore launches a setup wizard to create an initial configuration.
The setup wizard presents four options.
Option (q)
(q) Quit and do nothing.
• Exits the setup wizard.
• The wizard will appear again the next time Zsh starts.
Option (0)
(0) Exit, creating the file ~/.zshrc containing just a comment.
• Creates a minimal .zshrc file.
• Prevents the setup wizard from appearing again.
• Useful for users who want to configure everything manually.
Option (1)
(1) Continue to the main menu.
• Opens the advanced configuration menu.
• Allows customization of history settings, key bindings, completion settings, and other shell features.
Option (2)
(2) Populate your ~/.zshrc with the configuration recommended by the system
administrator.
• Automatically creates a recommended .zshrc file.
• Applies sensible default settings.
• Recommended for beginners.
Recommended Choice for Beginners
For users who are new to Zsh, selecting:
2
is generally the best option.
This option:
• Creates the configuration file automatically.
• Applies useful default settings.
• Allows immediate use of Zsh without manual configuration.
Understanding the .zshrc File
During the setup process, a file named:
~/.zshrc
is created.
Breaking It Down
• ~ = Home directory of the current user.
• .zshrc = Zsh Run Commands file.
• The dot ( . ) indicates that it is a hidden file.
The .zshrc file stores:
• Shell settings
• Aliases
• Plugins
• Themes
• Environment variables
• Custom terminal configurations
Every time Zsh starts, it reads this file and applies the stored settings.
Verifying the Configuration File
To verify that the configuration file was created successfully:
ls -la ~/.zshrc
Understanding the Command
• ls = Lists files and directories.
• -l = Displays detailed information.
• -a = Shows hidden files.
• ~/.zshrc = Path of the configuration file.
If the file exists, Linux displays its details.
Key Takeaways
Installing Zsh introduces several important Linux concepts:
• Linux supports multiple shells.
• Users can choose their preferred shell.
• Shell behavior is controlled through configuration files.
• Commands can be combined using command substitution.
• Terminal environments can be customized extensively.
Understanding these concepts provides a strong foundation for further Linux learning.
Conclusion
Zsh is a modern and feature-rich shell that enhances the Linux terminal experience through improved auto-completion, customization, and productivity features. Installing Zsh is a simple process, but it also serves as an excellent opportunity to learn about package management, shell configuration, and Linux command-line fundamentals.
For beginners exploring Ubuntu and Linux, Zsh provides a practical introduction to terminal customization while maintaining compatibility with familiar Bash workflows.