Change default shell in Ubuntu 22.04

In this article, we would see how we can change default shell in Ubuntu 22.04 release. A shell is basically a command-line interpreter. When we start a terminal, the first program to launch is the shell.

In Ubuntu, the default shell is Bourne Again Shell. We would first show you how to find out our default shell. If you haven’t made changes to configuration then, in all probability Bourne Again Shell is the default one.

Note: Following operations would require you to have superuser privileges. In case you don’t have one then, we advise you to contact your System Administrator for assistance.

Find out the default shell

Open a terminal and issue the following –

whoami

the whoami command-line utility shows us our username. Now, we can check –

grep $USER /etc/passwd

here, $USER is our username. If we want to check for some other USER then, we need to specify username in place of $USER.

The output of the above code –

xyz:x:1000:1000:XYZ:/home/xyz:/bin/bash

It clearly shows the Bourne Again Shell is our default shell.

List all the installed shells

To list all the installed shells, we need to issue the following command in terminal –

cat /etc/shells

It would show us the list of valid login shells.

Change default shell in Ubuntu 22.04

We would use chsh command-line utility here. chsh is used to change user login shell. The list of shells we get through cat /etc/shells is very useful to us. Note down the path of the shell you to like to change from cat /etc/shells.

For instance, we tried to change default shell to Zsh (Z Shell) – /bin/zsh.

There are two modes available to us – interactive and non-interactive.

I. Interactive mode, just issue the following in terminal –

chsh

It will ask us to enter the new value, therein enter the path we get through cat /etc/shells command. As we have already discussed, we preferred zsh

/bin/zsh

You can have any other shell as you like.

II. Non-interactive mode, issue the following in terminal –

chsh -s /bin/zsh

where,

-s option is for new login shell.

In conclusion, we have discussed how to change default shell in Ubuntu 22.04 release.

Similar Posts