To set the default shell in a Unix-like operating system, such as Linux or macOS, you typically use the
chsh (change shell) command. This command allows you to change the login shell for your user account. Here’s how you can do it:
1. Find Available Shells
First, you might want to see a list of all shells installed on your system. You can do this by checking the
This command will display a list of valid login shells available on your system. Common entries include
2. Change the Default Shell
To change your default shell, use the
chsh command followed by the
-s option (to specify the shell), and the path to the desired shell. For example, to change to
zsh, you would use:
chsh -s /bin/zsh
/bin/zsh with the path to your desired shell as listed in
3. Enter Password (if prompted)
You may be prompted to enter your password to confirm the change.
4. Restart or Log Out
For the change to take effect, you may need to log out and log back in, or restart your terminal session.
- macOS Users: If you are using a recent version of macOS (Catalina or later), the default shell is already
zsh. To change it to
bashor another shell, the same method applies.
- System-Wide Changes: The
chshcommand changes the shell for your user only. To change the shell system-wide (which is not recommended for typical use cases), you would need to modify the default shell for each user account individually or change the system configuration, which requires administrative privileges.
- Administrative Users: If you are an administrative user and want to change the shell for another user, you can use
sudo chsh -s shell_path username, replacing
shell_pathwith the desired shell and
usernamewith the target user’s username.
Always be cautious when changing the default shell, especially if you’re new to the command line, as it can affect how your terminal behaves and how scripts are executed.