Before installing anything new, it’s good practice to update your system packages:
It might be easier than you think to install and use a new shell. First install the package like this:
Now you can enter a session of zsh be invoking the shell’s name ‘zsh’.
You might not be sure if it succeeded, how you can verify which sell you are using now?
You should see some output like the following:
zsh:
[root@mypc]~#
ok good, if it says bash or something other than zsh you have a problem with your setup. Now lets run a couple basic commands
Example 1: Print all numbers from 1 to 10. In Zsh, you can use a for loop to do this:
Example 2: Create a variable to store your username and then print it. You can use the $USER environment variable which automatically contains your username:
echo $my_username
Example 3: Echo a string that says “I love $0”. The $0 variable in a shell script or interactive shell session refers to the name of the script or shell being run. Here’s how to use it:
When run in an interactive Zsh session, this will output something like “I love -zsh” if you’re in a login shell, or “I love zsh” if not.
Conclusion
Switching shells in a linux system is easy due to the modularity. Now that you see how to install ZSH you may like it and decide to use it as your preferred shell.