In this article, we cover how to change the default shell in the Ubuntu 24.04 release. A Shell is often referred to as a CLI or Command-line interface. Through a shell, a user can execute commands that help him/her to interact with the system. It is quite useful when it comes to redirecting output, text processing, changing file ownership, navigation file systems, etc. To increase productivity, a user can also opt to automate tasks through it.
The default shell in Ubuntu is Bourne Again Shell. First, we will identify our currently active shell and then move to change it to some other shell. If you are just starting out with the Shell then, there is great resource available: Command Line for Beginners.
Note: The following operations require Administrative rights. If you lack the necessary rights to make changes to your system then, contact your System Administrator for assistance.
Identify default Shell
If you are looking for the default Shell of the currently logged-in user then issue the following command in the terminal:
grep $USER /etc/passwd
If you wish to identify it for some other user, then put a different username in place of $USER.
The output of the above code would be something like:
xyz:x:1000:1000:XYZ:/home/xyz:/bin/bash
At this moment, Bourne Again Shell is our default shell.
Get a list of installed Shells
To change to some other shells, we need to have that other shell installed. For instance, we wanted to move from Bourne Again Shell to Zsh (or, Z shell). So, we installed it first:
sudo apt update sudo apt install zsh
To get a list of all installed shells:
cat /etc/shells
From the list, note the path of the shell shown here. It will be useful for the next section.
Change the default shell in Ubuntu 24.04
To change the default shell we can use the command-line utility: chsh
There are two modes through which we can do so:
- Interactive mode and,
- Non-interactive mode.
Interactive mode:
Issue the following command in a terminal:
chsh
It would prompt us for the password. Thereafter, use the path as a value that we got by issuing the command in the above section cat /etc/shells. So, enter the value as /bin/zsh to move to Z shell. And, press Enter.
Non-interactive mode:
chsh -s /bin/zsh
is the direct command with use. Just put the path of the shell we wish to move to. And, enter the password.
Once we are done, we can verify the changes by issuing the following command as described in the first section above:
grep $USER /etc/passwd
In conclusion, we have covered here how to change the default shell in Ubuntu 24.04 release.