1. Home
  2. Linux
  3. Switch bash to c shell linux

How to switch from Bash to C Shell on Linux

C Shell is a command-line shell for Unix that uses a C++ syntax, rather than the familiar Bash syntax. It’s an older shell, but loved in the Unix community by programmers. It’s available on Linux via Tcsh: a modification of the original C Shell that adds in new features and enhancements.

Want to use C Shell? Follow along with the steps below to switch from Bash to C Shell on Linux.

Note: You can switch from Bash to Fish Shell if you’re not a fan of C Shell. Alternatively, you can also try ZSH.

Install C Shell

C Shell is a pretty cool shell replacement for Bash. However, it’s likely that your Linux PC doesn’t have it set up by default. Luckily, the shell can easily be installed on most Linux distributions.

To install it, open up a terminal window and follow the instructions to get C Shell set up on the Linux operating system that you use on your computer.

Ubuntu

C Shell is in Ubuntu’s primary software sources and can be installed using the Apt package manager tool.

sudo apt install tcsh

Debian

Even though Debian Linux usually is behind on package updates, they manage to distribute a somewhat up to date version of C Shell in their primary software repository. It can be installed with the Apt-get packaging tool.

sudo apt-get install tcsh

Arch Linux

Arch Linux users love to experiment with alternatives to bash. As a result, even obscure Bash alternatives like C Shell are available for installation in the default software repository for the distribution. To get it on Arch, use the Pacman package tool.

sudo pacman -S tcsh

Fedora

Need C Shell on your Fedora Linux PC? You’ll need to install it with the Dnf package manager as it isn’t loaded up on Fedora by default.

sudo dnf install tcsh

OpenSUSE

Like the other mainstream Linux distributions out there, OpenSUSE has C Shell available as an alternative to Bash in their primary software sources. To install it, run the following Zypper command.

sudo zypper install tcsh

Generic Linux

So, you’re on a lesser-known Linux distribution, and you want to use C Shell. What do you do? Open up the terminal and search “tcsh” or “c shell” with your Linux PC’s package manager. You’re sure to find this package on even the most unknown Linux OS, as Tcsh has been around for quite a while.

List shells

Before being able to swap from Bash to C Shell on your Linux computer, you’ll need to figure out the location of the Tcsh binary on your computer. Knowing the location of this binary is critical because without this information Linux will be unable to swap the default command-line shell for your user.

To generate a list of command-line shells on your Linux PC, you must look at the /etc/shells/ file. There are multiple ways to view this file, but the most efficient way is with the cat command.

cat /etc/shells/

Running the cat command will spit out a list of the location of many different shells installed on your Linux PC. No doubt there will be more than one, and that can be confusing.

Note: If you don’t want to scan this file for “Tcsh,” consider combining the cat command with the grep command to filter it out.

cat /etc/shells | grep tcsh

Highlight the output of /etc/shells/ and make a copy of the location of C Shell. Alternatively, output it to a text file for later.

cat /etc/shells | grep tcsh >> tcsh-location.txt

Swap from Bash to C Shell

Making the C shell default is done with the chsh command. Please note that the chsh command must run without sudo or root permissions. If this command runs as root, you could inadvertently swap the shell for the root user on Linux, rather than your user.

In the terminal, use the chsh command and use it to swap from Bash (or whatever Shell you are using) to Tcsh.

chsh

Entering the chsh command in a terminal will print out “Enter the new value, or press ENTER for the default” on the screen. At this point, you’ll need        to specify the location of C Shell to set it as the default for your user.  Take a look at the output of /etc/shells and write out where C Shell is in the prompt window.

After specifying the location of C Shell in the Linux terminal, press Enter on the keyboard and input your user’s password. Repeat this process for every user that needs to use C Shell on your Linux PC.

Disable C Shell

Tried out C Shell and didn’t like it? Switch back by following the steps below!

Step 1: Open up a terminal and enter the change shell command.

chsh

Step 2: Write /bin/bash/ when asked to “enter a new value”.

Step 3: Enter your password. Then, close the terminal and reboot. Upon startup, Bash will be default again.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.