CIS Header Left CIS Header Center
C-2-100 Mackinac Hall
1 Campus Drive
Allendale, MI 49401

Phone:616-331-2060
Fax:616-331-2106
email: info@cis.gvsu.edu


ABET Accredited Symbol

The Computer Science and Information Systems programs are accredited by the Computing Accreditation Commission of ABET.
Find us on Facebook

Find us on Twitter
Environment Variables & Startup Files

Index->Environment Variables & Startup Files

Environment Variables & Startup Files

In this lab, we will experiment with a few additional tricks in Linux. Linux maintains several variables that affect what you can do at the command line.

Command Prompt

  1. Check your PS1 variable by typing "echo $PS1"
  2. Reset your prompt temporarily, by typing PS1="CIS rules> "

Search Path

Linux searches for the location of any command you enter. It needs to know in which directories to look. The PATH environment variable contains a list of directories.

  1. Check your PATH variable, "echo $PATH". Notice that each of the distinct directories are separated by a colon.
  2. Try to run the C program 'myFirst' from last lab without putting the 'dot slash' in front. Linux can not find the correct command because your current directory is not in your search path.
  3. Modify the search path so that Linux will look in your current directory, type PATH=$PATH:. (note the colon after the second PATH name). This command tells Linux to take the original PATH, add the current directory to it, and then reassign it to the original PATH. As a last resort, Linux will look in your current directory for a program to execute.
  4. Check your PATH variable again. See the colon at the end?
  5. Now try to run your first C program again.

Aliases

You can customize some commands that you often use. An alias is a command created by you that is often a shortcut for longer commands.

  1. List your current aliases by typing, "alias". Note that some have been created for you already.
  2. Now create your own, "alias c=cal"
  3. Now type 'c' and press return
  4. Now create a second alias, "alias x='ls -al'"
  5. Now type 'x' and press return

Remote Access

  1. Try "who". This lists every user that is currently logged into your computer. It might just be you or could also be several other people that have remotely logged on.
  2. Try "ssh". This is a more secure version of 'telnet'. It allows you to remotely connect to any computer on the Internet if you have an account. Connect your neighbor's computer in the lab using the appropriate computer name such as "ssh eos12.cis.gvsu.edu". You should be able to log into the machine.
  3. Try "who" again after your neighbor computer is connected to your machine.
  4. Log out of the other machine, "exit".

Start Up Files

Taking the time to customize aliases and environment variables does not seem to help much if they reset each time you log out. Fortunately, you can place these customizations into a special file that is called automatically every time you log in. On our system, one of the special files is called ".bashrc". Note that it begins with a period.

  1. In your home directory, make a backup of your bashrc file, "cp .bashrc .bashrc.bak"
  2. Edit your original .bashrc file using a text editor such as vi. Add a line for each alias you want to create. Such as:
        alias h='history'
        alias p='ps -a'
        
  3. Add your name at the top in a comment field and save the file
  4. Manually execute your .bashrc file using the dot command
        . .bashrc
        
  5. Check your aliases by typing
        alias
        
  6. If you choose to modify your path so that you can run files in your current directory, make sure you place it after the if statement that is already in the file.
        export PATH=$PATH:.
        
  7. Print your .bashrc file with your name in it and at least one additional alias. Hand in your printout to your instructor.

This page was last modified November 27 2007.
Send comments to the CIS School Webmaster.
Copyright ©1995 - 2009 Grand Valley State University.
GVSU is an Equal Opportunity/Affirmative Action Institution.