The default shell in Linux plays a crucial role in how users interact with the system. This guide explains how to change the default shell in Linux using various methods like the usermod
command, chsh
utility, or direct editing of the /etc/passwd
file, offering flexibility for customizing your shell experience.
Table of Contents
- Types of Shells
- How to Check and List Available Shells
- Who Can Change the Shell?
- Methods to Change the Default Shell
- Method 1: Using the
usermod
Command - Method 2: Using the
chsh
Utility - Method 3: Editing the
/etc/passwd
File Directly
- Method 1: Using the
What is a Shell?
A shell is a command-line interface (CLI) that enables users to interact with the operating system by typing commands. It acts as a bridge between the user and the operating system, interpreting and executing the commands entered by the user on the kernel level. The shell provides a way to control the computer’s resources, run programs, manage files, and automate tasks.
Key Functions of a Shell:
- Command Execution: The shell takes user input in the form of commands and executes them.
- Scripting: Shells support scripting, which allows users to automate repetitive tasks by writing scripts.
- Process Management: The shell helps manage system processes, such as starting, stopping, or monitoring running applications.
- File Management: Users can navigate the file system, and create, delete, and modify files and directories.
- Redirection and Piping: Shells allow output from one command to be passed as input to another command, enhancing flexibility.
Types of Shells
- Bash (Bourne Again Shell): The default shell on many Linux distributions and macOS. It’s known for its features like command history, job control, and scripting capabilities.
- Zsh (Z Shell): A more advanced shell with features like improved autocompletion, better globbing, and support for plugins.
- Fish (Friendly Interactive Shell): A user-friendly shell with a modern design, offering features like syntax highlighting, autosuggestions, and easy configuration.
- Csh (C Shell): A shell with a C-like syntax, used in some UNIX systems for scripting and interactive use.
- Tcsh: An enhanced version of Csh with additional features like filename completion and command-line editing.
How to Check the Current Shell:
The current shell for a user is stored in the /etc/passwd
file. This file contains essential information about user accounts, including the login shell. To find your current shell, run the following command:
$> grep $(whoami) /etc/passwd
The output will display the current user’s information, including their shell. For example:

Listing Available Shells:
Before changing the shell, check which shells are installed on your system. Use this command:
$> cat /etc/shells
The output will list all available shells. For example:

Who Can Change the Shell?
1. Standard Users: Can change their shell to any listed in `/etc/shells`.
2. Root Users: Can change the shell for any user.
3. Restricted Accounts: Require root privileges to modify their shell.
Methods to Change the Default Shell
Method 1: Using the `usermod
` Command
The `usermod
` command modifies system account files, including the `/etc/passwd
` file. Use the `-s` or `–shell` option to change the shell for a specific user.
Use the command below to change the shell of a user to `/bin/bash`:
$> sudo usermod --shell /bin/bash USERNAME

Method 2: Using the `chsh
` Utility
The `chsh` (change shell) utility provides a simpler way to change a user’s login shell. It also modifies the `/etc/passwd
` file.
Use the command below to change the shell of a user from `/bin/sh` to `/bin/bash`:
$> chsh -s /bin/bash USERNAME
You’ll be prompted for the password to confirm the change.

Method 3: Editing the `/etc/passwd
` File Directly
You can manually edit the `/etc/passwd
` file to change the user’s shell.
1. Open the file in a text editor:
Here, we are using Nano Text Editor.
$> sudo nano /etc/passwd

2. Locate the user entry. For example:

3. Replace the shell path with the desired shell. For example:

4. Save and exit the editor.