SlideShare a Scribd company logo
2
Most read
3
Most read
4
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 command ppt
kalyanineve
 
PPT
Linux basics
Santosh Khadsare
 
PDF
Course 102: Lecture 22: Package Management
Ahmed El-Arabawy
 
PPT
Unix/Linux Basic Commands and Shell Script
sbmguys
 
PDF
Course 102: Lecture 20: Networking In Linux (Basic Concepts)
Ahmed El-Arabawy
 
PDF
Quick Guide with Linux Command Line
Anuchit Chalothorn
 
PDF
Launch the First Process in Linux System
Jian-Hong Pan
 
PPTX
Linux file system
Md. Tanvir Hossain
 
Linux command ppt
kalyanineve
 
Linux basics
Santosh Khadsare
 
Course 102: Lecture 22: Package Management
Ahmed El-Arabawy
 
Unix/Linux Basic Commands and Shell Script
sbmguys
 
Course 102: Lecture 20: Networking In Linux (Basic Concepts)
Ahmed El-Arabawy
 
Quick Guide with Linux Command Line
Anuchit Chalothorn
 
Launch the First Process in Linux System
Jian-Hong Pan
 
Linux file system
Md. Tanvir Hossain
 

What's hot (20)

PPTX
Bash Shell Scripting
Raghu nath
 
PPT
Shell and its types in LINUX
SHUBHA CHATURVEDI
 
PPT
History of Linux
Gray-chan Desu
 
PPTX
Linux kernel
Goutam Sahoo
 
PDF
Shell scripting
Manav Prasad
 
PPTX
Linux standard file system
Taaanu01
 
PPTX
Introduction 2 linux
Papu Kumar
 
PPT
Linux basic commands
MohanKumar Palanichamy
 
PDF
Linux Basic Commands
Hanan Nmr
 
PPTX
Basic commands of linux
shravan saini
 
PPTX
file system in operating system
tittuajay
 
PDF
Q2.12: Debugging with GDB
Linaro
 
PPTX
Linux.ppt
onu9
 
PDF
Basic linux commands
Shakeel Shafiq
 
PPT
Linux Administration
Harish1983
 
PPTX
Basics of shell programming
Chandan Kumar Rana
 
PDF
File System Hierarchy
sritolia
 
PPT
Shell Scripting
Gaurav Shinde
 
Bash Shell Scripting
Raghu nath
 
Shell and its types in LINUX
SHUBHA CHATURVEDI
 
History of Linux
Gray-chan Desu
 
Linux kernel
Goutam Sahoo
 
Shell scripting
Manav Prasad
 
Linux standard file system
Taaanu01
 
Introduction 2 linux
Papu Kumar
 
Linux basic commands
MohanKumar Palanichamy
 
Linux Basic Commands
Hanan Nmr
 
Basic commands of linux
shravan saini
 
file system in operating system
tittuajay
 
Q2.12: Debugging with GDB
Linaro
 
Linux.ppt
onu9
 
Basic linux commands
Shakeel Shafiq
 
Linux Administration
Harish1983
 
Basics of shell programming
Chandan Kumar Rana
 
File System Hierarchy
sritolia
 
Shell Scripting
Gaurav Shinde
 
Ad

Viewers also liked (20)

PPTX
Linux Shell Basics
Constantine Nosovsky
 
PDF
Getting Started With Linux Administration
Edureka!
 
PPTX
Shell scripting
simha.dev.lin
 
PPT
Shell Scripting in Linux
Anu Chaudhry
 
PDF
Complete Guide for Linux shell programming
sudhir singh yadav
 
PPTX
Unix environment
Er Mittinpreet Singh
 
PDF
Linux day 2016 la shell in linux
Giuseppe Piccolo
 
PDF
How inodes Work
Roman Tarnavski
 
PPT
Shell programming
Moayad Moawiah
 
PDF
Intro to Linux Shell Scripting
vceder
 
DOC
RedHat Linux Administrator
sowmya devi
 
PDF
Shell Scripting
Anil Kumar Pugalia
 
PPTX
Linux commands
Mannu Khani
 
PDF
Linux Memory Management
Anil Kumar Pugalia
 
PPT
Basic Linux Internals
mukul bhardwaj
 
PDF
Linux File System
Anil Kumar Pugalia
 
PPTX
Linux Administrator - The Linux Course on Eduonix
Paddy Lock
 
PDF
Lesson 3 Working with Files in Linux
Sadia Bashir
 
PPT
Slideshare Powerpoint presentation
elliehood
 
PPTX
Slideshare ppt
Mandy Suzanne
 
Linux Shell Basics
Constantine Nosovsky
 
Getting Started With Linux Administration
Edureka!
 
Shell scripting
simha.dev.lin
 
Shell Scripting in Linux
Anu Chaudhry
 
Complete Guide for Linux shell programming
sudhir singh yadav
 
Unix environment
Er Mittinpreet Singh
 
Linux day 2016 la shell in linux
Giuseppe Piccolo
 
How inodes Work
Roman Tarnavski
 
Shell programming
Moayad Moawiah
 
Intro to Linux Shell Scripting
vceder
 
RedHat Linux Administrator
sowmya devi
 
Shell Scripting
Anil Kumar Pugalia
 
Linux commands
Mannu Khani
 
Linux Memory Management
Anil Kumar Pugalia
 
Basic Linux Internals
mukul bhardwaj
 
Linux File System
Anil Kumar Pugalia
 
Linux Administrator - The Linux Course on Eduonix
Paddy Lock
 
Lesson 3 Working with Files in Linux
Sadia Bashir
 
Slideshare Powerpoint presentation
elliehood
 
Slideshare ppt
Mandy Suzanne
 
Ad

Similar to Linux shell env (20)

PPTX
Licão 09 variables and arrays v2
Acácio Oliveira
 
ODP
Shellscripting
Narendra Sisodiya
 
PPT
Introduction to shell scripting ____.ppt
nalinisamineni
 
PPT
Chap06
Dr.Ravi
 
PPT
Using Unix
Dr.Ravi
 
PPT
101 3.1 gnu and unix commands
Acácio Oliveira
 
PPTX
SHELL PROGRAMMING
jinal thakrar
 
PDF
Text mining on the command line - Introduction to linux for bioinformatics
BITS
 
PDF
60761 linux
Ritika Ahlawat
 
PDF
Shell Scripting crash course.pdf
harikrishnapolaki
 
PDF
21bUc8YeDzZpE
Aniruddh Tyagi
 
PDF
21bUc8YeDzZpE
aniruddh Tyagi
 
PDF
21bUc8YeDzZpE
aniruddh Tyagi
 
PDF
(Ebook) linux shell scripting tutorial
jayaramprabhu
 
PDF
Linux programming - Getting self started
Emertxe Information Technologies Pvt Ltd
 
PPT
UnixShells.ppt
EduardoGutierrez111076
 
PPT
UnixShells.pptfhfehrguryhdruiygfjtfgrfjht
singingalka
 
PPT
Spsl by sasidhar 3 unit
Sasidhar Kothuru
 
PPTX
Linux
Srinivas Reddy
 
PPTX
Shell & Shell Script
Amit Ghosh
 
Licão 09 variables and arrays v2
Acácio Oliveira
 
Shellscripting
Narendra Sisodiya
 
Introduction to shell scripting ____.ppt
nalinisamineni
 
Chap06
Dr.Ravi
 
Using Unix
Dr.Ravi
 
101 3.1 gnu and unix commands
Acácio Oliveira
 
SHELL PROGRAMMING
jinal thakrar
 
Text mining on the command line - Introduction to linux for bioinformatics
BITS
 
60761 linux
Ritika Ahlawat
 
Shell Scripting crash course.pdf
harikrishnapolaki
 
21bUc8YeDzZpE
Aniruddh Tyagi
 
21bUc8YeDzZpE
aniruddh Tyagi
 
21bUc8YeDzZpE
aniruddh Tyagi
 
(Ebook) linux shell scripting tutorial
jayaramprabhu
 
Linux programming - Getting self started
Emertxe Information Technologies Pvt Ltd
 
UnixShells.ppt
EduardoGutierrez111076
 
UnixShells.pptfhfehrguryhdruiygfjtfgrfjht
singingalka
 
Spsl by sasidhar 3 unit
Sasidhar Kothuru
 
Shell & Shell Script
Amit Ghosh
 

More from Rahul Pola (11)

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

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