SlideShare a Scribd company logo
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

What's hot

What's hot (20)

Php and MySQL
Php and MySQLPhp and MySQL
Php and MySQL
 
Functions Of Operating System
Functions Of Operating SystemFunctions Of Operating System
Functions Of Operating System
 
Shell and its types in LINUX
Shell and its types in LINUXShell and its types in LINUX
Shell and its types in LINUX
 
Bash shell
Bash shellBash shell
Bash shell
 
Vi editor in linux
Vi editor in linuxVi editor in linux
Vi editor in linux
 
PHP - Introduction to File Handling with PHP
PHP -  Introduction to  File Handling with PHPPHP -  Introduction to  File Handling with PHP
PHP - Introduction to File Handling with PHP
 
Unix
UnixUnix
Unix
 
File system Os
File system OsFile system Os
File system Os
 
Process management os concept
Process management os conceptProcess management os concept
Process management os concept
 
Operators in PHP
Operators in PHPOperators in PHP
Operators in PHP
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Linux operating system ppt
Linux operating system pptLinux operating system ppt
Linux operating system ppt
 
Linux process management
Linux process managementLinux process management
Linux process management
 
Function C programming
Function C programmingFunction C programming
Function C programming
 
Unix operating system architecture with file structure
Unix operating system architecture with file structure Unix operating system architecture with file structure
Unix operating system architecture with file structure
 
directory structure and file system mounting
directory structure and file system mountingdirectory structure and file system mounting
directory structure and file system mounting
 
Filepermissions in linux
Filepermissions in linuxFilepermissions in linux
Filepermissions in linux
 
An Introduction to Linux
An Introduction to LinuxAn Introduction to Linux
An Introduction to Linux
 
Unix OS & Commands
Unix OS & CommandsUnix OS & Commands
Unix OS & Commands
 
Unix ppt
Unix pptUnix ppt
Unix ppt
 

Viewers also liked

Getting Started With Linux Administration
Getting Started With Linux AdministrationGetting Started With Linux Administration
Getting Started With Linux AdministrationEdureka!
 
Shell Scripting in Linux
Shell Scripting in LinuxShell Scripting in Linux
Shell Scripting in LinuxAnu Chaudhry
 
Complete Guide for Linux shell programming
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programmingsudhir singh yadav
 
Linux day 2016 la shell in linux
Linux day 2016   la shell in linuxLinux day 2016   la shell in linux
Linux day 2016 la shell in linuxGiuseppe Piccolo
 
Intro to Linux Shell Scripting
Intro to Linux Shell ScriptingIntro to Linux Shell Scripting
Intro to Linux Shell Scriptingvceder
 
RedHat Linux Administrator
RedHat Linux AdministratorRedHat Linux Administrator
RedHat Linux Administratorsowmya devi
 
Unix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell ScriptUnix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell Scriptsbmguys
 
Linux command ppt
Linux command pptLinux command ppt
Linux command pptkalyanineve
 
Linux Administrator - The Linux Course on Eduonix
Linux Administrator - The Linux Course on EduonixLinux Administrator - The Linux Course on Eduonix
Linux Administrator - The Linux Course on EduonixPaddy Lock
 
Lesson 3 Working with Files in Linux
Lesson 3 Working with Files in LinuxLesson 3 Working with Files in Linux
Lesson 3 Working with Files in LinuxSadia Bashir
 

Viewers also liked (20)

Linux Shell Basics
Linux Shell BasicsLinux Shell Basics
Linux Shell Basics
 
Getting Started With Linux Administration
Getting Started With Linux AdministrationGetting Started With Linux Administration
Getting Started With Linux Administration
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Shell Scripting in Linux
Shell Scripting in LinuxShell Scripting in Linux
Shell Scripting in Linux
 
Complete Guide for Linux shell programming
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programming
 
Unix environment
Unix environmentUnix environment
Unix environment
 
Linux day 2016 la shell in linux
Linux day 2016   la shell in linuxLinux day 2016   la shell in linux
Linux day 2016 la shell in linux
 
How inodes Work
How inodes WorkHow inodes Work
How inodes Work
 
Shell programming
Shell programmingShell programming
Shell programming
 
Intro to Linux Shell Scripting
Intro to Linux Shell ScriptingIntro to Linux Shell Scripting
Intro to Linux Shell Scripting
 
RedHat Linux Administrator
RedHat Linux AdministratorRedHat Linux Administrator
RedHat Linux Administrator
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory Management
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
 
Linux File System
Linux File SystemLinux File System
Linux File System
 
Unix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell ScriptUnix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell Script
 
Linux command ppt
Linux command pptLinux command ppt
Linux command ppt
 
Linux Administrator - The Linux Course on Eduonix
Linux Administrator - The Linux Course on EduonixLinux Administrator - The Linux Course on Eduonix
Linux Administrator - The Linux Course on Eduonix
 
Lesson 3 Working with Files in Linux
Lesson 3 Working with Files in LinuxLesson 3 Working with Files in Linux
Lesson 3 Working with Files in Linux
 

Similar to Linux shell env

Similar to Linux shell env (20)

Licão 09 variables and arrays v2
Licão 09 variables and arrays v2Licão 09 variables and arrays v2
Licão 09 variables and arrays v2
 
Shellscripting
ShellscriptingShellscripting
Shellscripting
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Chap06
Chap06Chap06
Chap06
 
Using Unix
Using UnixUsing Unix
Using Unix
 
101 3.1 gnu and unix commands
101 3.1 gnu and unix commands101 3.1 gnu and unix commands
101 3.1 gnu and unix commands
 
SHELL PROGRAMMING
SHELL PROGRAMMINGSHELL PROGRAMMING
SHELL PROGRAMMING
 
Text mining on the command line - Introduction to linux for bioinformatics
Text mining on the command line - Introduction to linux for bioinformaticsText mining on the command line - Introduction to linux for bioinformatics
Text mining on the command line - Introduction to linux for bioinformatics
 
60761 linux
60761 linux60761 linux
60761 linux
 
Shell Scripting crash course.pdf
Shell Scripting crash course.pdfShell Scripting crash course.pdf
Shell Scripting crash course.pdf
 
21bUc8YeDzZpE
21bUc8YeDzZpE21bUc8YeDzZpE
21bUc8YeDzZpE
 
21bUc8YeDzZpE
21bUc8YeDzZpE21bUc8YeDzZpE
21bUc8YeDzZpE
 
(Ebook) linux shell scripting tutorial
(Ebook) linux shell scripting tutorial(Ebook) linux shell scripting tutorial
(Ebook) linux shell scripting tutorial
 
21bUc8YeDzZpE
21bUc8YeDzZpE21bUc8YeDzZpE
21bUc8YeDzZpE
 
Linux programming - Getting self started
Linux programming - Getting self started Linux programming - Getting self started
Linux programming - Getting self started
 
UnixShells.ppt
UnixShells.pptUnixShells.ppt
UnixShells.ppt
 
Spsl by sasidhar 3 unit
Spsl by sasidhar  3 unitSpsl by sasidhar  3 unit
Spsl by sasidhar 3 unit
 
Linux
LinuxLinux
Linux
 
Shell & Shell Script
Shell & Shell Script Shell & Shell Script
Shell & Shell Script
 

More from Rahul Pola

Automized Examination System
Automized Examination SystemAutomized Examination System
Automized Examination SystemRahul Pola
 
Project Synopsis sample
Project Synopsis sampleProject Synopsis sample
Project Synopsis sampleRahul Pola
 
Sequence diagram
Sequence diagramSequence diagram
Sequence diagramRahul Pola
 
Object diagram
Object diagramObject diagram
Object diagramRahul Pola
 
Use case Diagram
Use case Diagram Use case Diagram
Use case Diagram Rahul Pola
 
Cloud Computing
Cloud ComputingCloud Computing
Cloud ComputingRahul Pola
 
Linux Information
Linux InformationLinux Information
Linux InformationRahul Pola
 
Cloud computing
Cloud computingCloud computing
Cloud computingRahul Pola
 
Android introduction
Android introductionAndroid introduction
Android introductionRahul Pola
 

More from Rahul Pola (11)

UML Diagrams
UML  DiagramsUML  Diagrams
UML Diagrams
 
Automized Examination System
Automized Examination SystemAutomized Examination System
Automized Examination System
 
Project Synopsis sample
Project Synopsis sampleProject Synopsis sample
Project Synopsis sample
 
Report format
Report formatReport format
Report format
 
Sequence diagram
Sequence diagramSequence diagram
Sequence diagram
 
Object diagram
Object diagramObject diagram
Object diagram
 
Use case Diagram
Use case Diagram Use case Diagram
Use case Diagram
 
Cloud Computing
Cloud ComputingCloud Computing
Cloud Computing
 
Linux Information
Linux InformationLinux Information
Linux Information
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 
Android introduction
Android introductionAndroid introduction
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