2
Most read
4
Most read
8
Most read
Linux Shell Environment
Content Updating Program(CUP)
On
Linux Programming
Shell Overview
What is a Shell?
 Linux shells provide a "command line" interface which allows
the user to enter commands.
 A shell is a program which reads and executes commands for the
user.
 Shell also usually provide features such as Job Control,
Input/output Redirection and a Command Language for writing
Shell Scripts.
 The user can pick their shell (just like the applications, desktop
manger, window manager, etc. on a LINUX system).
 On the UMBC GL network, the default UNIX shell is tcsh -
Turbo C Shell.
Shell Overview
 Shells available include:
 tcsh - Turbo C SHell
 csh - C SHell
 ksh - Korn SHell
 bash - Bourne Again SHell
 sh - SHell
 Linux Default Shell
 Most Linux systems (especially home installations) default to
the bash shell.
 Changing Your Shell - On a Home Based System
 Usually there is a command called chsh that stands for
change shell.
 You have to enter your password and then the absolute path
to the new shell that you wish to use.
Shell Environment Variables
 The bash shell uses a feature called ‘environment
variables’ to store information about the shell session
and the working environment.
 USE: - Many programs and scripts uses environment
variables
- to obtain system information
- to store temporary data
- configuration information.
 There are two types of environment variables
- Local Environment Variables
- Global Environment Variables
Gobal Environment Variables
 Global Env. Variables(GEV) are visible from
the shell session and from any child process that
the shell spawns.
 Linux system sets several GEV on start of Shell.
 System environment variables uses CAPITAL
letter to differ from user environment variables.
 To view the GEV, use command
$ printenv
GEV contiuned…..
 To display a value of individual env variable
 Use command
$ echo $HOME
Example of GEV available to Child process also…
Local Environment Variables
 LEV can be seen in the local processes in which
they are defined.
 Linux system also define standard LEV for user
by default.
 To view LEV use the command
$ set
(additional variables not in printenv are LEV)
SETTING Env Variables
 Setting LEV: Users are allowed to create local
variables that are visible within user shell process
 We can assign either numerical or string value to
and environment variable using equal sign (=)
 Example:
 $ test=testing
$ echo $test
 Standard Convention is use Lower case for LEV
and user Upper Case for GEV.
SETTING GEV continued…
 SETTING GEV:
Create a LEV and export it to global env.
Example:
$ test=‘testing your patience’
$ echo $test
$ export test
$ bash
$ echo $test
???
Removing Env. Variables
 Remove the Environment variable using
command – unset
Example:
$ unset test (don’t use $before variable..)
$ echo $test
Example for GEV…
Default Shell Env. Variables
 List of Default Variables…
Important Environment Variables
 HOME - your home directory.
 USER and LOGNAME - your login ID.
 HOSTNAME - the name of the host computer.
 PWD - the current working directory.
 MAIL - where your mail is located.
 PATH - a list of directories in which to look for executable
commands.
 Certain applications and commands may communicate with the
shell and reference the environment variables that it maintains.
 For example, it seems that frm and nfrm seem not to work if $MAIL is
not defined. frm and nfrm are commands to list the contents of your
inbox without logging into pine.
Setting the PATH env. variable
 PATH env. Variable includes all of the directories
where your applications resides.
 We can add new search directories to existing
PATH environment variable without rebuild it
from scratch.
 Example:
$ echo $PATH
---------------
$ PATH=$PATH:/home/user
$ echo $PATH
Locating System Env. variables
 When we start a bash shell by logging on to the
system, it searches several files for command,
These file are called Startup files.
Following is the order in which bash processes these
files:
 /etc/profile
 $HOME/.bash_profile
 $HOME/.bash_login
 $HOME/.profile
Variable Arrays
 Environment variables can be used as arrays.
 So it can hold multiple values.
 To set list them in parentheses separated by
comma.
 Example:
$ mytest=( one two three four five )
$ echo $mytest
????
$ echo ${mytest[2]}
???
Aliasing Commands
 A helpful feature, especially for many users new to LINUX, is
the alias function.
 The alias command assigns a command, possibly with many
options and flags, to another name. Usually it is a shorter name
or one that is easier to remember.
Setting up an alias:
 The exact syntax depends on the shell that you are using. We will
cover how to do it under tcsh and bash. Most other shells use a
similar or identical syntax.
 tcsh syntax:
 alias <aliased name> <original command>
 bash syntax:
 alias <aliased name>=<original command>
Example:
$ alias dir=‘ls –l’
$dir
Thank you …

More Related Content

PPT
Linux file system nevigation
PDF
Shell scripting
ODP
Linux Introduction (Commands)
PPTX
PPTX
Operating system
PPT
Vi editor in linux
PDF
Users and groups in Linux
PDF
Part 02 Linux Kernel Module Programming
Linux file system nevigation
Shell scripting
Linux Introduction (Commands)
Operating system
Vi editor in linux
Users and groups in Linux
Part 02 Linux Kernel Module Programming

What's hot (20)

PPTX
Linux standard file system
PPT
Shell Scripting
PPTX
Unix
PPTX
Operating Systems - File Management
PDF
Shell scripting
PPTX
Unit II - MS DOS Commands
PPTX
Linux device drivers
PDF
Course 102: Lecture 14: Users and Permissions
PPSX
User Administration in Linux
PDF
Linux Directory Structure
PDF
Lesson 2 Understanding Linux File System
PPT
Bootstrap process of u boot (NDS32 RISC CPU)
PPTX
Basic commands of linux
PDF
Linux practicals T.Y.B.ScIT
PDF
Quick Guide with Linux Command Line
PPTX
Presentation on samba server
PPTX
Unix OS & Commands
PDF
Introduction to char device driver
PPT
Linux Networking Commands
PPTX
Linux kernel
Linux standard file system
Shell Scripting
Unix
Operating Systems - File Management
Shell scripting
Unit II - MS DOS Commands
Linux device drivers
Course 102: Lecture 14: Users and Permissions
User Administration in Linux
Linux Directory Structure
Lesson 2 Understanding Linux File System
Bootstrap process of u boot (NDS32 RISC CPU)
Basic commands of linux
Linux practicals T.Y.B.ScIT
Quick Guide with Linux Command Line
Presentation on samba server
Unix OS & Commands
Introduction to char device driver
Linux Networking Commands
Linux kernel
Ad

Viewers also liked (20)

PPTX
Linux Shell Basics
PDF
Getting Started With Linux Administration
PPTX
Shell scripting
PPT
Shell Scripting in Linux
PDF
Complete Guide for Linux shell programming
PPTX
Unix environment
PDF
Linux day 2016 la shell in linux
PDF
How inodes Work
PPT
Shell programming
PDF
Intro to Linux Shell Scripting
DOC
RedHat Linux Administrator
PDF
Shell Scripting
PPTX
Linux commands
PDF
Linux Memory Management
PPT
Basic Linux Internals
PDF
Linux File System
PPT
Unix/Linux Basic Commands and Shell Script
PPT
Linux command ppt
PPTX
Linux Administrator - The Linux Course on Eduonix
PDF
Lesson 3 Working with Files in Linux
Linux Shell Basics
Getting Started With Linux Administration
Shell scripting
Shell Scripting in Linux
Complete Guide for Linux shell programming
Unix environment
Linux day 2016 la shell in linux
How inodes Work
Shell programming
Intro to Linux Shell Scripting
RedHat Linux Administrator
Shell Scripting
Linux commands
Linux Memory Management
Basic Linux Internals
Linux File System
Unix/Linux Basic Commands and Shell Script
Linux command ppt
Linux Administrator - The Linux Course on Eduonix
Lesson 3 Working with Files in Linux
Ad

Similar to Linux shell env (20)

PPTX
Licão 09 variables and arrays v2
ODP
Shellscripting
PPT
Introduction to shell scripting ____.ppt
PPT
Chap06
PPT
Using Unix
PPT
101 3.1 gnu and unix commands
PPTX
SHELL PROGRAMMING
PDF
Text mining on the command line - Introduction to linux for bioinformatics
PDF
60761 linux
PDF
Shell Scripting crash course.pdf
PDF
21bUc8YeDzZpE
PDF
21bUc8YeDzZpE
PDF
21bUc8YeDzZpE
PDF
(Ebook) linux shell scripting tutorial
PDF
Linux programming - Getting self started
PPT
UnixShells.ppt
PPT
UnixShells.pptfhfehrguryhdruiygfjtfgrfjht
PPT
Spsl by sasidhar 3 unit
PPTX
PPTX
Shell & Shell Script
Licão 09 variables and arrays v2
Shellscripting
Introduction to shell scripting ____.ppt
Chap06
Using Unix
101 3.1 gnu and unix commands
SHELL PROGRAMMING
Text mining on the command line - Introduction to linux for bioinformatics
60761 linux
Shell Scripting crash course.pdf
21bUc8YeDzZpE
21bUc8YeDzZpE
21bUc8YeDzZpE
(Ebook) linux shell scripting tutorial
Linux programming - Getting self started
UnixShells.ppt
UnixShells.pptfhfehrguryhdruiygfjtfgrfjht
Spsl by sasidhar 3 unit
Shell & Shell Script

More from Rahul Pola (11)

PPTX
UML Diagrams
PPTX
Automized Examination System
DOCX
Project Synopsis sample
DOC
Report format
PPTX
Sequence diagram
PPTX
Object diagram
PPT
Use case Diagram
PPT
Cloud Computing
PPT
Linux Information
PPTX
Cloud computing
PPTX
Android introduction
UML Diagrams
Automized Examination System
Project Synopsis sample
Report format
Sequence diagram
Object diagram
Use case Diagram
Cloud Computing
Linux Information
Cloud computing
Android introduction

Linux shell env

  • 1. Linux Shell Environment Content Updating Program(CUP) On Linux Programming
  • 2. Shell Overview What is a Shell?  Linux shells provide a "command line" interface which allows the user to enter commands.  A shell is a program which reads and executes commands for the user.  Shell also usually provide features such as Job Control, Input/output Redirection and a Command Language for writing Shell Scripts.  The user can pick their shell (just like the applications, desktop manger, window manager, etc. on a LINUX system).  On the UMBC GL network, the default UNIX shell is tcsh - Turbo C Shell.
  • 3. Shell Overview  Shells available include:  tcsh - Turbo C SHell  csh - C SHell  ksh - Korn SHell  bash - Bourne Again SHell  sh - SHell  Linux Default Shell  Most Linux systems (especially home installations) default to the bash shell.  Changing Your Shell - On a Home Based System  Usually there is a command called chsh that stands for change shell.  You have to enter your password and then the absolute path to the new shell that you wish to use.
  • 4. Shell Environment Variables  The bash shell uses a feature called ‘environment variables’ to store information about the shell session and the working environment.  USE: - Many programs and scripts uses environment variables - to obtain system information - to store temporary data - configuration information.  There are two types of environment variables - Local Environment Variables - Global Environment Variables
  • 5. Gobal Environment Variables  Global Env. Variables(GEV) are visible from the shell session and from any child process that the shell spawns.  Linux system sets several GEV on start of Shell.  System environment variables uses CAPITAL letter to differ from user environment variables.  To view the GEV, use command $ printenv
  • 6. GEV contiuned…..  To display a value of individual env variable  Use command $ echo $HOME Example of GEV available to Child process also…
  • 7. Local Environment Variables  LEV can be seen in the local processes in which they are defined.  Linux system also define standard LEV for user by default.  To view LEV use the command $ set (additional variables not in printenv are LEV)
  • 8. SETTING Env Variables  Setting LEV: Users are allowed to create local variables that are visible within user shell process  We can assign either numerical or string value to and environment variable using equal sign (=)  Example:  $ test=testing $ echo $test  Standard Convention is use Lower case for LEV and user Upper Case for GEV.
  • 9. SETTING GEV continued…  SETTING GEV: Create a LEV and export it to global env. Example: $ test=‘testing your patience’ $ echo $test $ export test $ bash $ echo $test ???
  • 10. Removing Env. Variables  Remove the Environment variable using command – unset Example: $ unset test (don’t use $before variable..) $ echo $test Example for GEV…
  • 11. Default Shell Env. Variables  List of Default Variables…
  • 12. Important Environment Variables  HOME - your home directory.  USER and LOGNAME - your login ID.  HOSTNAME - the name of the host computer.  PWD - the current working directory.  MAIL - where your mail is located.  PATH - a list of directories in which to look for executable commands.  Certain applications and commands may communicate with the shell and reference the environment variables that it maintains.  For example, it seems that frm and nfrm seem not to work if $MAIL is not defined. frm and nfrm are commands to list the contents of your inbox without logging into pine.
  • 13. Setting the PATH env. variable  PATH env. Variable includes all of the directories where your applications resides.  We can add new search directories to existing PATH environment variable without rebuild it from scratch.  Example: $ echo $PATH --------------- $ PATH=$PATH:/home/user $ echo $PATH
  • 14. Locating System Env. variables  When we start a bash shell by logging on to the system, it searches several files for command, These file are called Startup files. Following is the order in which bash processes these files:  /etc/profile  $HOME/.bash_profile  $HOME/.bash_login  $HOME/.profile
  • 15. Variable Arrays  Environment variables can be used as arrays.  So it can hold multiple values.  To set list them in parentheses separated by comma.  Example: $ mytest=( one two three four five ) $ echo $mytest ???? $ echo ${mytest[2]} ???
  • 16. Aliasing Commands  A helpful feature, especially for many users new to LINUX, is the alias function.  The alias command assigns a command, possibly with many options and flags, to another name. Usually it is a shorter name or one that is easier to remember. Setting up an alias:  The exact syntax depends on the shell that you are using. We will cover how to do it under tcsh and bash. Most other shells use a similar or identical syntax.  tcsh syntax:  alias <aliased name> <original command>  bash syntax:  alias <aliased name>=<original command> Example: $ alias dir=‘ls –l’ $dir