intro unix/linux 10
Upcoming SlideShare
Loading in...5
×
 

intro unix/linux 10

on

  • 6,922 views

controlling user processes

controlling user processes

Statistics

Views

Total Views
6,922
Views on SlideShare
6,919
Embed Views
3

Actions

Likes
0
Downloads
287
Comments
0

1 Embed 3

http://www.slideshare.net 3

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    intro unix/linux 10 intro unix/linux 10 Presentation Transcript

    • Lesson 10-Controlling User Processes
    • Overview
      • Managing and processing processes.
      • Managing jobs.
      • Exiting/quitting when jobs have been stopped.
    • Managing and Processing Processes
      • Every running program is a separate entity, called a process.
      • A process consists of several components working together, including the code, data, CPU activity, memory, input, output, and error handling.
    • Managing and Processing Processes
      • Each process involves reading instructions, accessing computer memory, reading from input, evaluating arguments, performing calculations, and writing to output.
      • Every process on the system has its own unique process ID number.
    • Managing and Processing Processes
      • Obtaining detailed information on system processes.
      • Identifying processes connected to a terminal.
      • Starting a new shell process.
      • Obtaining detailed data about user processes.
      • Genealogy of processes.
      • Ending foreground processes.
      • Ending background processes.
      • Terminating a process that is not responding.
      Managing and Processing Processes
    • Obtaining Detailed Information on System Processes
      • The “ps –aux” and the “ps –ef” commands can be used to get a list of all processes currently running on the system.
      • The “ps –u $USER” command can be used to list only the processes owned by a particular user.
      • The “ps –u root” command can be used to list the processes that are started when the system is booted up, and that are owned by the root user.
    • Identifying Processes Connected to a Terminal
      • User processes must be informed of the port to which they are attached.
      • The “tty” command can be used to determine the terminal port used by a user.
      • The “ps –t port” command can be used to display the running processes, the shell, a process running sleep, and the process running the ps utility.
    • Identifying Processes Connected to a Terminal Output of ps Utility
    • Identifying Processes Connected to a Terminal
      • PID – The PID, called the Process IDentification number, is a unique number assigned to each process when it gets created.
      • CPU – It refers to the CPU time consumed by a process.
      • CMD – The command mode contains the names of the utilities associated with each running process.
    • Starting a New Shell Process
      • The “sh” command is used to start a child shell.
      • The “echo $$” command can be used to obtain the PID of the current shell.
      • The “exit” command or the CTRL-D keys can be used to exit the child shell.
    • Obtaining Detailed Data about User Processes Output of ps –l Command
    • Obtaining Detailed Data about User Processes
      • Flags (F) – This field contains a number indicating the Flags or options set for a process.
      • State (S) – It indicates the state of the process, which includes sleeping (S), running (R), idle (I), and traced (T).
      • Size (SZ) – It contains a number indicating the size of the process in memory.
      • Command (CMD) – It refers to the actual command being run by the process.
    • Genealogy of Processes
      • Processes inherit data from their parent process.
      • Every utility or executable file name that is typed is executed by a process that is a child of the shell process.
      • The child process inherits data such as tty, user ID, and the current directory from the parent process.
    • Ending Foreground Processes
      • The “stty –a” command can be used to display the settings for a system.
      • The “echo $?” and the “echo $status” commands can be used to ask for the exit status sent by the process running sleep to the shell.
      • The “echo $?” command is used by the sh and the recent csh family shells.
    • Ending Foreground Processes
      • The “echo $status” command is used by the older csh family of shells.
      • The CTRL-D key is used to mark the end-of-file character, while the CTRL-C key is used to interrupt a process.
      • The CTRL-D key displays an output, but the CTRL-C does not generate any output.
    • Ending Foreground Processes
      • The keyboard signal “quit” can be used to stop a foreground process.
      • The “CTRL-” keys can also be used to quit a process.
      • The quit signal destroys the process and sometimes makes a copy of the CPU memory associated with the process at the time of exit. The copy is called a core file.
    • Ending Background Processes
      • The “kill” command can be used to terminate a process running in the background.
      • The command requires the PID of the process as the second argument.
      • The “kill –l” command can be used to list all the kill signals available for the current system.
    • Ending Background Processes Listing of All Signals
    • Terminating a Process that is not Responding
      • The following tasks should be carried out to terminate a process:
          • A new terminal should be started.
          • The current terminal port should be identified at the new login or terminal.
          • All the processes should be listed.
          • The PID of the particular process should be identified and the ‘kill’ command should be used to terminate it.
    • Managing Jobs
      • A command-line that instructs the shell to start several processes with the output from the first connecting to the second and so on, is called a job.
      • All modern shells allow users to start, suspend, make active, and kill the processes associated with a job.
    • Managing Jobs
      • Suspending a job.
      • Identifying the most recent job.
      • Killing a particular job.
    • Suspending a Job
      • The “stty –a” command is used to describe a list of CTRL key settings used by the terminal and the shell for communication.
      • The CTRL-Z key is used to suspend a job.
      • The suspended job does not use the system memory.
      • The “fg” command is used to bring the last suspended job into the foreground.
    • Suspending a Job
      • The “jobs” program lists all background and suspended jobs and their status.
      • The “jobs” command is a shell built-in command.
      • A job’s output is divided into four columns – the job number, the order, the status, and the command being executed.
    • Identifying the Most Recent Job
      • The “fg %+” is used to bring the most recently suspended job to the foreground.
      • The “fg %-” is used to bring the second most recently suspended job to the foreground.
    • Identifying the Most Recent Job
      • The job number can also be used to get a job to the foreground.
      • For example, “fg %2”, where %2 specifies the job with the job number 2.
      • The job name can also be used to get a job to the foreground.
    • Killing a Job
      • The “kill %+” command is used to kill the most recent job in the job list.
      • The job number can also be passed as an argument to kill that particular job.
      • The job name can also be passed as an argument to kill a job.
      • Care should be taken while killing a job. We must not kill wrong jobs.
    • Exiting/Quitting When Jobs Have Been Stopped
      • Job control is a very useful method of managing processes.
      • UNIX job control provides a method of warning the users of stopped or running background jobs when an attempt is made to log out or exit a process.
      • It logs out without warning when we issue the same command again, resulting in loss of unsaved data.
    • Summary
      • Programs running in a system are executed by a process that reads the appropriate code and accomplishes the tasks.
      • All the processes have their own unique PID, the PID of their parent, an owner, group, memory, code, input, output, error, and their tty port.
      • A command-line that consists of one process or a series of processes connected by pipes is called a job.
      • The kill command terminates processes identified by either their process ID or job number/job name.
      Summary