Submitted by drupalmaster on

Checking the running shell, locating a system-available shell, and altering the Linux default shell are all covered in this brief tutorial.

You probably already know that Linux and other Unix-like systems offer a number of different shells. Although Bash is the default shell on almost all Linux distributions, other popular shells include:

 

ksh 
zsh 
fish 
csh 
dash 

Some of the shells offer more features in a way that is easier to use. Take, for instance, fish shell. Based on the last command you typed, it partially starts showing you command hints. If you don't want to constantly remember the Linux terminal shortcuts, this is a very useful feature.

Let's take a look at the shell on your Linux system.

How Can I Learn About The Default Shell?

You can check the SHELL environment variable to determine your Linux system's default shell. Typically, bash is used as the default shell, and it looks like this:

echo $SHELL 
/bin/bash

How Can I Find Out Which Shell I'm Currently Using

There is no single method that can accurately identify the shell you are using.

You can try either echo $0, which displays the following output:

echo $0 
zsh 

or check the process with ps -p $$ in the following manner:

ps -p $$ 

PID TTY         TIME CMD 
9625 pts/0   00:00:00 zsh 

How Do You View All Your Linux System's Shells?

The file /etc/shells contains a list of all the shells that are available on your Linux systems. To view the file's contents, you can use the cat or less commands.

# shells//etc: valid login shells
/bin/sh
/bin/bash
/bin/rbash
/bin/dash
/usr/bin/tmux
/usr/bin/fish
/bin/zsh
/usr/bin/zsh

Simply typing the name of the new shell will log you into the new one if you want to use it. For instance, if you want to use zsh after installing it, you can simply use:

zsh 

You can enter exit to return to the previous shell and exit the new one.

How Can Linux's Default Shell Be Permanently Changed?

Let's say you liked the Fish shell so much that you wanted to use it as your default shell every time you opened the terminal or used ssh to get into the system.

The chsh command in Linux lets you change the default shell. The most effective way to change the default shell for your own signed in client is by determining the shell name recorded in the/and so on/shells document with the - s choice.

chsh -s /usr/bin/fish

To ensure that the changes take effect, you must log out of the system. Otherwise, you might think that running chsh didn't change the shell.

Did you notice that the /etc/shells file required us to specify the full path? I would have received an error like "chsh:" if I had used chsh -s fish. "Fish is a useless shell."

Which one do you prefer?

You can also read about changing users in Linux now that you know how to change the shell.

I hope you found this brief guide to changing Linux's shell helpful. If you've considered changing the default shell, you might use a different one than bash. Is that the shell? Why do you think it's better than the others?



 

Category