Home Linux Shells How to Install and Use ZSH Shell in Linux

How to Install and Use ZSH Shell in Linux

A shell is used as an interface between a user and the operating system. On most Linux distributions, bash shell is the default shell used, however, the best part about open source is choice. As users, we can decide to change defaults that came with the system and use other alternatives.

In Linux, the most commonly used open-source shells include Bourne Again Shell (bash), tcsh (an enhanced C shell), Korn shell (ksh), friendly interactive shell (fish), and zsh.

Zsh is an extended version of the bash shell with added features and it is based on a similar shell as bash therefore bash commands are also applicable in zsh.

In this article, we discuss how to install and use zsh shell features in Linux systems.

Installing Z Shell (Zsh) in Linux

Depending on the Linux distribution you are using, you can install Zsh on your Linux system from one of the following commands:

$ sudo apt install zsh           [On Debian, Ubuntu and Mint]
$ sudo yum install zsh           [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux]
$ sudo emerge -a app-shells/zsh  [On Gentoo Linux]
$ sudo pacman -S zsh             [On Arch Linux]
$ sudo zypper install zsh        [On OpenSUSE]    

To get started, open a terminal and type the command to change the current shell to zsh:

$ zsh

We can also use the chsh command to change the default shell although this requires us to log out then log back in for the changes to take effect.

$ chsh -s $(which zsh)
Change Linux Shell
Change Linux Shell

How to Use Z Shell (Zsh) in Linux

At this point, if the shell has changed, we can start exploring some of the zsh features:

1. Tab Completion

As an example, type the cd command then, press the tab key:

$ cd <TAB>
Zsh Tab Completion
Zsh Tab Completion

Unlike bash shell, which lists all files and directories, zsh, in addition to listing all files and directories, allows us to navigate directories while highlighting them. When we find a directory to change to, we just press the enter key.

2. History Command

With bash, we usually use the history command or perform a recursive search (CTRL+R) to find the last executed commands.

Zsh on the other hand gives better search functionality whereby we just type in the command then use the arrow up button to find the last commands executed with the command.

For example, to find all last executed cd commands we type cd and cycle through them using the arrow up button:

$ cd <ARROW UP>
Zsh History Command
Zsh History Command

3. Killing Linux Processes

Usually, we use the htop or ps command to find and kill unwanted processes. Zsh performs this action even better.

To demonstrate, type in the kill command and press the tab key:

$ kill <TAB>
Zsh Kill Command
Zsh Kill Command

To kill, say, the bash process with PID 38787, we press the enter key while we have it highlighted.

4. Command Options

In bash, say we forgot what ping command option allows us to send n number of packets, first we would have to abort writing the current command to type in ping --help or read the command’s manual page.

$ man ping

With Zsh all we have to do is write the command followed by a hyphen:

$ ping -
Zsh Command Options
Zsh Command Options

From the output, we can see some ping command options. For more command options, we press the tab key.

$ ping - <TAB>
Ping Command Options
Ping Command Options

To move down or up the options list we use the up and down arrow keys or the tab button. Also, notice how they are auto-filled to the ping command prompt, all we have to do to proceed is to pass a number representing the number of packets (5) we wish to send along with an IP address (

$ ping -c 5

5. Correction

Zsh shell can correct us when we make a mistake or help us remember what the exact name of a file or directory was.

For example, assume we forgot a directory name but remember some characters in the middle of the file name, or we remember the file extension.

In this case, assuming we forgot the Templates directory. We can write:

$ ls lates
Zsh Correction
Zsh Correction

Immediately you will see the Templates directory listed, now all we have to do is press the tab key to autofill and correct our mistake.

$ ls <TAB>

We can also apply the same concept to search for files with specific file extensions, for example, if we are searching for .c files we write.

$ cat .c

Now, all we have to do is press the tab key and highlight files then when the correct file is highlighted we select it by pressing the enter key.

Zsh Search Files
Zsh Search Files

Zsh is designed as an interactive shell and also a powerful scripting language. It is a combination of bash, ksh, and tsh shells all in one powerful shell.

We have discussed just a few features, enough to motivate one to make the shift from bash to zsh. In addition to more great features, it also has plugin support and helpful documentation that will blow your mind. And, there is no learning curve since bash commands are also applicable here.

Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

3 thoughts on “How to Install and Use ZSH Shell in Linux”

  1. The actual question is WHY, not HOW…


    Why use any other shell instead of the default? If you write a script that requires zsh, you’ll have to install zsh on every system where you want to run it.

    The bash gives everything that you want from a shell. For more complex tasks using a scripting language (Perl, python, etc)!


Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.