GSEC practice question 31 of 35

John works as a Network Administrator for Perfect Solutions Inc. The company has a Linux-based network. John is working as a root user on the Linux…

Full set: 383 questions

Domain Linux: Security and Administration

John works as a Network Administrator for Perfect Solutions Inc. The company has a Linux-based network. John is working as a root user on the Linux operating system. He is currently working on his C based new traceroute program. Since, many processes are running together on the system, he wants to give the highest priority to the cc command process so that he can test his program, remove bugs, and submit it to the office in time. Which of the following commands will John use to give the highest priority to the cc command process?
Answer options
A: nice -n 19 cc -c *.c &
B: nice cc -c *.c &
C: nice -n -20 cc -c *.c & Correct answer
D: nice cc -c *.c
Correct Answer:
C. nice -n -20 cc -c *.c &
Explanation

The nice command is used to modify the scheduling priority of a process in Linux. The "niceness" value ranges from -20 (highest priority) to +19 (lowest priority). A lower niceness value means the process is less "nice" to others and demands more CPU time. To assign the highest possible priority to the cc command, its niceness value must be set to -20. Only the superuser (root) has the privilege to set a negative niceness value, which increases a process's priority relative to others. The command nice -n -20 explicitly sets this highest priority level.

Why Incorrect

A. nice -n 19 cc -c .c & This command sets the niceness value to +19, which is the lowest possible priority, not the highest.
B. nice cc -c .c & Running nice without a specified value defaults to increasing the niceness by 10, resulting in a lower priority.
D. nice cc -c .c This is functionally the same as option B regarding priority; it defaults to a lower priority (niceness +10). ---

References

1. Linux Programmer's Manual

nice(1): The official man page for the nice command states

"nice runs command with an adjusted niceness

which affects process scheduling. If an adjustment is given

it is added to the current niceness value. The range of niceness values is from -20 (most favorable to the process) to 19 (least favorable to the process)... Only the superuser may specify a negative adjustment."

Source: nice(1) — Linux manual page. Available via man nice on any standard Linux distribution.

2. Stallings

W. (2018). Operating Systems: Internals and Design Principles (9th ed.). Pearson. In the chapter on UNIX and Linux scheduling

the text explains: "The nice value is a number in the range -20 to +19

where -20 is the highest priority and +19 is the lowest priority... A nonprivileged user can only increase the nice value of a process... The superuser can both increase and decrease the nice value."

Reference: Chapter 9

Section 9.5 "Linux Scheduling".

3. University of Chicago

Department of Computer Science. (2015). CMSC 12100: Introduction to Linux. Course materials on process management explain the nice command: "The range of nice values is from -20 to 19. The lower the value

the higher the priority of the process... By default

processes start with a nice value of 0. Only the root user can set negative nice values."

Source: Available through University of Chicago's public course archives for CMSC 12100.

Scroll to Top