SlideShare a Scribd company logo
4
Most read
6
Most read
7
Most read
Introduction to Unix and OS
Module 2
Dr. Girisha G S
Dept. of CSE
SoE,DSU, Bengaluru
Customizing the Unix Environment
Agenda
 The Shells
 Environment Variables
 Command Aliases- Shorthand names for commands
 Command History
 The Initialization Scripts
- You can find out what shell you are using like this:
$ echo $SHELL
/bin/bash
- Shell features are customizable
- The default prompt for the Bourne, Bourne Again, and Korn shells is the
dollar sign ($).
- The default prompt for the C shell is the percent sign (%).
- The default prompt for root in either shell is the pound sign (#).
$ env
Common Environment Variables
$ set
DISPLAY=:0.0
EDITOR=/usr/bin/vi
SHELL=/bin/bash
TERM=xterm-256color
USER=geek
- Environment variables are variables that are set up in your shell when you log in.
- The environment variables are managed by the shell.
Customizing Environment Variable: PS1
- The shell primary prompt string is $ stored in the shell variable PS1, and you can
customize it according to your preference.
Example : change the primary prompt string to present working directory
$ PS1=”$PWD -> “
/home/user->
Customizing Environment Variable : PATH
- The PATH variable contains a list of directory path names, separated by colons for
executing commands and scripts and you can customize it according to your
preference.
Example: Include the home directory in the PATH variable
$ PATH=$PATH:/home/user
- You can display a single variable with a simple echo command.
Example: $ echo $PWD
/home/user
Aliases
- Aliases let you assign shorthand names to frequently used commands
alias: This command assign shorthand names to command
The syntax is as follows:
$ alias shortname=“command [options]”
Example: Create an alias called list, which will use the ls command to print a long-style
listing of all files in the current directory
$ alias list=‘ls –la’
$ list
unalias: this command unset an alias
Example: To unset alias list
$ unalias list
Command history
- Lets you recall previous commands and edit/ re-execute them
- Every command is treated as an event and assigned an event number
- Using this number you can recall previous command, edit them if
required and re-execute them
history: this command displays the history list showing the event number
of every previously executed command
Example: $ history
Example : display the last two commands
$ history 2
- The symbol ! Is used to repeat previous commands
Example: re-execute the command with event number 12
$ !12
- To repeat the previous command, use !!
Example : $ !!
Accessing previous commands by event numbers
Accessing previous commands by context
- When you don’t remember the event number of a command but
know that the command started with a specific letter of a string,
you can use the history facility with context
Example: repeats the last command beginning with v
$ !v
- You can specify a numeric argument to specify the number of previous commands to display
The Initialization Scripts
- The start up scripts are executed when the user logs in
- The initialization scripts in different shells are:
The Profile
- If you'd like to set the environment variables permanently, add your settings to
the initialization file
In the bash login shell, the startup scripts are executed in the following order
/etc/profile
~/.bash_profile
~/.bash_login
~/.profile
- reads and executes commands from the first one that exists
- If none exists, /etc/bashrc applied
- When a login shell exits, bash reads and executes commands from the file,
~/.bash_logout, if it exists.
- Every time you change the profile file, You can execute it by using a special command
(called dot).
Example : $ . .profile
The specific settings which an unix user usually does is:
― Setting of any environment variable
― Setting of any alias
― Setting of PATH variable or any other path variables
$cat $HOME/.profile
export PATH=$PATH:~blogger/bin
alias l="ls -lrt"
A typical profile file will look as shown below
The rc File
- This type of file is run every time a new shell is opened up even if it is not a login
shell.
- This file is ~/.bashrc for the bash shell
- The rc file is used to define command aliases, variable settings, and shell options.
- The rc file will be executed after the profile.
Ad

Recommended

Licão 09 variables and arrays v2
Licão 09 variables and arrays v2
Acácio Oliveira
 
Logrotate sh
Logrotate sh
Ben Pope
 
Bash Shell Scripting
Bash Shell Scripting
Raghu nath
 
Shell scripting
Shell scripting
Manav Prasad
 
Basics of shell programming
Basics of shell programming
Chandan Kumar Rana
 
My sql
My sql
Nadhi ya
 
DevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung Foo
brian_dailey
 
Shellscripting
Shellscripting
Narendra Sisodiya
 
Chap06
Chap06
Dr.Ravi
 
Easiest way to start with Shell scripting
Easiest way to start with Shell scripting
Akshay Siwal
 
Unix lab manual
Unix lab manual
Chaitanya Kn
 
Unix And Shell Scripting
Unix And Shell Scripting
Jaibeer Malik
 
101 3.1 gnu and unix commands
101 3.1 gnu and unix commands
Acácio Oliveira
 
Parsing JSON with a single regex
Parsing JSON with a single regex
brian d foy
 
Linux system admin
Linux system admin
Mohammed Zainul Abiddin
 
Unix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU Karnataka
iCreateWorld
 
Perl from the ground up: variables and data types
Perl from the ground up: variables and data types
Shmuel Fomberg
 
Perl from the ground up: objects and testing
Perl from the ground up: objects and testing
Shmuel Fomberg
 
Bash shell
Bash shell
xylas121
 
Unix shell scripts
Unix shell scripts
Prakash Lambha
 
Quick start bash script
Quick start bash script
Simon Su
 
Unit 11 configuring the bash shell – shell script
Unit 11 configuring the bash shell – shell script
root_fibo
 
Unix shell scripting basics
Unix shell scripting basics
Manav Prasad
 
Unix Basics
Unix Basics
Dr.Ravi
 
spug_2008-08
spug_2008-08
colinmeyer
 
Shell Scripting
Shell Scripting
Gaurav Shinde
 
Raspberry pi Part 4
Raspberry pi Part 4
Techvilla
 
Shell scripting
Shell scripting
Geeks Anonymes
 
SHELL PROGRAMMING
SHELL PROGRAMMING
jinal thakrar
 
Course 102: Lecture 10: Learning About the Shell
Course 102: Lecture 10: Learning About the Shell
Ahmed El-Arabawy
 

More Related Content

What's hot (20)

Chap06
Chap06
Dr.Ravi
 
Easiest way to start with Shell scripting
Easiest way to start with Shell scripting
Akshay Siwal
 
Unix lab manual
Unix lab manual
Chaitanya Kn
 
Unix And Shell Scripting
Unix And Shell Scripting
Jaibeer Malik
 
101 3.1 gnu and unix commands
101 3.1 gnu and unix commands
Acácio Oliveira
 
Parsing JSON with a single regex
Parsing JSON with a single regex
brian d foy
 
Linux system admin
Linux system admin
Mohammed Zainul Abiddin
 
Unix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU Karnataka
iCreateWorld
 
Perl from the ground up: variables and data types
Perl from the ground up: variables and data types
Shmuel Fomberg
 
Perl from the ground up: objects and testing
Perl from the ground up: objects and testing
Shmuel Fomberg
 
Bash shell
Bash shell
xylas121
 
Unix shell scripts
Unix shell scripts
Prakash Lambha
 
Quick start bash script
Quick start bash script
Simon Su
 
Unit 11 configuring the bash shell – shell script
Unit 11 configuring the bash shell – shell script
root_fibo
 
Unix shell scripting basics
Unix shell scripting basics
Manav Prasad
 
Unix Basics
Unix Basics
Dr.Ravi
 
spug_2008-08
spug_2008-08
colinmeyer
 
Shell Scripting
Shell Scripting
Gaurav Shinde
 
Raspberry pi Part 4
Raspberry pi Part 4
Techvilla
 
Shell scripting
Shell scripting
Geeks Anonymes
 
Easiest way to start with Shell scripting
Easiest way to start with Shell scripting
Akshay Siwal
 
Unix And Shell Scripting
Unix And Shell Scripting
Jaibeer Malik
 
101 3.1 gnu and unix commands
101 3.1 gnu and unix commands
Acácio Oliveira
 
Parsing JSON with a single regex
Parsing JSON with a single regex
brian d foy
 
Unix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU Karnataka
iCreateWorld
 
Perl from the ground up: variables and data types
Perl from the ground up: variables and data types
Shmuel Fomberg
 
Perl from the ground up: objects and testing
Perl from the ground up: objects and testing
Shmuel Fomberg
 
Bash shell
Bash shell
xylas121
 
Quick start bash script
Quick start bash script
Simon Su
 
Unit 11 configuring the bash shell – shell script
Unit 11 configuring the bash shell – shell script
root_fibo
 
Unix shell scripting basics
Unix shell scripting basics
Manav Prasad
 
Unix Basics
Unix Basics
Dr.Ravi
 
Raspberry pi Part 4
Raspberry pi Part 4
Techvilla
 

Similar to Customizing the unix environment (20)

SHELL PROGRAMMING
SHELL PROGRAMMING
jinal thakrar
 
Course 102: Lecture 10: Learning About the Shell
Course 102: Lecture 10: Learning About the Shell
Ahmed El-Arabawy
 
390aLecture05_12sp.ppt
390aLecture05_12sp.ppt
mugeshmsd5
 
Linux shell env
Linux shell env
Rahul Pola
 
Shell Scripting crash course.pdf
Shell Scripting crash course.pdf
harikrishnapolaki
 
Using Unix
Using Unix
Dr.Ravi
 
Introduction to shell scripting ____.ppt
Introduction to shell scripting ____.ppt
nalinisamineni
 
UNIX - Class4 - Advance Shell Scripting-P1
UNIX - Class4 - Advance Shell Scripting-P1
Nihar Ranjan Paital
 
Unix Basics For Testers
Unix Basics For Testers
nitin lakhanpal
 
Common linux ubuntu commands overview
Common linux ubuntu commands overview
Ameer Sameer
 
Basic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manual
Kuntal Bhowmick
 
Linux
Linux
Srinivas Reddy
 
Spsl by sasidhar 3 unit
Spsl by sasidhar 3 unit
Sasidhar Kothuru
 
Examples -partII
Examples -partII
Kedar Bhandari
 
Linux
Linux
Srinivas Reddy
 
Shell programming
Shell programming
Moayad Moawiah
 
OS-Module 2 Linux Programming Important topics
OS-Module 2 Linux Programming Important topics
JithinS34
 
UnixShells.ppt
UnixShells.ppt
EduardoGutierrez111076
 
UnixShells.pptfhfehrguryhdruiygfjtfgrfjht
UnixShells.pptfhfehrguryhdruiygfjtfgrfjht
singingalka
 
Linux shell scripting
Linux shell scripting
Mohamed Abubakar Sittik A
 
Course 102: Lecture 10: Learning About the Shell
Course 102: Lecture 10: Learning About the Shell
Ahmed El-Arabawy
 
390aLecture05_12sp.ppt
390aLecture05_12sp.ppt
mugeshmsd5
 
Linux shell env
Linux shell env
Rahul Pola
 
Shell Scripting crash course.pdf
Shell Scripting crash course.pdf
harikrishnapolaki
 
Using Unix
Using Unix
Dr.Ravi
 
Introduction to shell scripting ____.ppt
Introduction to shell scripting ____.ppt
nalinisamineni
 
UNIX - Class4 - Advance Shell Scripting-P1
UNIX - Class4 - Advance Shell Scripting-P1
Nihar Ranjan Paital
 
Common linux ubuntu commands overview
Common linux ubuntu commands overview
Ameer Sameer
 
Basic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manual
Kuntal Bhowmick
 
OS-Module 2 Linux Programming Important topics
OS-Module 2 Linux Programming Important topics
JithinS34
 
UnixShells.pptfhfehrguryhdruiygfjtfgrfjht
UnixShells.pptfhfehrguryhdruiygfjtfgrfjht
singingalka
 
Ad

More from Dr. Girish GS (14)

Unix- the process
Unix- the process
Dr. Girish GS
 
unix- Sort, uniq,tr,grep
unix- Sort, uniq,tr,grep
Dr. Girish GS
 
unix- the process states, zombies, running jobs in background
unix- the process states, zombies, running jobs in background
Dr. Girish GS
 
Unix - Filters
Unix - Filters
Dr. Girish GS
 
File systems and inodes
File systems and inodes
Dr. Girish GS
 
Basic regular expression, extended regular expression
Basic regular expression, extended regular expression
Dr. Girish GS
 
Loop instruction, controlling the flow of progam
Loop instruction, controlling the flow of progam
Dr. Girish GS
 
Logic instructions part 1
Logic instructions part 1
Dr. Girish GS
 
Bcd arithmetic instructions
Bcd arithmetic instructions
Dr. Girish GS
 
Bcd and ascii arithmetic instructions
Bcd and ascii arithmetic instructions
Dr. Girish GS
 
Ascii arithmetic instructions
Ascii arithmetic instructions
Dr. Girish GS
 
Rotate instructions
Rotate instructions
Dr. Girish GS
 
Program control instructions
Program control instructions
Dr. Girish GS
 
Memory interface
Memory interface
Dr. Girish GS
 
unix- Sort, uniq,tr,grep
unix- Sort, uniq,tr,grep
Dr. Girish GS
 
unix- the process states, zombies, running jobs in background
unix- the process states, zombies, running jobs in background
Dr. Girish GS
 
File systems and inodes
File systems and inodes
Dr. Girish GS
 
Basic regular expression, extended regular expression
Basic regular expression, extended regular expression
Dr. Girish GS
 
Loop instruction, controlling the flow of progam
Loop instruction, controlling the flow of progam
Dr. Girish GS
 
Logic instructions part 1
Logic instructions part 1
Dr. Girish GS
 
Bcd arithmetic instructions
Bcd arithmetic instructions
Dr. Girish GS
 
Bcd and ascii arithmetic instructions
Bcd and ascii arithmetic instructions
Dr. Girish GS
 
Ascii arithmetic instructions
Ascii arithmetic instructions
Dr. Girish GS
 
Program control instructions
Program control instructions
Dr. Girish GS
 
Ad

Recently uploaded (20)

International Journal of Advanced Information Technology (IJAIT)
International Journal of Advanced Information Technology (IJAIT)
ijait
 
Industry 4.o the fourth revolutionWeek-2.pptx
Industry 4.o the fourth revolutionWeek-2.pptx
KNaveenKumarECE
 
Mobile database systems 20254545645.pptx
Mobile database systems 20254545645.pptx
herosh1968
 
Industrial internet of things IOT Week-3.pptx
Industrial internet of things IOT Week-3.pptx
KNaveenKumarECE
 
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Shabista Imam
 
Solar thermal – Flat plate and concentrating collectors .pptx
Solar thermal – Flat plate and concentrating collectors .pptx
jdaniabraham1
 
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
resming1
 
Complete University of Calculus :: 2nd edition
Complete University of Calculus :: 2nd edition
Shabista Imam
 
special_edition_using_visual_foxpro_6.pdf
special_edition_using_visual_foxpro_6.pdf
Shabista Imam
 
retina_biometrics ruet rajshahi bangdesh.pptx
retina_biometrics ruet rajshahi bangdesh.pptx
MdRakibulIslam697135
 
Data Structures Module 3 Binary Trees Binary Search Trees Tree Traversals AVL...
Data Structures Module 3 Binary Trees Binary Search Trees Tree Traversals AVL...
resming1
 
Rapid Prototyping for XR: Lecture 1 Introduction to Prototyping
Rapid Prototyping for XR: Lecture 1 Introduction to Prototyping
Mark Billinghurst
 
Tesla-Stock-Analysis-and-Forecast.pptx (1).pptx
Tesla-Stock-Analysis-and-Forecast.pptx (1).pptx
moonsony54
 
Introduction to sensing and Week-1.pptx
Introduction to sensing and Week-1.pptx
KNaveenKumarECE
 
NEW Strengthened Senior High School Gen Math.pptx
NEW Strengthened Senior High School Gen Math.pptx
DaryllWhere
 
Structured Programming with C++ :: Kjell Backman
Structured Programming with C++ :: Kjell Backman
Shabista Imam
 
Complete guidance book of Asp.Net Web API
Complete guidance book of Asp.Net Web API
Shabista Imam
 
How to Un-Obsolete Your Legacy Keypad Design
How to Un-Obsolete Your Legacy Keypad Design
Epec Engineered Technologies
 
Rapid Prototyping for XR: Lecture 6 - AI for Prototyping and Research Directi...
Rapid Prototyping for XR: Lecture 6 - AI for Prototyping and Research Directi...
Mark Billinghurst
 
Structural Wonderers_new and ancient.pptx
Structural Wonderers_new and ancient.pptx
nikopapa113
 
International Journal of Advanced Information Technology (IJAIT)
International Journal of Advanced Information Technology (IJAIT)
ijait
 
Industry 4.o the fourth revolutionWeek-2.pptx
Industry 4.o the fourth revolutionWeek-2.pptx
KNaveenKumarECE
 
Mobile database systems 20254545645.pptx
Mobile database systems 20254545645.pptx
herosh1968
 
Industrial internet of things IOT Week-3.pptx
Industrial internet of things IOT Week-3.pptx
KNaveenKumarECE
 
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Shabista Imam
 
Solar thermal – Flat plate and concentrating collectors .pptx
Solar thermal – Flat plate and concentrating collectors .pptx
jdaniabraham1
 
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
resming1
 
Complete University of Calculus :: 2nd edition
Complete University of Calculus :: 2nd edition
Shabista Imam
 
special_edition_using_visual_foxpro_6.pdf
special_edition_using_visual_foxpro_6.pdf
Shabista Imam
 
retina_biometrics ruet rajshahi bangdesh.pptx
retina_biometrics ruet rajshahi bangdesh.pptx
MdRakibulIslam697135
 
Data Structures Module 3 Binary Trees Binary Search Trees Tree Traversals AVL...
Data Structures Module 3 Binary Trees Binary Search Trees Tree Traversals AVL...
resming1
 
Rapid Prototyping for XR: Lecture 1 Introduction to Prototyping
Rapid Prototyping for XR: Lecture 1 Introduction to Prototyping
Mark Billinghurst
 
Tesla-Stock-Analysis-and-Forecast.pptx (1).pptx
Tesla-Stock-Analysis-and-Forecast.pptx (1).pptx
moonsony54
 
Introduction to sensing and Week-1.pptx
Introduction to sensing and Week-1.pptx
KNaveenKumarECE
 
NEW Strengthened Senior High School Gen Math.pptx
NEW Strengthened Senior High School Gen Math.pptx
DaryllWhere
 
Structured Programming with C++ :: Kjell Backman
Structured Programming with C++ :: Kjell Backman
Shabista Imam
 
Complete guidance book of Asp.Net Web API
Complete guidance book of Asp.Net Web API
Shabista Imam
 
Rapid Prototyping for XR: Lecture 6 - AI for Prototyping and Research Directi...
Rapid Prototyping for XR: Lecture 6 - AI for Prototyping and Research Directi...
Mark Billinghurst
 
Structural Wonderers_new and ancient.pptx
Structural Wonderers_new and ancient.pptx
nikopapa113
 

Customizing the unix environment

  • 1. Introduction to Unix and OS Module 2 Dr. Girisha G S Dept. of CSE SoE,DSU, Bengaluru Customizing the Unix Environment
  • 2. Agenda  The Shells  Environment Variables  Command Aliases- Shorthand names for commands  Command History  The Initialization Scripts
  • 3. - You can find out what shell you are using like this: $ echo $SHELL /bin/bash - Shell features are customizable - The default prompt for the Bourne, Bourne Again, and Korn shells is the dollar sign ($). - The default prompt for the C shell is the percent sign (%). - The default prompt for root in either shell is the pound sign (#).
  • 4. $ env Common Environment Variables $ set DISPLAY=:0.0 EDITOR=/usr/bin/vi SHELL=/bin/bash TERM=xterm-256color USER=geek - Environment variables are variables that are set up in your shell when you log in. - The environment variables are managed by the shell.
  • 5. Customizing Environment Variable: PS1 - The shell primary prompt string is $ stored in the shell variable PS1, and you can customize it according to your preference. Example : change the primary prompt string to present working directory $ PS1=”$PWD -> “ /home/user-> Customizing Environment Variable : PATH - The PATH variable contains a list of directory path names, separated by colons for executing commands and scripts and you can customize it according to your preference. Example: Include the home directory in the PATH variable $ PATH=$PATH:/home/user - You can display a single variable with a simple echo command. Example: $ echo $PWD /home/user
  • 6. Aliases - Aliases let you assign shorthand names to frequently used commands alias: This command assign shorthand names to command The syntax is as follows: $ alias shortname=“command [options]” Example: Create an alias called list, which will use the ls command to print a long-style listing of all files in the current directory $ alias list=‘ls –la’ $ list unalias: this command unset an alias Example: To unset alias list $ unalias list
  • 7. Command history - Lets you recall previous commands and edit/ re-execute them - Every command is treated as an event and assigned an event number - Using this number you can recall previous command, edit them if required and re-execute them history: this command displays the history list showing the event number of every previously executed command Example: $ history
  • 8. Example : display the last two commands $ history 2 - The symbol ! Is used to repeat previous commands Example: re-execute the command with event number 12 $ !12 - To repeat the previous command, use !! Example : $ !! Accessing previous commands by event numbers Accessing previous commands by context - When you don’t remember the event number of a command but know that the command started with a specific letter of a string, you can use the history facility with context Example: repeats the last command beginning with v $ !v - You can specify a numeric argument to specify the number of previous commands to display
  • 9. The Initialization Scripts - The start up scripts are executed when the user logs in - The initialization scripts in different shells are: The Profile - If you'd like to set the environment variables permanently, add your settings to the initialization file In the bash login shell, the startup scripts are executed in the following order /etc/profile ~/.bash_profile ~/.bash_login ~/.profile - reads and executes commands from the first one that exists - If none exists, /etc/bashrc applied - When a login shell exits, bash reads and executes commands from the file, ~/.bash_logout, if it exists.
  • 10. - Every time you change the profile file, You can execute it by using a special command (called dot). Example : $ . .profile The specific settings which an unix user usually does is: ― Setting of any environment variable ― Setting of any alias ― Setting of PATH variable or any other path variables $cat $HOME/.profile export PATH=$PATH:~blogger/bin alias l="ls -lrt" A typical profile file will look as shown below The rc File - This type of file is run every time a new shell is opened up even if it is not a login shell. - This file is ~/.bashrc for the bash shell - The rc file is used to define command aliases, variable settings, and shell options. - The rc file will be executed after the profile.

Editor's Notes

  • #4: Interactive shell shell run by the user after logging on. A shell running a script is always a non-interactive shell. Bash shell is often identified by a '$' sign in the command prompt. Shell prompts are extremely customizable. The type of shell, which may be customized for each user Environment variables hold values related to the current environment, like the Operating System In simple terms, it is a variable with a name and a value. Environment variables are dynamic in nature, and it can be changed. There are a number of environment variables that can be referenced by programs and can be useful in finding information about their computing environment.
  • #5: environment variables are global system variables accessible by all the processes To display the environment variables that are currently set on your system, use the env command. Editor: Defines the default editor for the shell
  • #6: PS1 - Defines your command prompt. The default prompt for the Bourne, Bourne Again, and Korn shells is the dollar sign ($). The default prompt for the C, TC, and Z shells is the percent sign (%). The default prompt for root in either shell is the pound sign (#).
  • #7: to run the longer command with less typing.aliases are shortcut names for commands. alias - This command creates an alias shortcut for long or complex command.  used to avoid typing long commands avoid having to remember complex combinations of commands and options.  unalias removes alias name specified
  • #8: Executing the same command or a short sequence of commands over and over. Unix records all of the commands executed To list previous commands, use the history command
  • #9: With bash, the complete history list is displayed
  • #10: the shell program /bin/bash (hereafter referred to as just "the shell") uses a collection of startup files to help create an environment.  The name of the profile file varies depending on the default shell of the user.  what exactly goes into one of these environment setup files?