Chapter 8 - Managing Processes

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

How can you move the last job that was started in the background back as a foreground job?

'fg' command

What nice value would you apply to a start a process whose priority is at 10 ?

-10 nice -n -10 [COMMAND]

What nice value would you apply to a start a process whose priority at 1 ?

-19 nice -n -19 [COMMAND]

What is the range of the niceness values that can be set with the 'nice' and 'renice' commands?

-20 (most favourable to the process) to 19 (least favourable to the process)

What is the default niceness of a process?

0 (which results in the priority of 20)

What are the two process types?

1. Shell jobs When a user types a command, a shell job is started 2. Daemons

2 command that can be used to change the default priority a process was assigned to the process when it was started

1. nice 2. renice

Two commands that can be used to monitor system usage

1. sar 2. iostat

2 ways to change the priority for a currently running process.

1. the 'renice' command 2. the 'r' command from the top utility

What nice value would you apply to a start a process whose priority is at 30 ?

10 nice [COMMAND] default niceness without any options is 10

What is the default priority that all regular processes are started with ?

20

What is the default priority with of a process with a niceness value of 0?

20

How can a process be told to even after its shell has been closed?

By telling it to ignore the hangup signal (SIGHUP). Use the command 'nohub'

True or False? Regular users can both increase and decrease the priority of a running process.

False Regular users can only decrease the priority of a running process. You must be root to give processes increased priority. Ony root can give a negative niceness number to a process.

When a process is started from a shell, it becomes a child process of that shell. True of False? All process started from a shell are terminated when that shell is stopped.

False. All process EXCEPT the process started in the background will be terminated.

True or False. If you run a command so that it ignores SIGHUP, it will not be killed by SIGTERM or SIGKILL either.

False. Commands ran with nohup is only immune to SIGHUP , not other signals like SIGKILL and SIGTERM

How to sent a kill signal from the top utility.

From top, type k . top will then prompt for the PID of the process you want to send a signal to. By default, the most active process is selected. After you enter the PID, top asks which signal you want to send. By default, signal 15 for SIGTERM is used. However, if you want to insist a bit more, you can type 9 for SIGKILL. Now press Enter to terminate the process.

What is '&' used at the end of a command for?

Starts the command immediately in the background.

What is the default sort field of the top command?

The CPU usage. The process that is taking the most CPU resources is listed first. You can change the sort field with the help of the left and right directional (<, >) keys.

What is SIGHUP ?

The HUP signal is sent to a process when its controlling terminal/shell is closed

True or False? Every process has a Process ID and a Parent Process ID.

True

True or False? When you kill the parent process in Linux, you will also kill all of its active child processes.

True

How can you decrease the priority of a process using the nice and renice commands?

Use a positive niceness

Difference between Ctrl + C and Ctrl + D?

When Ctrl+C is used, the job is just canceled, and nothing is closed properly. When Ctrl+D is used, the job stops waiting for further input, which often is just what is needed to complete in a proper way.

What does the signal, SIGTERM (15) do?

ask a process to stop

What command can you use to continue a job that has been stopped using Ctrl + Z as a background job?

bg

What does the signal, SIGKILL (9) do?

force a process to stop.

Are executed commands started as foreground or background jobs as default?

foreground

Flip the card to see the possible process states you may be observing in the top utility.

https://stackoverflow.com/questions/307502/in-linux-what-do-all-the-values-in-the-top-command-mean

After a process has been told to ignore the hangup signal is started in the background, what happens if the process needs to display output in the STDOUT or STDERR?

it will store the output inside a file named, '/nohup.out'

Which command shows which jobs are currently running from this shell and displays job numbers that can be used as an argument to the commands bg and fg ?

jobs

What is the command used to send a signal to a process?

kill

What command should you use if there are multiple processes using the same name, that need to be killed simultaneously

killall

On your system, 20 processes with the same name are currently running. What is the easiest way to stop all of them?

killall command

Command to see a complete overview of all the available signals that can be sent to processes.

man 7 signals Use kill -l to show a list of available signals that can be used with kill .

Command that can be used to start a process with an adjusted priority.

nice [command] Start command with a nice value (10 by default) nice -n 2 [command] Start command with a nice value of 2

Command used to get a list of all PIDs that have a name containing the string dd.

pgrep dd ps aux | grep dd

What command should you use if you want the kill the process by its name rather than its PID?

pkill

In earlier versions of the bash shell, background processes were also killed when the shell they were started from was terminated. How can you prevent that?

processes could be started with the 'nohup' command in front of it.

Command to get an overview of currently running processes

ps

Command that can be use to review every process currently associated with the user, "zrt"

ps -u zrt

Which command gives an overview of all current shell jobs?

ps aux

Command to use to identify associated with the firefox browser.

ps aux | grep firefox pgrep -a firefox

Command used to show hierarchical relationships between parent and child processes

ps fax

Command used to display a tree of processes

pstree

Command that can be used to change the priority for a currently active process

renice renice -n [niceness no] -p [pid] renice -n [niceness no] -u [user]

What nice value would you apply to a process so that the priority is at 5? The process is currently running at a priority of 25

renice -n -15 -p [PID]

Which option should be used if you wish to format the output of the ps command?

the option -o

Which command can display running Linus tasks in order of their resource usage?

top With top, you can identify those processes that are using the most CPU and RAM memory.

How do you stop the current shell job to continue running it in the background?

CTRL + Z to temporarily stop the job. bg command to top continue running the job in the background

What does the command 'bg' do?

Continues the job that has just been frozen using Ctrl+Z in the background.

How do you stop a job or task that is running and remove the job from memory?

Ctrl + C

How do you temporarily stop a job or task that is running without removing the job from memory?

Ctrl + Z

what does the command 'ps' show?

If used without any arguments, the ps command shows only those processes that have been started by the current user.

A program is taking up too much resources but you don't want to kill the process. What can you do so that it does take up too much resouces?

If you don't want to kill a process, you can lower its priority with the renice command

What does the command 'ps ef' do?

It lists the processes and also the exact command that was used to start the process.

Why is it not a good idea to set process priority to -20?

It risks blocking other processes from getting served.

What does the keystroke, Ctrl + D do to job that is currently running?

It sends the End Of File (EOF) character to the current job. The result is that the job stops waiting for further input so that it can complete what it was currently doing.

How can you kill all the processes a program starts and run simultaneously.

It's at best inefficient to kill just one process. Use the command, killall to kill all processes with the same name

Would the following command run as a non-root user? renice -n -10 [PID]

No. Non root users cannot give a negative niceness number.

Click to see the output from the top command

PR: The priority of the task. NI: The nice value of the task, an adjustment to the priority. VIRT: The virtual memory in KiB used by the task. RES: Physical memory in use by the process, not including swap space, in KiB (similar to RSS in the output to the ps aux command). SHR: Shared memory in KiB available to a task. S: Process status (same as STAT in the output to the ps aux command). %CPU: CPU usage, as a percentage of time spent running since the last top screen update.

Which signal will be sent the process by the following command? kill -9 PID

SIGKILL

Which signal will be sent the process by the following command? kill PID

SIGTERM

Consider the following C program named "get_input.c", when it is run on linux, would you expect the statement "printf("\n input received..exiting program \n");" to be executed if the user presses "Ctrl + d" when the program prompts for input? What about "Ctrl + c"? ----------------------------------------------------------- #include <stdio.h> int main(){ printf("Enter something => "); char input[20]; scanf("%s",input); printf("\n\n input received..exiting program \n\n"); return 0; }

The printf statement will be executed if the user presses "Ctrl + d" as "Ctrl + d" simply sends the End Of File (EOF) character to the current job to indicate that it should stop waiting for further user input. It does not really terminate the program. The statement will not be executed if the user presses "Ctrl + c" as "Ctrl + c" cancels the current interactive job immediately.

What happens to the priority of a process if you apply a negative niceness value to it?

The priority will increase

What does the command 'ps aux' do?

The ps aux command gives a more complete database of currently running processes, in order of their PIDs. The a option lists all running processes. The u displays the output in a user-oriented format The x lifts the standard limitation that listed processes must be associated with a terminal or console.

There are kernel threads. These are a part of the Linux kernel, and each of them is started with its own process identification number (PID). Kernel threads cannot be managed. You cannot adjust their priority; neither is it possible to kill them, except by taking the entire machine down How can you recognize kernel threads?

They have a name that is between square brackets.

What does the signal, SIGHUP (1)do?

This signal is used to hang up a process. The effect is that the process will reread its configuration files, which makes this a useful signal to use after making modifications to a process configuration file.

How to renice a running process from the top utility?

To renice a running process from top, type r . You are first prompted for the PID of the process you want to renice. After entering the PID, you are prompted for the nice value you want to use. Enter a positive value to increase process priority or a negative value to decrease process priority

A user is asking you to cancel one of the jobs he has started. You cannot access the shell that user currently is working from. What can you do to cancel his job anyway?

You can monitor the process via the top utility and send a kill signal to the job's process id

Why is it bad idea to use 'kill -9' as in general?

You risk losing data. Your system may become unstable if other processes depend on the process you have just killed.


Set pelajaran terkait

Essentials of Pediatric Nursing - Chapter 21

View Set

Health Assessment: Assessing Head and Neck

View Set

baseball midterm 2 - identifications

View Set

Marketing Research & Analysis Ch. 3- Chaudhry

View Set

1.1 Introduction to risk management

View Set

TLE 7 - PRODUCTS AND SERVICES AVAILABLE IN THE MARKET

View Set