SEO, Internet Marketing, Search Engine Optimization, Search Engine Marketing by www.websquash.com

Shell Introduction

   For Shell , there are Two types of Shell as below :

    1. Shell Introduction
    2.Environment Variable

 I. Shell Introduction

    There are many Shells in UNIX system, but B shell and C shell are usually used in IN system. These chapters are about these two shell types.


  •       B Shell
              -  /etc/profile
  
              -  $HOME/.profile


 

  •      C Shell
              -  $HOME/.cshrc
     
              -  $HOME/.login


      Description :

  •    B Shell and C Shell are the most important shells in mini computer of IN system.
                - B Shell is a interpretive programming language. It can execute the commands read from terminal and file.
                - C Shell is an interpretive command language tool, which supports command history buffering, task controlling, aliasing and so on.

  •     B Shell
          The most important environment files for B Shell are  /etc/profile  and $HOME/.profile.

                -   /etc/profile is an environment file that effects the whole system. It is run by the user who uses B Shell. Only user root has the write permission for this file. Other users can only modify their own ".profile" to define their environment.

                -  $HOME/.profile is environment file for a certain user. If a user who want to change default environment variables, he should create or modify the file  .profile, This file is always used to define or set the environment variables during login, set the user terminal and execute a program.

  •     C Shell
            The most important environment files for C Shell are  $HOME/.cshrc  and $HOME/.login

               - When a user login using C Shell, the Shell searches a file whose name is  .login. If  C shell finds the file  .login , System will run the command in file .login  , Otherwise, the system runs the file $HOME/.cshrc  instead.


--------------------------------------------------------------------------------------------------------------

  What is Home Directory ?

  •        Home directory
                - The default directory that we login using the environment variables.

  •       Example : 
               # cd                   //Go to the current user root's home directory

               #pwd
                /                        //User root's home directory is  /

                # su - win          //Switch to user win and using the corresponding environment variables (including home directory)

                % cd                  //Go to the current user win's home directory

                % pwd

                  /opt/win          //User informix's home directory is /opt/win


       Description : 

    If we want to switch to the other user using command su - abc, it means we want to use the user abc's environment variables. Otherwise, do not use abc's environment variables.

     Practice the real situation : 

 


Please login as the user employeeA, then answer the questions as below : 

    - Question 1 : 

      Please switch to user employeeB without Changing the current directory and write down the answer.

     - Answer  : 


        ___________________________________________


      - Question 2 : 

        Please switch to user employeeC using employeeC's environment variables and write down the answer. 

      - Answer : 


         ____________________________________________


        
---------------------------------------------------------------------------------------------------------------


Environment Variable

  • Environment describes the session to the running programs.
  • Environment Variable - Every shell program started receives its information about the user's environment from these variables.

     Description : 

  •    Environment includes information as below :
              Home directory
              Time Zone when working
              Who are you when login
              Where can shell file search commands
               Type and size of terminal and so on

  • The command to display current environment variables is env.
             Example :

            % env
             
             TERM=vt100                                        // Current terminal type

              SHELL=/usr/bin/csh
              HOME=/opt/etc

----------------------------------------------------------------------------------------------------------------

more , grep

 
     - Syntax :
   
          - more -a filter for examining continuous text, one screen at a time, on a soft-copy terminal.

          - grep - search a file for a pattern

     - Examples:

          # env | more

          Display the current environment information on screen at a time

          # env | grep HOME

          Get the current home directory

Description:


  • More Examples:
           % su - scp
   
           % env | grep HOME

           HOME=/opt/scp

           % cd /tellin/scp
           % pwd
            /tellin/scp
            
            % cd
            % pwd
            /opt/scp

       Note:

  •    The sign " | "is a pipe which means the result before it will be the input of the latter command.
  •    Home directory is always stored in the file /etc/passwd

--------------------------------------------------------------------------------------------------------------------

How to Set Environment Variable ?

  • To set terminal type, in B Shell or POSIX shell, use export TERM = vt100
  • To set terminal type, in C shell , use setenv TERM vt100
      The most commonly used terminal type is vt100.

       The command only has a temporary effect. When user logs in the system for the second time, the effect will disappear. Modification in the corresponding environment files is the permanent method. (Note : In C shell, do not forget to take the files into effect using "source".)





Click here for read the next article : Common Commands and Tools






Share on Google Plus

About Unknown

0 comments:

Post a Comment

If there is any comments,Please leave a comment at here.

loading...
Sponsor by