User Tools

Site Tools


opus:fall2012:jcavalu3:unixpart2

unix Keyword 2

shabang

Definition

A shabang is this: #! The shabang is used to read the following test on the first line after it to determine what interpreter the user would like to… use. Some example of interpreters (Taken directly from http://en.wikipedia.org/wiki/Shebang_(Unix):

  • #!/bin/bash – Execute the file using sh, the Bourne shell, or a compatible shell
  • #!/bin/csh – Execute the file using csh, the C shell, or a compatible shell
  • #!/usr/bin/perl -T – Execute using Perl with the option for taint checks
  • #!/usr/bin/php – Execute the file using the PHP command line interpreter
  • #!/usr/bin/python -0 – Execute using Python with optimizations to code
  • #!/usr/bin/ruby – Execute using Ruby

References

unix Keyword 2 Phase 2

PATH environment variable

Definition

The $PATH variable specifies a list of one or more directory names separated by colons.

The /bin, /usr, and /local directories are typically included in most users' $PATH settings. The current directory is sometimes included, allowing programs in the current directory to be executed. Superuser (root) accounts as a rule are not include in $PATH, however, in order to prevent the accidental execution of scripts in the current directory.

When a command name is specified by the user or an exec call is made from a program, the system searches through $PATH, examining each directory from left to right in the list, looking for a filename that matches the command name. Once found, the program is executed as a child process of the command shell or program that issued the command.

References

Demonstration

The following is an example of a $PATH:

lab46:~/src/opus/opus2$  

The $PATH The home directory (~/) is the beginning of this specified $PATH, followed by the src directory, then the opus directory, and lastly the opus2 directory.

opus/fall2012/jcavalu3/unixpart2.txt · Last modified: 2012/10/30 18:35 by jcavalu3