Most Linux distributions include the bash shell by default, but you’ll also switch to a different shell environment. Zsh may be a particularly popular alternative, and there are other shells, like ash, dash, fish, and tcsh.
But what’s the difference, and why are there so many?
Bash is the default shell on Linux and Mac OS X. Zsh is an interactive shell which incorporates a lot of useful features from other shells.
What Do Linux Shells Do?
When you check in at the instruction or launch a terminal window on Linux, the system launches the shell program. Shells offer a typical way of extending the instruction environment. you’ll swap out the default shell for an additional one, if you wish .
The first shell environment was the Thompson Shell, developed at Bell Labs and released in 1971. Shell environments are building on the concept ever since, adding a spread of latest features, functionality, and speed improvements.
For example, Bash offers command and file name completion, advanced scripting features, a command history, configurable colors, command aliases, and a spread of other features that weren’t available back in 1971 when the primary shell was released.
The shell is additionally utilized in the background by various system services. Linux distributions include many functions written as shell scripts. These scripts are commands and other advanced shell scripting functions run through the shell environment.
Shells Leading Up to Bash: sh, csh, tsh, and ksh
The most prominent progenitor of recent shells is that the Bourne shell—also referred to as “sh”—which was named after its creator Stephen Bourne who worked at AT&T’s Bell Labs. Released in 1979, it became the default command-interpreter in Unix due to its support for command substitution, piping, variables, condition testing, and looping, along side other features. It didn’t offer much customization for users, and didn’t support such modern niceties as aliases, command completion, and shell functions (though this last one was eventually added).
The C shell, or “csh”, was developed within the late 1970s by Bill Joy at University of California, Berkley. It added tons of interactive elements with which users could control their systems, like aliases (shortcuts for long commands), job management abilities, command history, and more. it had been modeled off the C programing language , which the Unix OS itself was written in. This also meant that users of the Bourne shell had to find out C in order that they could enter commands in it. additionally , csh had quite few bugs that had to be hammered out by users and creators alike over an outsized period of your time . People ended up using the Bourne shell for scripts because it handled non-interactive commands better, but cursed with the C shell for normal use.
Over time, many people fixed bugs in and added features to the C shell, culminating in an improved version of csh referred to as “tcsh”. But csh was still the default in Unix-based computers, and had added some non-standard features. David Korn from Bell Labs worked on the KornShell, or “ksh”, which tried to enhance things by being backwards-compatible with the Bourne shell’s language but adding many features from the csh shell. it had been released in 1983, but under a proprietary license. It wasn’t free software until the 2000s, when it had been released under various open-source licenses.
The Birth of bash
The Portable OS Interface for Unix, or POSIX, was another response to the hectic proprietary csh implementations. It successfully created a typical for command interpretation (among other things) and eventually mirrored tons of the features within the KornShell. At an equivalent time, the GNU Project was attempting to make a free, Unix-compatible OS . The GNU Project developed a free software shell to be a part of its free OS and named it the “Bourne Again Shell”, or “bash”.
Bash has been improved within the decades since its first release in 1989, but it’s still the default shell on most Linux distributions today. It’s also the default shell on Apple’s macOS, and is out there for installation on Microsoft’s Windows 10.
Newer Linux Shells: ash, dash, zsh, and fish
While the Linux community has settled on Bash within the years since, developers didn’t stop creating new shells when Bash was first released 28 years ago.
Kenneth Almquist created a Bourne shell clone referred to as Almquish shell, A Shell, “ash”, or sometimes just “sh”. It had been also POSIX compatible and have become the default shell in BSD, a special branch of Unix. The ash shell is more lightweight than bash, which makes it popular in embedded Linux systems. If you’ve got a rooted Android phone with BusyBox installed—or the other device with the BusyBox suite of software—it’s using code from ash.
Debian developed a shell environment supported ash and called it “dash”. It’s designed to be POSIX-compliant and light-weight , so it’s faster than Bash, but won’t have all its features. Ubuntu uses the dash shell as its default shell for non-interactive tasks, speeding up shell scripts and other tasks running within the background. Ubuntu still uses bash for interactive shells, however, so users still have the full-featured interactive environment.
One of the foremost popular newer shells is Z shell, or “zsh”. Created by Paul Falstad in 1990, zsh may be a Bourne-style shell that contains the features you’ll find in bash, plus even more. for instance , zsh has spell-checking, the power to observe for logins/logouts, some built-in programming features like bytecode, support for scientific notation in syntax, allows for floating-point arithmetic, and more features.
Another newer shell is that the Friendly Interactive Shell, or “fish”, released in 2005. it’s a singular command-line syntax that’s designed to be a touch easier to find out , but isn’t derived from either the Bourne shell or C shell. It’s a stimulating idea, but what you learn through using fish won’t necessarily assist you use bash and other Bourne-derived shells.
Which do you have to Choose? (and Why Zsh is Popular)
You don’t got to choose a shell. Your OS chooses your default shell for you, which choice is nearly always bash. Sit down ahead a Linux distribution—or even a Mac—and you’ll nearly always have a bash shell environment. Bash has quite few advanced features, but you almost certainly won’t use them unless you program shell scripts.
On embedded Linux systems or BSD systems, you’ll find yourself with the ash shell. But ash may be a Bourne-based shell and is essentially compatible with bash. Any knowledge you’ve got from using bash will transfer to using an ash or dash shell, although some advanced scripting features aren’t available during this lightweight shell.
Almost every shell you’ll encounter is Bourne-based and works similarly—including zsh.
That’s why zsh is popular. This newer shell is compatible with bash, but includes more features. The zsh shell offers built-in spelling correction, improved command-line completion, loadable modules that act as plug-ins for your shell, global aliases that allow you to alias file names or anything on the instruction rather than just commands, and more theming support. It’s like bash, but with tons of extras, additional features, and configurable options you would possibly appreciate if you spend tons of your time at the instruction .
If you’re conversant in bash, you’ll switch to zsh without learning a special syntax—you’ll just gain additional features. if you’re conversant in zsh, you’ll switch to bash without learning a special syntax—you just won’t have access to those features.
“Oh My ZSH” may be a tool that helps you more easily enable zsh plug-ins and switch between premade themes, quickly customizing your zsh shell without spending hours tweaking things.
There are other shells, too. for instance , the tcsh shell remains around and remains an option. FreeBSD uses tsch as its default root shell and ash as its default interactive shell. If you employ the C programming regularly, tsch could be a far better fit you. However, it’s nowhere near as commonly used as bash or zsh.
How to Switch Between Shells
It’s easy to modify to a replacement shell to undertake it out. Just install the shell from your Linux distribution’s package manager and sort the command to launch the shell.
For example, let’s say you would like to undertake zsh on Ubuntu. You’d run the subsequent commands to put in then launch it:
sudo apt install zsh zsh
You’d then be sitting at a zsh shell. Type ”
exit ” at the shell to leave it and return to your current shell.
This is just temporary. Whenever you open a replacement terminal window or sign into your system at the instruction , you’ll see your default shell. to vary the shell you see once you sign in—known as your login shell—you can generally use the chsh , or “Change Shell”, command.
To use this command, you’ll first need to find the full path to your shell with the which command. For example, let’s say we wanted to change to the zsh shell. We’d run the following command:
On Ubuntu, this tells us the zsh binary is stored at /usr/bin/zsh.
Run the following command, enter your password, and you’ll be prompted to choose a new login shell:
According to the above command, we’d enter
/usr/bin/zsh . The zsh shell would then be our default until we ran the
chsh command and changed it back.