MTC logo MTC logo Midlands Technical College
Prospective StudentsEnrolled StudentsFaculty & StaffCommunity Partners
About
Academics
Continuing Education
Distance Learning
Student Forms
Library
Class Schedule
News & Updates
Calendar
Directory
Site Map
Ask MTC
MTC Jobs Bookstore
Home
navigation
 
Search

 

About MTC Academics Continuing Education Distance Learning Student Forms Library Class Schedule News & Updates Calendar Directory Site Map Ask MTC MTC Jobs Bookstore Home


CPT 247


Quick Reference

Exercise

Shellscript1

 

BASH Startup Files

The Bourne Again Shell uses several startup files.

    /etc/profile        a system-wide startup file

    a login initialization file composed one of the following :

    .bash_profile   

    .bash_login      

    .profile 

    Finally, bash looks in the home directory for the shell initialization file.

    .bashrc

After that, every interactive bash subshell executes the commands in .bashrc.

List the current settings of the environment variables.

This is done with the set command without arguments:

        BASH > set

Some common environment variables.

 

Variable

   Contents

HOME Pathname of your home directory
MAIL Pathname of your system mailbox
PATH Directories where shell is to look for commands
PS1 Primary prompt
PS2 Secondary prompt
PWD Present working directory
SHELL Pathname of login shell (/usr/bin/bash   or  /bin/bash )
TERM The termcap code for your terminal
USER Your user name

Setting the prompt.

    PS1="Your Majesty?"

    PS1= #

Commands for customizing prompt strings.

Command                           Meaning
\a  audible bell (ASCII code 007)
\d  date in "Weekday Month Day" format
\e  escape character (ASCII code 033)
\H  Hostname (long)
\h  hostname (short)
\n  newline (carriage return followed by a line feed)
\s  shell name
\T  Time in 12-hour "HH:MM:SS" format
\t  time in 24-hour "HH:MM:SS" format
\@  time in 12-hour "am/pm" format
\u  user name
\V  version of bash (long format)
\v  version of bash (short format)
\W  working directory
\w  working directory
\#  number of current command
\!  history number of current command
\$  # for superuser (UID of 0); $ for otherwise
\\  backslash
\nnn  ASCII character code (in octal)
\[  start if non-printing character sequence
\]  end of non-printing character sequence