Shells

Changing your shell

By default, ECE linux machines use bash(1) for their default shell; if you prefer to use another shell, you may change it with chsh(1), for example:
chsh -s /usr/bin/tcsh

You should bear in mind that if you are changing your shell on a machine that is part of a cluster or lab of machines, such as the color machines, the Wean Hall 3716 cluster, or the ECE cluster, you should ensure that you execute the chsh command on the lead machine of that cluster; otherwise, your change will only apply to that particular machine and will revert overnight to its previous state.

Shell Control Files

When you login to a unix-like system, your shell environment is described by various environment variables. You can see the entire list by executing env. There are various methods to control your environment, including automatic execution of scripts to set these variables; these are called your shell control files.

Invocation

How the shell was invoked affects which files will be executed for you upon startup.

Login

It is a login shell if you have done one of the following:

ssh user@hostname
logged in physically at the machine
bash --login
sudo su -

Bash will attempt to execute the following for you:

  • /etc/profile
  • ~/.bash_profile
  • ~/.bash_login
  • ~/.profile

Interactive

It is an interactive shell if you have done one of the following:

bash
sudo su
ssh user@hostname 'some command'
start the shell from within a desktop environment such as KDE or GNOME

For interactive, non-login shell invocation, bash will attempt to execute only:

  • ~/.bashrc

~/.bashrc should never echo output to the screen for the following reasons:

  • scp/sftp will fail
  • ssh user@hostname ‘some command’ will echo that output instead of the expected STDOUT from the ‘some command’.

Non-interactive

It is a non-interactive shell if you have done one of the following:

sh somefile
bash somefile
bash -c somefile
su user -c somefile

Bash will not automatically attempt to execute control files for non-interactive shells, you will need to manually source any files that you need to set environment variables or other customisations.

This entry was posted in Software. Bookmark the permalink.