How To Change Default Shell In Linux
Last Updated :
26 Dec, 2024
In most Linux systems, the default shell is bash but we can change that to any other shell-like zsh, fish, sh, and any other.
In this article, we are going to show how to change that default shell to any other shell in Linux systems. To change the user’s shell, first, let’s find the current shell. There are many ways by which we can change the shell of any user on a Linux system. We are going to see three methods of changing the user’s shell.
Find your current shell name
In Linux systems, there is one file which is /etc/passwd. The /etc/passwd file stores essential information of user accounts, which is required during login. By using this file we can identify the current user login shell.
We are going to see the current user information in the /etc/file using the following command:
grep `whoami` /etc/passwd

In the above image we can see that the user nishant (current user) has home directory /home/nishant and the shell is /bin/sh
List your shells in Linux
Now to change the shell, first, we need to see which shells are installed on the system. We can check installed shells using the following command :
cat /etc/shells
This will show all shells as follows:

Before moving further, first understand who can change the user shell
- Users can change shell to any other shell listed in /etc/shells/.
- The root account can be used to change any other user login shell.
- If an account has a restricted login shell, then only the root can change that userâs shell.
Changing default sh shell to bash
1. Using usermod command
usermod is a command that modifies the system account files. usemod can change the shell of Users by modifying file /etc/passwd. usermod command provides the -s or –shell option to change the user’s login shell.
In this example, we are going to change the shell of a user named nishant. We are going to change the shell from /bin/sh to /bin/bash of user nishant using usermod command.
sudo usermod --shell /bin/bash nishant
With usermod command mention shell and username after –shell option.
Now you can see the shell use changed. In the above commands, replace nishant with the user name whose shell has to change.

2. Using chsh Utility
chsh is the utility to change a user’s login shell. chsh provides the -s option to change the user’s shell. This method also modifies the file /etc/passwd. Use the following command to change shells using chsh:
chsh -s /bin/bash nishant

3. Change User Shell to /etc/passwd File
 As we see in the above two methods, the usermod command and chsh utility modify the /etc/passwd file and change the user shell. We can do that manually also by editing the /etc/passwd file. Just change the shell after the username and home directory in the /etc/passwd file and save the file.
nano /etc/passwd

The three methods mentioned above provide simple and effective ways to change the default shell in Linux.
Conclusion
Changing the default shell in Linux is a straightforward process with multiple methods to suit different preferences. Whether using the usermod command, the chsh utility, or manually editing the /etc/passwd file, these techniques provide flexibility for managing user environments.
By identifying the current shell, checking available options in /etc/shells, and ensuring proper permissions, users can easily switch to popular shells like zsh, fish, or any other supported option.
How To Change Default Shell In Linux – FAQs
What is a default shell in Linux?
The default shell is the command-line interpreter assigned to a user upon login, typically bash in most Linux distributions.
How do I change the default terminal in Linux?
Step 1: Check available shells with cat /etc/shells.
Step 2: Find the full path of your desired shell (e.g., /bin/bash or /bin/zsh).
Step 3: Change the default shell with chsh -s /path/to/shell.
Step 4: Log out and log back in to apply the change.
Step 5: Verify the default shell with echo $SHELL.
How can I find my current shell?
Use the following command to identify your current shell: echo $SHELL
How can I change the default shell for my user account?
You can use the chsh command: chsh -s /path/to/new/shell. Replace /path/to/new/shell with the desired shell from /etc/shells.
Similar Reads
How To Change Default Shell In Linux
In most Linux systems, the default shell is bash but we can change that to any other shell-like zsh, fish, sh, and any other. In this article, we are going to show how to change that default shell to any other shell in Linux systems. To change the user's shell, first, let's find the current shell. T
4 min read
How To Change Default Shell In Linux
In most Linux systems, the default shell is bash but we can change that to any other shell-like zsh, fish, sh, and any other. In this article, we are going to show how to change that default shell to any other shell in Linux systems. To change the user's shell, first, let's find the current shell. T
4 min read
How to change the default SSH port in Linux
SSH (Secure Shell) is a network protocol used to securely connect to the remote server where the data between the server and client is transferred in an encrypted format. In the world of Linux system administration and security, one essential practice is changing the default SSH port. This article w
7 min read
How to Create a Shell Script in linux
Shell is an interface of the operating system. It accepts commands from users and interprets them to the operating system. If you want to run a bunch of commands together, you can do so by creating a shell script. Shell scripts are very useful if you need to do a task routinely, like taking a backup
7 min read
How to change font size in putty
PuTTY application is one one the most widely used terminal-based emulators that allow users to connect to remote servers through a wide range of protocols like Telnet, SSH, and other important protocols. As the PuTTY application has its GUI application, we can customize it by making it more reliable
4 min read
How to Change Time in Kali Linux
Kali Linux is a popular Debian-based Linux distribution used for pen-testing and ethical hacking. It is developed and maintained by an American cybersecurity firm, Offensive Security. Kali Linux comes pre-installed with various tools and software required for penetration testing and ethical hacking,
4 min read
How to Change the Directory in Linux | cd Command
The cd command in Linux is one of the most basic and frequently used commands for Linux users. The cd command allows you to change directories in Linux, making it easier to navigate through the file system and manage your files efficiently. Whether you're a beginner or an experienced user, understan
7 min read
How to Change the Directory in Linux | cd Command
The cd command in Linux is one of the most basic and frequently used commands for Linux users. The cd command allows you to change directories in Linux, making it easier to navigate through the file system and manage your files efficiently. Whether you're a beginner or an experienced user, understan
7 min read
How to Open a File in Linuxâ
In Linux, a file is a fundamental unit of storage, representing everything from documents and images to system logs and program data. Unlike traditional operating systems, Linux treats almost everythingâfiles, directories, devices, and processesâas a file. Whether you're accessing a simple text docu
6 min read
How to Open a File in Linuxâ
In Linux, a file is a fundamental unit of storage, representing everything from documents and images to system logs and program data. Unlike traditional operating systems, Linux treats almost everythingâfiles, directories, devices, and processesâas a file. Whether you're accessing a simple text docu
6 min read
How to Run a File in Linux
The command line is one of the most powerful tools in Linux. It allows you to execute commands, manage files, and automate tasks all from a single terminal window. One common task you'll often need to do is run a file, whether itâs a script, a compiled program, or even a text file. In this article,
6 min read
How to Run a File in Linux
The command line is one of the most powerful tools in Linux. It allows you to execute commands, manage files, and automate tasks all from a single terminal window. One common task you'll often need to do is run a file, whether itâs a script, a compiled program, or even a text file. In this article,
6 min read
How to configure SSH Client in Linux ?
At times we may need to access multiple remote systems with different IP addresses/hostnames, usernames, non-standard-ports with various command-line options. One way is to create a bash alias for each remote connection. But we have an easy and much better solution to this problem. OpenSSH allows to
4 min read
How to Run a Shell Script in Linux
Shell scripts are a powerful way to automate tasks and manage system processes in Linux. These scripts, written in shell programming languages like Bash, allow users to execute a sequence of commands efficiently. In this guide, we'll show the steps to check a shell script in Linux before running it,
4 min read
How to Run a Shell Script in Linux
Shell scripts are a powerful way to automate tasks and manage system processes in Linux. These scripts, written in shell programming languages like Bash, allow users to execute a sequence of commands efficiently. In this guide, we'll show the steps to check a shell script in Linux before running it,
4 min read
How to Change the Output Color of Echo in Linux
When working with a computer, some users may encounter a situation where they need to output text in a different color. The colors we are familiar with by now will have been worked out for our particular machine and thus can be replaced easily if needed. Echo is a Linux command that can be used to c
9 min read
How to Change Default Display Manager in Ubuntu
In Linux desktop systems, the display manager is a crucial component that handles user authentication and manages user sessions. The display manager is responsible for presenting the login screen and loading the desktop environment after successful authentication. Some popular display managers inclu
4 min read
How to Enable Shell Script Debugging Mode in Linux?
Linux is a very popular operating system especially among developers and in the computer science world, as it comes along with its powerful ability to play with the kernel. Major Linux distributions (often referred to as Linux distros) are Open Source (Source Code available and can be modified on re
5 min read
Setting python3 as Default in Linux
Python 2 support ended on 1-January-2020, and many major projects already signed the Python 3 Statement that declares that they will remove Python 2 support. However many of us prefer to code on python interpreter for tiny code snippets, instead of making .py files. And when we fire command 'python'
1 min read