I've recently started to use FreeBSD operating system with tcsh (c shell clone) shell. I noticed that both set and setenv command set shell user environment. What's the difference between the SET and SETENV commands?
C Shell: set vs setenv
The c shell (tcsh or csh) sits between you and the operating system. It act as a command interpreter. It reads your command and translates the commands into actions taken by the Unix system. When the c shell starts up it reads its startup files and may set environment variables using setenv command.
All variables set with setenv command are automatically exported to subshell. All csh variables set to with set command are NOT automatically exported to subshell. In this example, set an enviorment variable called vech using set command:
set vech=bus echo "$vech"
Start a new shell
Try to display $vech, enter:
vech: Undefined variable.
Now, try same with setenv command:
setenv jaildir /nas/httpd echo "$jaildir" csh echo "$jaildir"
In short, set command is used for this shell and setenv for this and any subshells. Usually, all system environmental variable such as $HOME, $USER, $MAIL, $PATH, and others are defined using setenv command.Tweet itFacebook itG+ itDownload PDF versionFound an error/typo on this page?
- 30 Cool Open Source Software I Discovered in 2013
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012
- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop