Your SlideShare is downloading. ×
Unix And Shell Scripting
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Unix And Shell Scripting

5,571

Published on

Understanding Unix And Shell Scripting.

Understanding Unix And Shell Scripting.

Published in: Technology
4 Comments
22 Likes
Statistics
Notes
  • Hi Malik,



    Presetation was very good, Shall I get a copy of above presentation if possible?

    my mail id is 'srinig20@gmail.com'



    Regards,

    Srini
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Good Presentation! it's useful one for beginners of unix & shell
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Unix And Shell Scripting
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • best one
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
5,571
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
0
Comments
4
Likes
22
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 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
  • 6. ARCHITECTURE
  • 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
  • 8. Solaris File System Tree
  • 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 Your 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 “ The 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:
  • 32. Questions
    • ?
  • 33. ... Feedback…

×