A Beginner’s Guide to Installing and Configuring Zsh on Ubuntu Linux

Install and Setup ZSH on Ubuntu Linux

Zsh is a powerful shell for the command-line interface in Unix-based operating systems like Ubuntu Linux. It is an alternative to the default bash shell, offering many features and customization options.

Some benefits of using Zsh include improved auto-completion, better command-line history search, and customizable prompts. It also has many built-in features that make working on the command line easier and more efficient.

The purpose of this guide is to provide step-by-step instructions for installing and configuring Zsh on Ubuntu Linux, as well as tips and tricks for using it effectively. By the end of this guide, you should be able to use Zsh as your default shell and take advantage of its features to streamline your command-line workflow.

Installing Zsh

Before installing Zsh, it is recommended to check if it is already installed on your Ubuntu Linux system. You can check this by opening a terminal and typing the following command:

zsh --version

Installing Zsh

If Zsh is already installed, the version number will be displayed.

B. If Zsh is not already installed, you can install it using the apt-get package manager. Open a terminal and enter the following command:

sudo apt-get install zsh

C. After the installation is complete, you can verify that Zsh is installed and working correctly by typing the following command into the terminal:


This will switch your shell to Zsh, and you should see a new prompt with different colors and formatting.

D. To set Zsh as your default shell, use the following command:

chsh -s /bin/zsh

You will be prompted to enter your password, and then your default shell will be changed to Zsh. You will need to log out and log back in for the changes to take effect.

Configuring Zsh

A. Installing Oh My Zsh

To install Oh My Zsh, run the following command in your terminal:

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

B. Choosing a Zsh theme

Oh My Zsh comes with many pre-installed themes that you can choose from. To change your theme, open the .zshrc file in your home directory using a text editor, and modify the ZSH_THEME variable to the name of the theme you want to use. For example, to use the “agnoster” theme, you would set ZSH_THEME=”agnoster“.

C. Adding plugins to enhance functionality

Oh My Zsh also comes with many pre-installed plugins that you can enable to add additional functionality to Zsh. To enable a plugin, open the .zshrc file and find the plugins variable. Add the name of the plugin to the list of enabled plugins. For example, to enable the “git” plugin, you would add git to the list of plugins like this: plugins=(git). You can find a list of available plugins in the ~/.oh-my-zsh/plugins/ directory.

D. Customizing aliases and shortcuts

You can create aliases and shortcuts to make working with Zsh more efficient. To create an alias, open the .zshrc file and add a line in the following format:

alias shortcut='command'

For example, to create an alias for the command ls -alh, you would add the following line:

alias ll='ls -alh'

To create a keyboard shortcut, use the bindkey command in the .zshrc file. For example, to create a shortcut for the command cd ~/Documents, you would add the following line:

bindkey -s '^[d' 'cd ~/Documents\n'

This would create a shortcut using the Alt+d key combination.

E. Configuring the prompt

You can customize the prompt in Zsh by modifying the PROMPT variable in the .zshrc file. The prompt is made up of various escape sequences that are replaced with information about your system and the current working directory. You can find a list of these escape sequences in the Zsh documentation. For example, to add the current git branch to your prompt, you would modify the PROMPT variable like this:

PROMPT='%[email protected]%m:%~$(git_prompt_info) $ '

Using Zsh

A. Basic command line navigation

Zsh supports all the basic command line navigation commands like moving the cursor, deleting characters, and editing the command line. Some common navigation commands include:

  • Move the cursor to the beginning of the line: Ctrl+A
  • Move the cursor to the end of the line: Ctrl+E
  • Delete the character to the left of the cursor: Ctrl+H or Backspace
  • Delete the character to the right of the cursor: Ctrl+D or Delete
  • Move the cursor back one character: Ctrl+B
  • Move the cursor forward one character: Ctrl+F

B. Auto-completion

Zsh has powerful auto-completion features that can save you a lot of time when typing commands. To use auto-completion, start typing a command or file name and then press the Tab key. Zsh will try to complete the command or file name for you based on what you have typed so far. If there are multiple possible completions, you can press Tab again to cycle through them.

C. Command history

Zsh keeps a history of all the commands you have typed, which you can access using the history command. By default, Zsh stores up to 10,000 history entries. You can use the history command to display your command history, or you can use the !! command to repeat the last command you typed.

D. Searching through history

You can search through your command history using the Ctrl+R shortcut. This will open a reverse search prompt where you can start typing the command you are looking for. Zsh will search through your command history and display the most recent matching command. You can then press Enter to execute the command, or use the arrow keys to edit it first.

E. Tab completion for files and directories

Zsh also supports tab completion for files and directories. When you are typing a file or directory name, you can press Tab to have Zsh complete the name for you. If there are multiple possible completions, you can press Tab again to cycle through them. You can also use wildcards to match multiple files or directories. For example, to match all files with a .txt extension in the current directory, you can type *.txt and then press Tab.


Zsh is a powerful shell that offers a lot of benefits over other shells like Bash. Some of the benefits of using Zsh include:

  • Powerful auto-completion features that can save you time when typing commands.
  • A rich set of plugins and themes that can enhance your productivity and make your terminal look better.
  • A more customizable prompt that can display useful information about your system and the current working directory.
  • A built-in command history that can save you time when reusing commands.

Tips for further customization

To further customize Zsh, you can explore the various plugins and themes available through Oh My Zsh or create your own customizations. You can also modify the Zsh configuration file (~/.zshrc) to change various settings, aliases, and shortcuts.

Other Tutorials:

Additional resources for learning and troubleshooting

If you encounter any issues or have any questions about using Zsh, there are many resources available online to help you. The Zsh documentation is a good place to start, as it provides detailed information about using and customizing Zsh. There are also many online forums and communities where you can ask for help or share your experiences with other Zsh users. Finally, the Oh My Zsh documentation provides a wealth of information about using and customizing Oh My Zsh specifically.