The C shell (or CSH) is one of the earliest UNIX/Linux shell interpreters, developed by Bill Joy at the University of California, Berkeley, in the late 1970s, inspired by the C programming language.
Along with Bash and Korn Shell, these three were the most popular shell interpreters in the early 1990s and distributed as the default login shell in most UNIX/Linux systems.
On systems like macOS or Red Hat, instead of C shell, you will find its extended version, Tcsh (also known as “tee-see-shell” or “tee-shell“), as a symbolic link pointing towards its original source.
The “t” in “tcsh” comes from the “T” in the TENEX operating system, and many features were taken from this OS as inspiration by the author of Tcsh while studying at Carnegie Mellon University.
The Tcsh added features are enhanced history substitution (which allows you to execute previously entered commands using the “↑” and “↓” keys), spelling correction, and word completion (press the tab button to autocomplete).
The following is a list of known features:
- History substitutions
- Job control facilities
- Interactive filename and command completion
- Support C-like syntax
- Support shell script execution
- Backward compatible with the C shell
While Tcsh was popular way back in time, it lost its popularity as it stepped backward. Even today, you will rarely find any UNIX/Linux system with Tcsh as the default login shell, except for BSD systems.
Even if you want to give it a try, I recommend you go with Tcsh (instead of C Shell).
How to Install Tcsh in Linux
By default, Tcsh is included in most Linux repositories and can be easily installed using the default package manager.
To install it, execute one of the following commands based on your system type:
$ sudo apt install tcsh #On Debian and Ubuntu $ sudo dnf install tcsh #On Fedora and RHEL $ sudo pacman -S tcsh # On Arch and Manjaro
After the installation is complete, execute the following command to verify its existence:
$ which tcsh #OR $ tcsh --version
You can enter in interpreter mode by executing the tcsh command; however, execute the following command if you want to have it as your default shell:
Also Read: 3 Ways to Change User’s Login Shell in Linux
$ chsh -s $(which tcsh)
After the above command is executed, logout from your system to reflect the changes, and then execute the following command to verify your default shell:
$ echo $0
You can also notice the default “$” representing the Bash interpreter is replaced with “>” in Tcsh.
A Few Differences Between the Tcsh and Bash
If you were a Bash user and switched to Tcsh for a short or long time, then you would find the following differences between them:
Setting Shell Variables
In Bash, you can directly specify the variable name (or key) to initialize; however, Tcsh requires the set keyword before the variable name (or key) while initializing.
> set var1=testing > echo $var1
Creating Environment Variables
The export command used in Bash to create an environment variable does not work in Tcsh; instead, you need to use the setenv command and specify the variable in “KEY VALUE” format without using the equals sign, as shown.
> setenv var1 testing > printenv var1
Adding Directory to the $PATH Variable
The $PATH variable stores the list of directories used to look for binary or program files that are executed from your terminal.
Tcsh also uses the same variable for searching binaries and programs; however, adding a path to this variable is different from Bash, as shown.
> set path = ($path $HOME/script/) > echo $PATH
The above command will add the “/home/linuxtldr/script” path to the $PATH variable.
Creating Aliases in Tcsh
Creating aliases in Tcsh is identical to Bash, except you have to avoid using the equals sign.
> alias www "cd /var/www/html" > alias www
Tcsh Configuration Files
The Tcsh utilizes different configuration files for login and non-login shells instead of Bash, as shown.
- For login shell: “/etc/csh.cshrc“, “/etc/csh.login“, “~/.tcshrc“, “~/.cshrc“, and “~/.login“.
- For non-login shell: “/etc/csh.cshrc“, “~/.tcshrc“, and “~/.cshrc“.
- Logout clean up: “/etc/csh.logout” or “~/.logout“.
That’s all the difference as a beginner you should know about Tcsh.
How to Remove Tcsh in Linux
If you are bored with Tcsh and want to remove it immediately from your system, then execute the following command to change back to your previous shell (ex: bash):
> chsh -s /bin/bash
After executing the above command, log out and log back in to your system to reflect the changes, then execute the following command to verify your existing shell:
$ echo $0
Lastly, execute any one of the following commands to remove Tcsh from your Linux system:
$ sudo apt remove tcsh #On Debian and Ubuntu $ sudo dnf remove tcsh #On Fedora and RHEL $ sudo pacman -R tcsh # On Arch and Manjaro
That’s all you need to do to remove Tcsh from your Linux system.
We will end the article here, but if you want me to write more articles related to this topic, let me know in the comment section.
Join The Conversation
Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.