Software & AppsOperating SystemLinux

How To Set Fish as Default Shell in Ubuntu

Ubuntu 18

In this article, we’ll be discussing how to set Fish as the default shell in Ubuntu. The Fish shell, or the ‘Friendly Interactive SHell’, is known for its user-friendly features and powerful auto-suggestions. If you’re looking to switch from the default Bash shell to Fish in Ubuntu, this guide is for you.

Quick Answer

To set Fish as the default shell in Ubuntu, you can use the chsh command or the usermod command. Alternatively, you can add Fish to your .bashrc file. It’s important to be cautious when changing your default shell and to refer to the Fish documentation for troubleshooting tips if needed.

What is a Shell?

A shell is a user interface that allows access to various services of an operating system. It can be either a command-line interface (CLI) or a graphical user interface (GUI). The default shell in most Linux distributions is Bash, but there are several alternatives available, one of which is Fish.

Installing Fish

Before setting Fish as the default shell, you need to install it. Open a terminal and use the following command to install Fish:

sudo apt-get install fish

This command uses the apt-get package manager to install the Fish shell. The sudo command is used to execute the command with root privileges.

Setting Fish as the Default Shell

There are several methods to set Fish as the default shell in Ubuntu. We’ll discuss three of them.

Method 1: Using chsh Command

The chsh command, short for ‘change shell’, is used to change the login shell of a user. To set Fish as your default shell, use the following command:

chsh -s $(which fish)

Here, chsh -s is used to specify the shell, and $(which fish) returns the path of the Fish shell. You need to log out and log back in for the changes to take effect.

To set Fish as the default shell for another user, use sudo and add the username at the end:

sudo chsh -s $(which fish) username

Method 2: Using usermod Command

The usermod command modifies the system account files to reflect the changes that are specified on the command line. To set Fish as the default shell for a user, use the following command:

sudo usermod -s /usr/bin/fish username

Replace “username” with the desired username. This command will permanently change the shell for the specified user.

Method 3: Adding Fish to .bashrc

You can also add Fish to your .bashrc file. This will load Fish when you open a new terminal, but it will still be running on top of Bash. To do this, open the .bashrc file in a text editor:

nano ~/.bashrc

Then, add the line fish at the end of the file. Save the file and exit.

Reverting Back to Bash

If you want to switch back to Bash, use the following command from within Fish:

chsh -s (which bash)

Conclusion

Switching to the Fish shell can greatly enhance your productivity due to its advanced features. However, it’s important to understand the implications of changing your default shell. Always be cautious when using chsh or usermod with sudo to avoid accidentally changing the root shell. If you encounter any issues, refer to the Fish documentation for troubleshooting tips and additional information.

Can I use Fish shell alongside other shells?

Yes, you can use Fish shell alongside other shells. By adding Fish to your .bashrc file, it will load Fish when you open a new terminal, but it will still be running on top of Bash.

How do I switch back to Bash shell?

To switch back to Bash shell, use the following command from within Fish: chsh -s (which bash). This will set Bash as your default shell again.

Can I set Fish as the default shell for another user?

Yes, you can set Fish as the default shell for another user. Use the sudo chsh -s $(which fish) username command, replacing "username" with the desired username.

Where can I find more information about Fish shell?

You can find more information about Fish shell in the Fish documentation. The documentation provides troubleshooting tips and additional information about using Fish shell.

Leave a Comment

Your email address will not be published. Required fields are marked *