How to Install and Use Zsh Shell in Ubuntu and Other Linux

3 min


This guide explains how to install, use and configure several themes in Zsh.

I bet all true Linux fans love Terminal. A Terminal is a way of executing commands from a user for the Linux Kernel. And a way for Linux Kernel to interact with users as well. Hence, it is always a much faster way of doing several activities via the terminal.

If you are a system administrator managing multiple Linux desktop systems in a local network or organisation network, you spend most of your time in a terminal. If you use a desktop environment for those works, you might want to change the look of your terminal. And it helps to move away from the mundane default terminals of Ubuntu and other Linux systems.

By default, almost all Linux distributions use the Bash shell. The bash shell is a solid program and an old one too. But it lacks specific customisation options. For example, if you want some nice colours, the execution time for commands, etc. – it isn’t easy to customise.

So, for those customisations, you can use the Zsh shell, which is, in a way, an extended Bash Shell with additional improvements. 

And in this guide, we explain how to install, use and configure several themes in Zsh. This applies to all Linux distributions

Install zsh

Installing Zsh is easy. The following command does the trick.

Ubuntu, Debian, Linux Mint and all related distro

sudo apt install zsh

Fedora

sudo dnf install zsh

Arch

pacman -S zsh

Configure and use zsh

After installation, you need to configure the Zsh and replace your bash shell. To do that, open the terminal and run the below command. Change the username to your system (root in the example below).

  • First, find out the executable path of Zsh.
whereis zsh
  • Then change the Shell using the below command.
chsh -s /usr/bin/zsh root
Changing Shell
Changing Shell
  • Then log off and log in again and open the terminal. You should see a first-time setup screen. Choose 0. This should create an empty .zshrc file.
zsh configuration
zsh configuration

And now it’s time to colourise Zsh.

Install and Configure Oh My Zsh

Oh My Zsh is a collection of script and themes which gives the actual look and feel of your terminal. It is present on GitHub, which you need to download and install. Follow the steps below.

  • If Git is not installed, install it via sudo apt install git Or, sudo dnf install git.
  • Then run the following command.
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh

Or, you can use any of the below installation methods.

MethodCommand
curlsh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
wgetsh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
fetchsh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  • The above command will install the Oh My Zsh and create a configuration folder in your home named .zshrc.
  • Copy the templates.
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
  • Recompile the Zsh.
source ~/.zshrc
  • And you should see a nice-looking terminal prompt.
oh my zsh install
oh my zsh install

Changing Themes

See the above screen prompt. That is the default prompt. Now, Oh My Zsh is pre-loaded with many themes. They are located in ~/.oh-my-zsh/themes. See below.

pre-loaded themes
pre-loaded themes

How they look, you can find it here. It’s a good idea to browse through first before making a change.

Now, to change a theme, note down the name from above and update it in the ~/.zshrc file via any text editor. For this tutorial, I will change to agnoster theme.

In the file, change the name of the ZSH_THEME property with the theme name. Save and close the file.

changing the theme name
changing the theme name

Recompile the .zshrc file.

source ~/.zshrc

Close and open the terminal again. And you should see the new theme in action.

oh my zsh - theme applied
oh my zsh – theme applied

Closing Notes

I hope this guide helps you to transform your otherwise mundane terminal. You can play around with various themes and settle on what you like. You can also learn more about configuration options on the official GitHub page or Arch Wiki.

Let me know whether you can change your terminal. Also, share your terminal screenshot in the comment box below. Cheers.


Arindam

Creator and author of debugpoint.com. Connect with me via Telegram, 𝕏 (Twitter), or send us an email.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

4 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments