Managing Unix - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Managing Unix

Description:

Shell Script. The Process. The Jobs Control -Foreground and Background -Listing the jobs ... To create a shell script. 1. Create a file with vi. 2. Put commands in it ... – PowerPoint PPT presentation

Number of Views:33
Avg rating:3.0/5.0
Slides: 15
Provided by: Kami47
Category:
Tags: managing | unix

less

Transcript and Presenter's Notes

Title: Managing Unix


1
Managing Unix
  • Shell Script
  • The Process
  • The Jobs Control
  • -Foreground and Background
  • -Listing the jobs
  • -Recalling the jobs
  • -Killing the Jobs
  • -Suspending the jobs

2
Shell Script
  • A shell Script
  • A file that contains commands to be executed
  • To create a shell script
  • 1. Create a file with vi
  • 2. Put commands in it
  • 3. Make the file executable

3
Our First Shell Script
  • Vi inform
  • The commands inside the file
  • date
  • pwd
  • echo You have the following files
  • ls
  • echo Users currently logged in
  • who
  • echo Your login name is
  • who grep USER
  • echo Good Bye
  • Chmod ux inform Or chmod 700 inform
  • Call the file name
  • inform Or ./inform

4
The Process
  • A process in UNIX simply represents the running
    of a command
  • The process structure in UNIX is similar to the
    hierarchical structure of directories
  • The beginning process is root
  • Parent processes can create child processes
  • Processes can fork other processes
  • When a child process is finished, execution
    returns to its parent process

5
The Processes
  • To list the processes currently running
  • ps
  • PID TTY TIME CMD
  • 15322 pts/35 000 sleep 200
  • 37320 pts/35 000 -ksh
  • 46212 pts/35 001 -ksh
  • 61324 pts/35 000 sleep 2000
  • 73748 pts/35 000 ps
  • 139494 pts/35 000 -ksh

6
Listing the Processes
  • To view a detailed listing of process ID numbers
    (relating child (PID) parent processes(PPID))
    enter
  • ps l
  • To view listing of processes for the entire
    system, enter
  • ps -ef

7
Creating Filenames using
  • The shell can store the PID number as a read-only
    shell variable
  • echo displays the PID number that is currently
    executing
  • echo ! displays the PID of the last process that
    was run in the background

8
Referring to My Phobos files
  • Inform
  • InformB (uses sleep to display the results of
    command better)
  • InformC (the sleep time increases representing a
    bigger job being processed)
  • InformD (Job results redirected to a file to be
    viewed later, but the shell is still occupied.)
  • The notion of Foreground vc Background

9
The Job
  • To list the jobs
  • jobs
  • 2 Running ../Testing/sleepygu
    y
  • 1 - Running informD

10
Foreground VS. Background
  • To run the job in the background
  • informD
  • Afterwards,The following message appears
  • 1 11508
  • 1 ? job number
  • The second no. ? PID number
  • PID (Process identification number)

11
Recalling the job
  • Moving the most recent job to foreground
  • fg
  • or fg
  • Recalling the second recent job
  • fg -
  • Recalling a particular job
  • fg Job-number
  • fg 1 fg 4

12
Killing Jobs
  • Killing the most recent job
  • kill
  • Killing the second most recent job
  • kill -
  • Killing a particular job
  • kill job-number
  • eg kill 1 kill 4
  • Killing all the processes
  • kill 0
  • Killing the selected process
  • kill PID no.

13
Suspending a job
  • Suspending a job, eg, youre writing a mail
  • ltCtrlgt Z
  • to go back to mail fg
  • to display what you wrote so far p
  • Moving a Suspended job into background
  • bg
  • To put a job into background, first suspend the
    job
  • For a particular job
  • bg job-number

14
Task1
  • What command would you use to start up a ps in
    the background?
  • For the next questions,refer to the following
    listing
  • 2 Stopped sort /etc/passwd
  • 3 - Stopped vi .cshrc
  • 4 Stopped more .login
  • 2.What command would you use to bring the vi
    editor into foreground?
  • 3. What is the command to kill the more?
  • 4. What is the command to get this listing?
Write a Comment
User Comments (0)
About PowerShow.com