SlideShare a Scribd company logo
Unix & Shell Scripting Presenter:   Jaibeer   Malik August 6, 2004
Agenda Objectives UNIX Shell Scripting Questions Feedback
Session Objectives Understand the basics of Unix Operating Environment Understand the basics of Shell Scripting
Unix History History of the Unix Operating System: - Beginning at AT&T Bell Laboratories - Kenneth Thompson - Dennis Ritchie - Berkeley: The Second School - BSD UNIX - Stallman and Torvalds - GNU and LINUX
Unix Why???   There are only two kind of people   who understand 0 1 and who don’t understand 01010101010101010101010101010101010101010101010101010 The features that made UNIX a hit from the start are: Multitasking capability  Multi-user capability  Portability  UNIX programs  Library of application software
ARCHITECTURE
ARCHITECHTURE The UNIX system is functionally organized at three levels: The kernel, which schedules tasks and manages storage;  The shell, which connects and interprets users' commands, calls programs from memory, and executes them; and  The tools and applications that offer additional functionality to the operating system
Solaris File System Tree
 
Navigating The File System pwd: Checking your Current Directory cd: Changing Directory mkdir: Making Directories rmdir: Removing Directories ls: Listing Files
General-Purpose Utilities banner: Display a Blown-up Message cal: The Calendar date: Display the System Date who: Login Details tty: Knowing Your Terminal man <command>: Displays help on <command>  apropos <keyword>:locates commands by keyword lookup whatis <command>:  Brief command description
 
Handling Files cat: Displaying and Creating Files cp: Copying a File rm: Deleting Files mv: Renaming Files more: Paging Output lp: Printing a File file: Know the file types wc:  Line and Word and character counting  split: Splitting a File into Multiple Files cmp: Comparing two files
File Attributes ls –l: listing File Attributes ls –d: Listing Directory Attributes stat: Display File Permissions chmod: Changing File Permissions chown: Changing Ownership chgrp: Changing Group chsh: Changing Shell ln: Links umask: Define Defaults File Permissions for a User
The Environment env: Displays Environment Properties .profile: The Script Executed During Login Time PWD: Know your Current Directory HISTSIZE: Define History Size LOGNAME: Login Name SHELL: Your Default Shell HOME: Define Home Directory  PATH: Declare Path MAIL: Declare Mail Directory Path alias: Define short-hand names for commands
The Process ps: Process Status <command> &: To run a process in Background bg: To run a process in Background fg: To run a process in Foreground kill: Premature Termination of a Process nice: job execution with low Priority at and batch: Execute Later cron: Running jobs Periodically
Communication And Electronic Mail write: Two-way Communication mesg: Your Willingness to Talk talk: Splits the screen into two windows for chatting mail: The mailer news: To read news messages elm: A screen-oriented mail handler pine: Another mail program finger: Details of Users
Networking telnet: Remote Login ftp: File Transfer (protocol) rlogin: Remote Login Without Password rcp: Remote File Copying
System Administration useradd: Adding Users /etc/passwd: User Information /etc/shadow: Encrypted Passwords userdel: Removing Users fsck: File System Checking df: Checking disk size du: Checking file size groupadd: Adding Group groupdel: Deleting Group groupmod: Modifying Group
The Shell The following table shows the default system prompt and superuser prompt for the C shell, Bourne shell, and Korn shell.
Shell Scripting A universal convention is that the extension .sh be used for  shell scripts  (or  shell programs  or  shell procedures ). The scripts can be executed in two ways: $ chmod +x <filename.sh> $ sh <filename.sh> read: For taking input from the user Example: $ cat example1.sh #First Simple Example to print the standard input from the user to the  standard output. echo “Enter Your Name: “ read name echo “Your name is: $name”
Shell Scripting (Contd..) When arguments are specified with a shell procedure, they are assigned to certain special “variables” or rather positional parameters. $1,$2,etc.  The positional Parameters $*  Complete set of positional parameters  as a single string $#  Number of arguments specified in  command line $0  Name of executed command $? Exit status of the last command $!  PID of last command
Shell Scripting (Contd..) Example: $ cat example2.sh  #Example to print the standard input from the user to the standard output using positional parameters. echo “Program: $0 The Number of Arguments Specified is $# The Arguments are $*” echo “Your Name: $1\nYour Extension Number: $2” Example: $ example2.sh Jai 5630 Program: example2.sh The Number of Arguments Specified is 2 The Arguments are Jai 5630 Your Name: Jai Your Extension Number: 5630
Shell Programming (Contd..) The && operator delimits two commands; the second command is executed only when the first succeeds. The || operator delimits two commands; the second command is executed only when the first fails. The  exit  statement is used to prematurely terminate a program. The if Conditional if condition is true then   execute commands else   execute commands fi
Shell Scripting (Contd..) Relational Operators -eq Equal to -neq Not equal to -gt greater than -ge greater than or equal to -lt  less than -le  less than or equal to test  uses certain operators to evaluate the condition on its right, and returns either a true or false test  $x –eq $y or [$x –eq $y] String tests used by test -n stg  true if string stg is not a null string -z stg  true is string stg is a null string s1 = s2 true if string s1=s2 s1! = s2 true if string s1 is not equal to s2 stg true if string stg is assigned and not null
Shell Scripting (Contd..) File-related tests with  test -e file   true if file exists -f file  true if file exists and is a regular file -r file  true if file exists and is a redable -w file  true if file exists and is a writable -x file  true if file exists and is a executable -d file  true if file exists and is a directory -s file  true if file exists and has a size greater than   zero
Shell Scripting (Contd..) The  case  conditional case expression in pattern1) execute commands;; pattern2) execute commands;; pattern3) execute commands;; …… esac The  while  loop while condition is true do execute commands done
Shell Scripting (Contd..) The  for  loop for variable in list do execute commands done Example: $ for x in 1 2 4 5 #list has 4 strings   do echo “\nThe value of x is $x”   done  The value of x is 1 The value of x is 2 The value of x is 4 The value of x is 5
Shell Scripting (Contd..) The  here document  symbol (<<) is used sometimes when we need to place the data inside the script. The  here document  symbol (<<) is followed by the data and a delimiter. shift  transfers the contents of a positional parameter to its immediate lower numbered one. When  set –x  is used inside a script, it echoes each statement on the terminal, preceded by a + as it is executed.
Example bash-2.03$ cat example3.sh  IFS=&quot;|&quot;  while echo &quot;Enter Department Code: &quot;  do read dcode  set -- `grep $dcode data`  case $# in  3) echo &quot;Department name : $2 Emp-id of head of dept : $3&quot;  shift 3 ;;  *) echo &quot;Invalid Code&quot; ; continue  esac  done  bash-2.03$ cat data 01|accounts|6213  02|admin|5423  03|marketing|6521  04|personnel|2365  05|production|9876  06|sales|1006
Example (Contd…) bash-2.03$ bash example4.sh Enter Department Code: 99  Invalid Code  Enter Department Code: 01 Department name : accounts Emp-id of head of dept : 6213  Enter Department Code: 06 Department name : sales Emp-id of head of dept : 1006 Enter Department Code:
Questions ?
  ... Feedback…

More Related Content

What's hot (20)

Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell Scripting
Raghu nath
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
Manav Prasad
 
Easiest way to start with Shell scripting
Easiest way to start with Shell scriptingEasiest way to start with Shell scripting
Easiest way to start with Shell scripting
Akshay Siwal
 
Basic 50 linus command
Basic 50 linus commandBasic 50 linus command
Basic 50 linus command
MAGNA COLLEGE OF ENGINEERING
 
Unix Shell Scripting
Unix Shell ScriptingUnix Shell Scripting
Unix Shell Scripting
Mustafa Qasim
 
Linux command ppt
Linux command pptLinux command ppt
Linux command ppt
kalyanineve
 
Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...
Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...
Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...
Anne Nicolas
 
Introduction to Modern U-Boot
Introduction to Modern U-BootIntroduction to Modern U-Boot
Introduction to Modern U-Boot
GlobalLogic Ukraine
 
Linux Char Device Driver
Linux Char Device DriverLinux Char Device Driver
Linux Char Device Driver
Gary Yeh
 
Linux LVM Logical Volume Management
Linux LVM Logical Volume ManagementLinux LVM Logical Volume Management
Linux LVM Logical Volume Management
Manolis Kartsonakis
 
Embedded Linux Kernel - Build your custom kernel
Embedded Linux Kernel - Build your custom kernelEmbedded Linux Kernel - Build your custom kernel
Embedded Linux Kernel - Build your custom kernel
Emertxe Information Technologies Pvt Ltd
 
Linux Kernel Module - For NLKB
Linux Kernel Module - For NLKBLinux Kernel Module - For NLKB
Linux Kernel Module - For NLKB
shimosawa
 
Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions
Ahmed El-Arabawy
 
LCA13: Power State Coordination Interface
LCA13: Power State Coordination InterfaceLCA13: Power State Coordination Interface
LCA13: Power State Coordination Interface
Linaro
 
Linux System Programming - File I/O
Linux System Programming - File I/O Linux System Programming - File I/O
Linux System Programming - File I/O
YourHelper1
 
U boot-boot-flow
U boot-boot-flowU boot-boot-flow
U boot-boot-flow
BabuSubashChandar Chandra Mohan
 
swings.pptx
swings.pptxswings.pptx
swings.pptx
Parameshwar Maddela
 
Introduction to Makefile
Introduction to MakefileIntroduction to Makefile
Introduction to Makefile
Zakaria El ktaoui
 
Layout manager
Layout managerLayout manager
Layout manager
Shree M.L.Kakadiya MCA mahila college, Amreli
 
Arm device tree and linux device drivers
Arm device tree and linux device driversArm device tree and linux device drivers
Arm device tree and linux device drivers
Houcheng Lin
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell Scripting
Raghu nath
 
Easiest way to start with Shell scripting
Easiest way to start with Shell scriptingEasiest way to start with Shell scripting
Easiest way to start with Shell scripting
Akshay Siwal
 
Unix Shell Scripting
Unix Shell ScriptingUnix Shell Scripting
Unix Shell Scripting
Mustafa Qasim
 
Linux command ppt
Linux command pptLinux command ppt
Linux command ppt
kalyanineve
 
Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...
Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...
Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...
Anne Nicolas
 
Linux Char Device Driver
Linux Char Device DriverLinux Char Device Driver
Linux Char Device Driver
Gary Yeh
 
Linux LVM Logical Volume Management
Linux LVM Logical Volume ManagementLinux LVM Logical Volume Management
Linux LVM Logical Volume Management
Manolis Kartsonakis
 
Linux Kernel Module - For NLKB
Linux Kernel Module - For NLKBLinux Kernel Module - For NLKB
Linux Kernel Module - For NLKB
shimosawa
 
Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions
Ahmed El-Arabawy
 
LCA13: Power State Coordination Interface
LCA13: Power State Coordination InterfaceLCA13: Power State Coordination Interface
LCA13: Power State Coordination Interface
Linaro
 
Linux System Programming - File I/O
Linux System Programming - File I/O Linux System Programming - File I/O
Linux System Programming - File I/O
YourHelper1
 
Arm device tree and linux device drivers
Arm device tree and linux device driversArm device tree and linux device drivers
Arm device tree and linux device drivers
Houcheng Lin
 

Viewers also liked (20)

Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
Dr.Ravi
 
Unix Shell Script
Unix Shell ScriptUnix Shell Script
Unix Shell Script
student
 
OpenGurukul : Language : Shell Scripting
OpenGurukul : Language : Shell ScriptingOpenGurukul : Language : Shell Scripting
OpenGurukul : Language : Shell Scripting
Open Gurukul
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
Sudharsan S
 
Quick start bash script
Quick start   bash scriptQuick start   bash script
Quick start bash script
Simon Su
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
Gaurav Shinde
 
Bash shell scripting
Bash shell scriptingBash shell scripting
Bash shell scripting
VIKAS TIWARI
 
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
sbmguys
 
Basic Unix
Basic UnixBasic Unix
Basic Unix
Rajesh Kumar
 
Commands and shell programming (3)
Commands and shell programming (3)Commands and shell programming (3)
Commands and shell programming (3)
christ university
 
Unix files
Unix filesUnix files
Unix files
Sunil Rm
 
Rock-solid shell scripting with Ammonite
Rock-solid shell scripting with AmmoniteRock-solid shell scripting with Ammonite
Rock-solid shell scripting with Ammonite
Maxim Novak
 
Unix processes
Unix processesUnix processes
Unix processes
Sunil Rm
 
SG Security Switch Brochure
SG Security Switch BrochureSG Security Switch Brochure
SG Security Switch Brochure
Shotaro Kaida
 
SOS Presentation
SOS PresentationSOS Presentation
SOS Presentation
Michele Phillips
 
Scripting Oracle Develop 2007
Scripting Oracle Develop 2007Scripting Oracle Develop 2007
Scripting Oracle Develop 2007
Tugdual Grall
 
Web server installation_configuration_apache
Web server installation_configuration_apacheWeb server installation_configuration_apache
Web server installation_configuration_apache
Shaojie Yang
 
Advanced Shell Scripting for Oracle professionals
Advanced Shell Scripting for Oracle professionalsAdvanced Shell Scripting for Oracle professionals
Advanced Shell Scripting for Oracle professionals
Andrejs Vorobjovs
 
Apache Web Server Setup 2
Apache Web Server Setup 2Apache Web Server Setup 2
Apache Web Server Setup 2
Information Technology
 
Linux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for BeginnersLinux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for Beginners
Davide Ciambelli
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
Dr.Ravi
 
Unix Shell Script
Unix Shell ScriptUnix Shell Script
Unix Shell Script
student
 
OpenGurukul : Language : Shell Scripting
OpenGurukul : Language : Shell ScriptingOpenGurukul : Language : Shell Scripting
OpenGurukul : Language : Shell Scripting
Open Gurukul
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
Sudharsan S
 
Quick start bash script
Quick start   bash scriptQuick start   bash script
Quick start bash script
Simon Su
 
Bash shell scripting
Bash shell scriptingBash shell scripting
Bash shell scripting
VIKAS TIWARI
 
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
sbmguys
 
Commands and shell programming (3)
Commands and shell programming (3)Commands and shell programming (3)
Commands and shell programming (3)
christ university
 
Unix files
Unix filesUnix files
Unix files
Sunil Rm
 
Rock-solid shell scripting with Ammonite
Rock-solid shell scripting with AmmoniteRock-solid shell scripting with Ammonite
Rock-solid shell scripting with Ammonite
Maxim Novak
 
Unix processes
Unix processesUnix processes
Unix processes
Sunil Rm
 
SG Security Switch Brochure
SG Security Switch BrochureSG Security Switch Brochure
SG Security Switch Brochure
Shotaro Kaida
 
Scripting Oracle Develop 2007
Scripting Oracle Develop 2007Scripting Oracle Develop 2007
Scripting Oracle Develop 2007
Tugdual Grall
 
Web server installation_configuration_apache
Web server installation_configuration_apacheWeb server installation_configuration_apache
Web server installation_configuration_apache
Shaojie Yang
 
Advanced Shell Scripting for Oracle professionals
Advanced Shell Scripting for Oracle professionalsAdvanced Shell Scripting for Oracle professionals
Advanced Shell Scripting for Oracle professionals
Andrejs Vorobjovs
 
Linux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for BeginnersLinux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for Beginners
Davide Ciambelli
 
Ad

Similar to Unix And Shell Scripting (20)

Unix
UnixUnix
Unix
nazeer pasha
 
Introduction to UNIX
Introduction to UNIXIntroduction to UNIX
Introduction to UNIX
Bioinformatics and Computational Biosciences Branch
 
Shell programming
Shell programmingShell programming
Shell programming
Moayad Moawiah
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
Abhay Sapru
 
Unix - Shell Scripts
Unix - Shell ScriptsUnix - Shell Scripts
Unix - Shell Scripts
ananthimurugesan
 
Using Unix
Using UnixUsing Unix
Using Unix
Dr.Ravi
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
Mufaddal Haidermota
 
Advanced linux chapter ix-shell script
Advanced linux chapter ix-shell scriptAdvanced linux chapter ix-shell script
Advanced linux chapter ix-shell script
Eliezer Moraes
 
1 4 sp
1 4 sp1 4 sp
1 4 sp
Bhargavi Bbv
 
shellScriptAlt.pptx
shellScriptAlt.pptxshellScriptAlt.pptx
shellScriptAlt.pptx
NiladriDey18
 
What is a shell script
What is a shell scriptWhat is a shell script
What is a shell script
Dr.M.Karthika parthasarathy
 
Shell Programming_Module2_Part2.pptx.pdf
Shell Programming_Module2_Part2.pptx.pdfShell Programming_Module2_Part2.pptx.pdf
Shell Programming_Module2_Part2.pptx.pdf
HIMANKMISHRA2
 
ShellProgramming and Script in operating system
ShellProgramming and Script in operating systemShellProgramming and Script in operating system
ShellProgramming and Script in operating system
vinitasharma749430
 
390aLecture05_12sp.ppt
390aLecture05_12sp.ppt390aLecture05_12sp.ppt
390aLecture05_12sp.ppt
mugeshmsd5
 
Linux powerpoint
Linux powerpointLinux powerpoint
Linux powerpoint
bijanshr
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
simha.dev.lin
 
Bash shell
Bash shellBash shell
Bash shell
xylas121
 
Slides
SlidesSlides
Slides
abhishekvirmani
 
Talk Unix Shell Script
Talk Unix Shell ScriptTalk Unix Shell Script
Talk Unix Shell Script
Dr.Ravi
 
Shell Scripts
Shell ScriptsShell Scripts
Shell Scripts
Dr.Ravi
 
Ad

Recently uploaded (20)

cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry ReportThe State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Introduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUEIntroduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUE
Google Developer Group On Campus European Universities in Egypt
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent IntegrationPyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdfArtificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Trends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary MeekerTrends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary Meeker
Clive Dickens
 
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and ImplementationAI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
Christine Shepherd
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
How to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptxHow to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Secure Access with Azure Active Directory
Secure Access with Azure Active DirectorySecure Access with Azure Active Directory
Secure Access with Azure Active Directory
VICTOR MAESTRE RAMIREZ
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME FlowProviding an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data ResilienceFloods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too LateKubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry ReportThe State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent IntegrationPyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdfArtificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Trends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary MeekerTrends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary Meeker
Clive Dickens
 
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and ImplementationAI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
Christine Shepherd
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
How to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptxHow to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Secure Access with Azure Active Directory
Secure Access with Azure Active DirectorySecure Access with Azure Active Directory
Secure Access with Azure Active Directory
VICTOR MAESTRE RAMIREZ
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME FlowProviding an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data ResilienceFloods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too LateKubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 

Unix And Shell Scripting

  • 1. Unix & Shell Scripting Presenter: Jaibeer Malik August 6, 2004
  • 2. Agenda Objectives UNIX Shell Scripting Questions Feedback
  • 3. Session Objectives Understand the basics of Unix Operating Environment Understand the basics of Shell Scripting
  • 4. Unix History History of the Unix Operating System: - Beginning at AT&T Bell Laboratories - Kenneth Thompson - Dennis Ritchie - Berkeley: The Second School - BSD UNIX - Stallman and Torvalds - GNU and LINUX
  • 5. Unix Why??? There are only two kind of people who understand 0 1 and who don’t understand 01010101010101010101010101010101010101010101010101010 The features that made UNIX a hit from the start are: Multitasking capability Multi-user capability Portability UNIX programs Library of application software
  • 7. ARCHITECHTURE The UNIX system is functionally organized at three levels: The kernel, which schedules tasks and manages storage; The shell, which connects and interprets users' commands, calls programs from memory, and executes them; and The tools and applications that offer additional functionality to the operating system
  • 9.  
  • 10. Navigating The File System pwd: Checking your Current Directory cd: Changing Directory mkdir: Making Directories rmdir: Removing Directories ls: Listing Files
  • 11. General-Purpose Utilities banner: Display a Blown-up Message cal: The Calendar date: Display the System Date who: Login Details tty: Knowing Your Terminal man <command>: Displays help on <command> apropos <keyword>:locates commands by keyword lookup whatis <command>: Brief command description
  • 12.  
  • 13. Handling Files cat: Displaying and Creating Files cp: Copying a File rm: Deleting Files mv: Renaming Files more: Paging Output lp: Printing a File file: Know the file types wc: Line and Word and character counting split: Splitting a File into Multiple Files cmp: Comparing two files
  • 14. File Attributes ls –l: listing File Attributes ls –d: Listing Directory Attributes stat: Display File Permissions chmod: Changing File Permissions chown: Changing Ownership chgrp: Changing Group chsh: Changing Shell ln: Links umask: Define Defaults File Permissions for a User
  • 15. The Environment env: Displays Environment Properties .profile: The Script Executed During Login Time PWD: Know your Current Directory HISTSIZE: Define History Size LOGNAME: Login Name SHELL: Your Default Shell HOME: Define Home Directory PATH: Declare Path MAIL: Declare Mail Directory Path alias: Define short-hand names for commands
  • 16. The Process ps: Process Status <command> &: To run a process in Background bg: To run a process in Background fg: To run a process in Foreground kill: Premature Termination of a Process nice: job execution with low Priority at and batch: Execute Later cron: Running jobs Periodically
  • 17. Communication And Electronic Mail write: Two-way Communication mesg: Your Willingness to Talk talk: Splits the screen into two windows for chatting mail: The mailer news: To read news messages elm: A screen-oriented mail handler pine: Another mail program finger: Details of Users
  • 18. Networking telnet: Remote Login ftp: File Transfer (protocol) rlogin: Remote Login Without Password rcp: Remote File Copying
  • 19. System Administration useradd: Adding Users /etc/passwd: User Information /etc/shadow: Encrypted Passwords userdel: Removing Users fsck: File System Checking df: Checking disk size du: Checking file size groupadd: Adding Group groupdel: Deleting Group groupmod: Modifying Group
  • 20. The Shell The following table shows the default system prompt and superuser prompt for the C shell, Bourne shell, and Korn shell.
  • 21. Shell Scripting A universal convention is that the extension .sh be used for shell scripts (or shell programs or shell procedures ). The scripts can be executed in two ways: $ chmod +x <filename.sh> $ sh <filename.sh> read: For taking input from the user Example: $ cat example1.sh #First Simple Example to print the standard input from the user to the standard output. echo “Enter Your Name: “ read name echo “Your name is: $name”
  • 22. Shell Scripting (Contd..) When arguments are specified with a shell procedure, they are assigned to certain special “variables” or rather positional parameters. $1,$2,etc. The positional Parameters $* Complete set of positional parameters as a single string $# Number of arguments specified in command line $0 Name of executed command $? Exit status of the last command $! PID of last command
  • 23. Shell Scripting (Contd..) Example: $ cat example2.sh #Example to print the standard input from the user to the standard output using positional parameters. echo “Program: $0 The Number of Arguments Specified is $# The Arguments are $*” echo “Your Name: $1\nYour Extension Number: $2” Example: $ example2.sh Jai 5630 Program: example2.sh The Number of Arguments Specified is 2 The Arguments are Jai 5630 Your Name: Jai Your Extension Number: 5630
  • 24. Shell Programming (Contd..) The && operator delimits two commands; the second command is executed only when the first succeeds. The || operator delimits two commands; the second command is executed only when the first fails. The exit statement is used to prematurely terminate a program. The if Conditional if condition is true then execute commands else execute commands fi
  • 25. Shell Scripting (Contd..) Relational Operators -eq Equal to -neq Not equal to -gt greater than -ge greater than or equal to -lt less than -le less than or equal to test uses certain operators to evaluate the condition on its right, and returns either a true or false test $x –eq $y or [$x –eq $y] String tests used by test -n stg true if string stg is not a null string -z stg true is string stg is a null string s1 = s2 true if string s1=s2 s1! = s2 true if string s1 is not equal to s2 stg true if string stg is assigned and not null
  • 26. Shell Scripting (Contd..) File-related tests with test -e file true if file exists -f file true if file exists and is a regular file -r file true if file exists and is a redable -w file true if file exists and is a writable -x file true if file exists and is a executable -d file true if file exists and is a directory -s file true if file exists and has a size greater than zero
  • 27. Shell Scripting (Contd..) The case conditional case expression in pattern1) execute commands;; pattern2) execute commands;; pattern3) execute commands;; …… esac The while loop while condition is true do execute commands done
  • 28. Shell Scripting (Contd..) The for loop for variable in list do execute commands done Example: $ for x in 1 2 4 5 #list has 4 strings do echo “\nThe value of x is $x” done The value of x is 1 The value of x is 2 The value of x is 4 The value of x is 5
  • 29. Shell Scripting (Contd..) The here document symbol (<<) is used sometimes when we need to place the data inside the script. The here document symbol (<<) is followed by the data and a delimiter. shift transfers the contents of a positional parameter to its immediate lower numbered one. When set –x is used inside a script, it echoes each statement on the terminal, preceded by a + as it is executed.
  • 30. Example bash-2.03$ cat example3.sh IFS=&quot;|&quot; while echo &quot;Enter Department Code: &quot; do read dcode set -- `grep $dcode data` case $# in 3) echo &quot;Department name : $2 Emp-id of head of dept : $3&quot; shift 3 ;; *) echo &quot;Invalid Code&quot; ; continue esac done bash-2.03$ cat data 01|accounts|6213 02|admin|5423 03|marketing|6521 04|personnel|2365 05|production|9876 06|sales|1006
  • 31. Example (Contd…) bash-2.03$ bash example4.sh Enter Department Code: 99 Invalid Code Enter Department Code: 01 Department name : accounts Emp-id of head of dept : 6213 Enter Department Code: 06 Department name : sales Emp-id of head of dept : 1006 Enter Department Code:
  • 33. ... Feedback…