TCSH / CSH Shell Set PATH Variable

I am a new Unix / Linux / Apple OS X user. What is my path in CSH / TCSH shell? How do I set or modify path in c shell (CSH) on Unix like operating systems?

The PATH is an environment variable. It is a colon delimited list of directories that your shell searches through when you enter a command. All executables are kept in different directories on the Linux and Unix like operating systems.
Tutorial details
DifficultyEasy (rss)
Root privilegesNo
howto- Setting an environment variable in csh
A search path is the sequence of directories in which the c shell (CSH/TCSH) looks for commands to execute.


Print current PATH settings in C SHELL

Open the terminal and type the following command to print the current $PATH settings. You can use any one of the following command:

# use echo to display it ##
echo "$PATH"


## or use printenv
printenv PATH

Sample outputs:


The character between each directory in the C shell’s the PATH environment variable has colons. You can also use the following $path variable:

## note lower case ##
echo "$path"
## OR ##
printf "%s\n" $path

Sample outputs:

/usr/bin /bin /usr/sbin /sbin /usr/local/bin /opt/X11/bin /usr/local/sbin/modemZapp /Users/vivek/gcutil-1.8.4

The character between each directory in the C shell’s $path variable is a space. The C shell search path includes /usr/bin, /bin, /usr/sbin, and rest of the all directories displayed by the echo command.

Method #1: CSH / TCSH set path variable command for interactive use

You can add a directory called /usr/local/bin and $HOME/bin to to the search path by entering the following command:

### *** NOTE: $path is case sensitivity and must be in lowercase *** ###
set path = ($path /usr/local/bin)
echo $path

Sample outputs:

/usr/bin /bin /usr/sbin /sbin /usr/local/bin /opt/X11/bin /usr/local/sbin/modemZapp /Users/vivek/gcutil-1.8.4 /usr/local/bin

All directories are searched in the order they appear in the search path. Setting paths with $path variable is recommended for all your shell commands that you type directly. You can add second path using the same syntax:

### *** NOTE: $path is case sensitivity and must be in lowercase *** ###
set path = ($path /usr/local/bin $HOME/bin)
echo $path

Sample outputs:

/usr/bin /bin /usr/sbin /sbin /usr/local/bin /opt/X11/bin /usr/local/sbin/modemZapp /Users/vivek/gcutil-1.8.4 /usr/local/bin /Users/vivek/bin

Method #2: Csh/Tcsh add to $PATH

You can use the following syntax:

## please note 'PATH' is CASE sensitivity and must be in UPPERCASE ##
setenv PATH $PATH\:/dir/path1
setenv PATH $PATH\:/dir/path1\:/dir/path2

Please feel free to replace /dir/path1 with the directory you want the shell to search. If you skip \ before :, you will get an error message that read as follows:

Bad : modifier in $ (/).

How do I set path in tcsh/csh automatically on Unix/Linux?

You may want to set search path automatically each time you log in by appending any one of the following command in ~/.login or ~/.cshrc file (you need to type the command at shell prompt):

## command to append path settings in ~/.login file ##
echo 'set path = ($path /usr/local/bin $HOME/bin .)' >> ~/.login


## command to append path settings in ~/.cshrc file ##
echo 'setenv PATH $PATH\:/usr/local/bin\:$HOME/bin\:.'  >> ~/.cshrc

See csh(1) and tcsh(1) man page for more information.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

4 comments… add one
  • Sharath Jul 3, 2014 @ 15:58

    I think method #2 has a typo. I tried and it doesn’t work.
    Here’s what works for me (Notice the additional ‘\’ character in the expression.)
    setenv PATH $PATH\:/dir/path

    • manas Jan 18, 2016 @ 15:37

      Man ,Sharath u da man

      Its absolutely right .. WIthout the \ , u are doomed with following output :{xmomana}61: setenv PATH $PATH:/usr/bin
      Bad : modifier in $ (/).

      • 🐧 Vivek Gite Jan 18, 2016 @ 21:32

        The FAQ has been updated. Thanks for the heads up!

  • joseph veliz Mar 31, 2016 @ 20:56

    set path = ( $path usr/local/bxh/bin )

    does not set path, when I check with echo $path

    I have other paths set and they work ok.

    But when I go far back as usr/ , the path is not set

    Any help is appreciated

    Mac OSX 10.6.8

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.