Recent Changes - Search:

Help Topics

User Accounts

Network Access

Other/Outdated Documentation

Additional Help

Staff Docs

  • (Private)

edit SideBar

FAQ /

UnixShells


1.  Changing your shell

To change your shell, from a prompt type chsh. It will ask you for your current password and then give you a list of shells which you may choose from. Type in the full path name from the list given of the shell which you want to use. It will ask you if the information that you typed in is correct. You will then be returned to your prompt.

Note that /bin/tcsh is the ECE/CIS supported shell. If you choose another shell, such as /usr/bin/ksh or /bin/bash you are on your own if you run into problems.


2.  Changing your Finger Information

To change the information that shows up when you run the finger command, type chfn from a prompt. It will ask you for your current password and then prompt you for each of the information fields. To stick with the default value for that field (printed within the [] symbols), simply hit the return or enter key. After going through each of the three fields (full name, office location, and office phone number), you will be asked to confirm the correctness of the information. You will then be returned to your prompt.

Any of these changes will take a couple of hours to take effect.


3.  tcsh, .cshrc/.login and environment variables

The supported login shell is tcsh, although users may also select others if they so desire. Tcsh is much more powerful than csh and should be used. ~/.cshrc is the startup file that csh/tcsh read. tcsh will read ~/.tcshrc instead if it exists. ~/.login is read on login. These are the files that set up a user's environment. Prototypes of these files, the ones new users receive, are in /usr/local/lib/startup.

There are two sets of variables that csh and tcsh use. Environment variables are passed down to child processes and are set with setenv and can be viewed with printenv. Shell variable are only used by the shell and are set with set, and can be viewed with echo $var. setenv does not use an '=' to assign variables, but set does. An example follows:

After changing something in your .cshrc you need to either source it by typing "source .cshrc" in each window you want the change to take effect or by logging out and back in.

  • A very important Environment variable is PATH.
  • A very important Shell variable is path.
  • PATH is a colon separated list of directories.
  • path is a space separated list of directories.

These two variable do the same thing, sets the search path to find executable programs. You don't have to worry about maintaining both, of them, just one will do, as csh/tcsh will automatically set the other when you change one of them. For example:

> echo $path
/usr/local/bin /bin
> printenv PATH
/usr/local/bin:/bin

> set path = ( /usr/local/bin /bin /usr/sbin )
> echo $path  \\ /usr/local/bin /bin /usr/sbin
> printenv PATH 
/usr/local/bin:/bin:/usr/sbin

> setenv PATH ${PATH}:/usr/local/etc 
> echo $path
/usr/local/bin /bin /usr/sbin /usr/local/etc 
> printenv PATH 
/usr/local/bin:/bin:/usr/sbin:/usr/local/etc

> set path = ( ${path} . ) 
> echo $path 
/usr/local/bin /bin /usr/sbin /usr/local/etc . 
> printenv PATH 
/usr/local/bin:/bin:/usr/sbin:/usr/local/etc:.

As the preceding shows $var or ${var} will give the value of var. The last example show include '.' in the path. That is the current directory. If you include '.' in your path it should be last, after all system directories, and not first as bad things can happen with it first.


4.  Man pages

Man is short for manual and is how things are documented in Unix. Run man man to read the manual system's manual page.

MANPATH is an environment variable used by man to find man pages. It is a colon separated list of directories for man to look in for man pages. Alternatively you man specify the directory to look in with the -M option to man. The directory the man page is in must either be in MANPATH or in one specified by the -M option for man to find it. The directories actually have subdirectories for the different sections of the manual, which contain the files. For example, ls -l /usr/man/..

The manual has several sections. Sometimes you need to know what section the man page is in. For example, if you want the man page for the write() system call, you need to do man -s 2 write as man would first find the write command in section one which are user commands. On Linux the -s can be left off. Another useful option to man is -k to search for a keyword. For example, man -k write.

Man pages are often in nroff format. What man basically does is find the man page, then do an nroff -man filename| $PAGER. So if you change this to nroff -man filename | lpr, it will be sent to the printer. This requires finding the location of the man page however. On most systems with enscript, you can simply use man filename | enscript -PPrinterName.

Note: If you have missing man pages on some systems such as mlb, you may need to add /usr/share/man to your manpath.


5.  Using ps and killing processes

The command to get a listing of processes is ps. This command comes in two flavors, BSD and SYSV. If you are on a Solaris host, uname -sr is SunOS 5.x, then do a which ps to find out which ps you are using by default. /usr/bin/ps is SYSV and is faster, while /usr/ucb/ps is BSD.

Now that you know which flavor ps you are using you now can give it the right options to get what you want. With the SYSV version you probably will want to use ps -elf, which will list all processes on the host in long format. With the BSD version ps -augxww will do a similar job. Piping the output to grep may be helpful, for example, ps -elf | grep $USER. The SYV version also has a -u option which takes a username to limit the output to processes running for that user. Check the man page, man ps, for more info. Solaris users may find the -o option to /usr/bin/ps helpful.

To kill a process first try kill PID, where PID is the PID of the process to kill. See the previous answer on ps which will give you the PID. If that doesn't kill the process try kill -9 PID instead.

Also, there are pgrep and pkill commands. pgrep will return the PID(s) of a process that matches the expression. pkill will send a signal to process(es) that match an expression. See their man page for more info.


6.  Supported text editors

  • vi -- /usr/ucb/vi
  • vim -- /usr/local/bin/vim Be sure to use color_xterm
    • (/usr/local/X11R6/bin/color_xterm) to get syntax highlighting to work- also put the following lines in your .vimrc:
 syntax on
 set hlsearch
 :if &term =~ "xterm"
   :if has("terminfo")
   :  set t_Co=16
   :  set t_AB=ESC[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm
   :  set t_AF=ESC[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm
   :else
   :  set t_Co=16
   :  set t_Sf=ESC[3%dm
   :  set t_Sb=ESC[4%dm
   :endif
 :endif
 (Note that the ESC is the esacpe key sequence inserted with Ctrl+v and  in vi)
  • emacs -- /usr/local/gnu/bin/emacs
  • xemacs -- /usr/local/xemacs/xemacs Note this location points to the most recent installed version
  • pico -- /usr/local/bin/pico

For more info on editors:

vi:

emacs and xemacs:


7.  Password-less SSH Authentication

If you'd like to ssh between hosts without using a password, you can set up key-based authentication as follows. This will work between all ece/cis hosts that share home directories.

  > ssh-keygen -t dsa
  Enter file in which to save the key (/usa/<username>/.ssh/id_dsa): <enter>
  Enter passphrase (empty for no passphrase): <enter>
  Enter same passphrase again: <enter>

  > cat ~/.ssh/id_dsa.pub >>! ~/.ssh/authorized_keys

You can now append your ~/.ssh/id_dsa.pub to other authorized_keys files in other home directories in order to move between research and acad systems, or between research and private computers.

For added security, use a passphrase when creating your key. This way, you're not only authenticated by your key, you're also authenticated by a password -- twice as secure.


Comments

To add a comment, click the link below. You are free to contribute anonymously, but it is preferred that you sign your comments with your name. Simply add ~~~~ to the end of your comment to sign it. Regardless of whether you sign your comment, your username will be visible on the History page.
(Add Your Own)


Edit - History - Print - Recent Changes - Search
Page last modified on September 29, 2008, at 01:16 AM