Comparing the advantages of zshell over bash shell in Linux

Linux admins interested in using zsh instead of bash shell will learn what is similar and what is different. Zshell offers new features for tab completion and typo correction and others that would be much more complex in bash.

Admins using bash shell might want to take a closer look at zshell, or zsh. With its likeness to bash and its enhanced features, zsh is gaining attention in the Linux community.

So what is different about zsh? First, zsh is a lot like bash with its similar feel and functionality. But, there are some enhancements that make zsh an interesting option. The following is a Thunderdome-style comparison of zsh and bash on a Linux server: 

Zsh enhancements: Tab completion and typo correction

Admins used to bash tab completion will find the enhanced capabilities in zsh impressive. These include presenting auto-completion command options in a menu that is able to be scrolled through using the arrow keys. For example, typing the following commands will provide a list of the potential command line flags:

$ ls -

Or,

$ rm -

To select a specific process to kill, a list of processes is available  with  the kill command.

Another feature is in the built-in pager, which provides a shortcut to the less command. To access it, type:

$ <filename

This is the same as running less filename on the command line.

For clumsy typists, a typo correction feature is available. For example, if an incorrect command is entered, zsh prompts a correction:

$ lls

zsh: correct 'lls' to 'ls' [nyae]?

To fix it, type y and correct the command to ls, and then it’s ready to run.

Other options are useful as well. The n option declines to correct the command, a aborts the command, and e pops up the command line for editing. This auto-correction also works for command line flags and file names, including esoteric items like correcting invalid Git branch names.

Get started using zsh

To quickly get started with zsh, make use of Robby Russell’s collection of zsh themes, functions and tools prepackaged as “Oh My Zsh.” It can be installed via Russell’s installation script, which changes the shell to zsh:

$ wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh

Manual zsh installation instructions are also available, requiring users to clone the Git repo and copy in the draft .zshrc template.

The “Oh My Zsh” repository contains a collection of themes and functions for a ready-made zsh environment to build on and change. It also comes with an uninstall script for easy removal:

$ uninstall_oh_my_zsh

The zsh shell comes with some excellent documentation and the zsh reference card. Online resources on sites like GitHub show example .zshrc files—the zsh equivalent of the .bashrc file—and can provide examples of how to customize zsh or examples of cool tips and tricks to enhance your command-line experience.

Some of zsh’s features are available with bash, but they are a lot more complex to set up and configure on bash, explaining why people have multi-page .bashrc files. If you’re heavy user of the shell, zsh may be an attractive alternative to bash. It’s quick and easy to get started using, and delivers some important features that make interacting with the shell a lot more fun.

About the author:
James Turnbull is head of Operations at Puppet Labs. He is a former IT executive in the banking industry and author of five technology books, including the just released Pro Puppet, as well as Pulling Strings with Puppet and Pro Linux System Administration. James has been involved in IT Operations for nearly twenty years and is an advocate of open source technology.

This was first published in June 2011

Dig deeper on Linux administration tools

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchDataCenter

SearchServerVirtualization

SearchCloudComputing

SearchEnterpriseDesktop

Close