#acl HlpLabGroup:read,write,delete,revert All:read #format wiki #language en #pragma section-numbers 2 = Setting up your Unix environment = Most of the Unix interaction in the lab will be on the command line. Graphical desktops exist for Unix, including [[http://www.gnome.org/|GNOME]] and [[http://www.kde.org/|KDE]] on top of [[http://www.x.org/|X11]], and MacOS X, where the Unix underpinnings are thoroughly hidden most of the time. There are two command shells that you are going to encounter on our systems. On the Macs you will be using the Bourne Shell ({{{sh}}} or more likely its successor {{{bash}}} or '''B'''ourne '''A'''gain '''Sh'''ell) unless you change your shell, and on the Linux systems in CS you will be using the C Shell ({{{csh}}} or more likely its successor {{{tcsh}}} or Tenex C Shell). For most day to day use they are functionally equivalent. However they have very different scripting languages and ways of setting up the environment. The main concept that we need to worry about for setting up the environment is how to set environmental variables. ----- == Bash == The Bourne Shell was originally written by Stephen Bourne at AT&T Bell Labs in the mid-to-late 1970s. Most systems now use Bash, which is an extended replacement written by the [[http://www.fsf.org|Free Software Foundation]] for the [[http://www.gnu.org|GNU]] project. === .bash_profile === At login the system automatically runs a file in your home directory called {{{.bash_profile}}} to set up the environment. You will need to edit this file to be able to use some third party software installed on the Macs. If you choose to change your shell on the CS Linux machines to Bash, you'll have to convert the C Shell settings given in later in this page to Bash syntax. Below are some shell commands you'll need to know and then some settings you'll want to change. ==== comments ==== Anything after a {{{#}}} is a comment. This is useful for documenting why you are doing something or to temporarily prevent the evaluation of a line of the file. ==== export ==== Unlike the C Shell, which makes a distinction between shell variables and environment variables, Bash sets them both the same way: with the {{{export}}} command. ==== Changes you need to make ==== Set the following environmental variables if you work with the TGrep2 corpus search tool: {{{#!highlight sh numbers=disable HLP="/p/hlp" export HLP TGREP2ABLE="$HLP/corpora/TGrep2able" export TGREP2ABLE TGREP2_CORPUS="$TGREP2ABLE/swbd.t2c.gz" export TGREP2_CORPUS TDT="/p/hlp/tools/TDT" export TDT TDT_DATABASES="$TDT/databases" export TDT_DATABASES SWBD_XML_DATABASES="/p/hlp/corpora/p-swbd/SWBD-xml-2-15-08/PAGE/Data/xml/" export SWBD_XML_DATABASES }}} The following lines change your path so you can use Python (2.4.4 instead of the default 2.3.5), La``Tex, Tcl/Tk, SBCL Common Lisp, Image``Magick, and Subversion: {{{#!highlight sh numbers=disable PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}:/usr/local/bin:/usr/texbin:/p/hlp/bin" export PATH }}} ==== Optional changes ==== You may or may not like the default command prompt that Apple uses. Luckily the prompt can be changed. The following is a nice prompt: {{{#!highlight sh numbers=disable PS1="\u@\h:\w\$ " export PS1 }}} This shows your username @ computer name : working directory $ If you want to have colors in Terminal.app, add the following line: {{{#!highlight sh numbers=disable export CLICOLOR=1 }}} ---- == C Shell == The C Shell was originally written by Bill Joy at UC Berkeley in the mid-1970s. (This should sound familiar if you've read the [[Vim|Vi(m)]] page.) It was given the name because the syntax of its scripting language is designed to be similar to the C programming language. Almost all modern systems (including the CS system here at Rochester) actually use the Tenex C Shell, which is a heavily extended rewrite of the original. === .cshrc === At login the system automatically runs a file in your home directory called {{{.cshrc}}} to set up the environment. You will need to edit this file to be able to use the corpus tools. Below are some shell commands you'll need to know and then some settings you'll want to change. ==== comments ==== Anything after a {{{#}}} is a comment. This is useful for documenting why you are doing something or to temporarily prevent the evaluation of a line of the file. ==== set and unset ==== {{{set}}} and {{{unset}}} are used to manage built-in shell variables. ==== setenv and unsetenv ==== {{{setenv}}} and {{{unsetenv}}} are used to manage environment variables. ==== alias and unalias ==== {{{alias}}} and {{{unalias}}} are used to alias commands to other commands. ==== Changes you need to make ==== Somewhere near the top of the file, but after the {{{#!highlight sh numbers=disable # Do Not Remove This source /usr/staff/lib/defaults/system.cshrc }}} lines, add the following lines for environment variables related to the corpus tools: {{{#!highlight sh numbers=disable # Corpus related variables setenv HLP /p/hlp setenv NLP /p/nl setenv TOOLS $HLP/tools setenv TDT $TOOLS/TDT setenv TDT_DATABASES $TDT/databases setenv TGREP2ABLE $HLP/corpora/TGrep2able setenv TGREP2_CORPUS $TGREP2ABLE/brown.t2c.gz }}} On the last line with {{{TGREP2_CORPUS}}} set the value of the part after the final forward slash to one of the corpora in the {{{/p/hlp/corpora/TGrep2able/}}} directory. For this example I've used the Brown corpus. We also need to change our path to add the directory with the corpus tools. This needs to come somewhere after the corpus related variables we just set, as it references one of them. {{{#!highlight sh numbers=disable # PATH addition set path = ($path $home/bin $HLP/bin) }}} ==== Optional changes ==== Near the bottom of the CS provided {{{.cshrc}}} there is a section that starts with the comment {{{#!highlight sh numbers=disable # add all INTERACTIVE commands here, specifically, any stty or prompt setting }}} In between the {{{if}}} and {{{endif}}} following that, you can set some nice optional settings. You may or may not like the default command prompt that the CS environment uses. Luckily the prompt can be changed. The following sets a nice prompt: {{{#!highlight sh numbers=disable set promptchars = "%#" set prompt = "%n@%m:%~ %# " }}} This shows your username @ computer name : working directory % (if normal user) | # (if superuser) If you worry about accidentally deleting files, add the following to have the system ask permission before deleting each file: {{{#!highlight sh numbers=disable alias rm 'rm -i' }}} If this gets annoying you can always type {{{unalias rm}}} at the command line to turn off interactive mode for {{{rm}}} until you logout. If you don't want to be accidentally logged out if you hit `^D` (aka EOF or "end of file"): {{{#!highlight sh numbers=disable set ignoreeof }}} If you don't want it to be possible to overwrite a file through output redirection: {{{#!highlight sh numbers=disable set noclobber }}}