In this tutorial I will show you, how to set a new PATH in csh and tcsh.
The PATH is an environment variable that tells the shell where to look for the basic executables (commands) you use (such as ping, useradd, etc). Setting a new PATH depends on the shell, not on the Linux or Unix distro.
The default shell in FreeBSD and PCBSD is the C shell (csh).
In this article I will show you how to set the PATH in csh and tcsh:
To use tcsh in Linux, install it first:
On Debian: sudo apt-get install tcsh
On Fedora: sudo yum install tcsh
On openSUSE: sudo zypper install tcsh
How to set the PATH in csh and tcsh:
I will temporary add the /home/razvan/myscripts in my PATH:
set path = ( $path /path/to/new/dir)
After the first reboot, the PATH changes will be discarded, unless you set them persistently:
$ set path = ($path /home/razvan/myscripts)
The directories in the path are separated one from another by space (white space):
How to set the PATH permanently
To permanently set a new PATH in csh and tcsh add this to your user’s shell configuration file (~cshrc for csh and tcsh):
set path = ($path /path/to/new/dir)
$ echo "set path = ($path /home/razvan/myscripts)" >> ~/.cshrc
For tcsh: If the ~/.tcshrc file exists, this file will be used instead of the ~/.cshrc .
To display the path’s value ($PATH) user: echo $path.
Related reading: How to change the PATH in bash, ksh and zsh.