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.
Similar Reads
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
Navigating the Linux file system is like exploring a vast library; each directory (folder) holds its own collection of files and subdirectories, and knowing how to move between them efficiently is the first step to mastering the command line. The cd (Change Directory) command is your compass in this
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 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 Rename a Folder in Linux
Renaming a folder in Linux is possible with Graphical User Interface (GUI) file managers as well as with powerful command-line utilities such as mv, rename, find, and rsync. Be it a novice utilizing Ubuntu, Debian, CentOS, Fedora, or Kali Linux or an expert dealing with bulk renaming in the terminal
12 min read