Using the school's Linux systems

From rs_faq
Jump to: navigation, search

Feel free to add some useful info, tips and tricks about using the school's Linux systems here.

Whether it be about your desktop machine, wallace & gromit, the clusters, shell scripts or UMS... feel free to share!

Contents

UMS

UMS is user maintained software. It is normally much more up-to-date than the School's default installation. It has its own page detailing how to set it up.

C Shell

The default command line shell that the School uses is the C shell. You can change this (see below). If you do decide to use C shell, there are some things you can change to make life easier. In the '~/.cshrc' file (where ~ represents your home directory), you can try the following:

Setting aliases

An alias is like a shortcut, to save typing. The command below:

alias lll 'ls -l|more'

binds the command 'lll' to a detailed directory listing. There is a section listed in your .cshrc file for additional aliases to be inserted.

Changing your Command Prompt

This might seem like a pointless thing to do, but the default prompt is very basic, just showing the machine you're working on. You might want to show the directory you're currently in. The following example:

set prompt="%{^[[37m%}[%@] %{^[[0m%}${user}@%m[%B%/%b]% "

changes your prompt to something like this:

[12:42pm] abc@acws-0123[/home/pg/abc]%

Of course, you can mess about with this as you wish, but the syntax is very unforgiving, so look it up if you're unsure (note: could someone link to a tutorial please?)

Note that you're strongly advised to save a backup of your .cshrc file before messing with it!

Alternative Shells

Using a different shell

The school's systems default to using the C shell, which may not be your favourite choice for every day use. However, you can't switch to a different shell using 'chsh', since, according to Support, many parts of the system rely on you having csh as your default shell.

You can however, get around this as far as your interactive shells are concerned.

A simple approach (using the example of zsh) is to append the following lines to the end of your ~/.login file:

if ($?prompt) then
  exec zsh
endif

This ensures that in interactive shells only, zsh is started as the very last thing, after doing everything else that needs to be done. If you prefer bash to zsh, then just replace 'zsh' with 'bash' instead.

Remember though, that you should still set all the environment variables and whatnot in your ~/.cshrc, since these will need to exist for non-login shells too.

Note: If you don't check whether the shell is interactive (i.e. by using the conditional statement), then this will prevent you from running scripts on the school's clusters, as they rely on csh.

(Thanks to Christopher James Coleman, who was an undergraduate here several years ago, for originally publicising the method which developed into this).

If you want to explicitly check who started the shell, you can add something like this (which allows you to start csh from bash):

if ($?prompt) then
  # Interactive shell
 
  # if not called directly from bash, then start bash to replace csh
  # first find the parent process name
  set parent_id=`ps h -o ppid -p $$`
  set parent_cmd=`ps h -o command -p $parent_id`
 
  # Check if our parent process is bash
  if ("$parent_cmd" != "bash") then
    exec bash
  endif
 
  # If got here - want a real C shell
 
endif
Personal tools