LFCS Exam QuestionsBrowse all questions from this exam

LFCS Exam - Question 69


Regarding the command:

nice -5 /usr/bin/prog

Which of the following statements is correct?

Show Answer
Correct Answer: A,B

The nice command is responsible for adjusting the scheduling priority of a given process. In Unix-like operating systems, nice values range from -20 to +19, where lower numerical values indicate higher priority. In the command 'nice -5 /usr/bin/prog', the value '-5' is directly specified, indicating that the program '/usr/bin/prog' will be executed with a nice level of -5, giving it a higher priority compared to the default, which is typically 0. Hence, '/usr/bin/prog' will run with a nice level of -5.

Discussion

7 comments
Sign in to comment
ignou143Option: D
Dec 8, 2020

D would right answer. Any guess?

StribOption: A
Jun 16, 2023

A. /usr/bin/prog is executed with a nice level of -5. Explanation: The nice command is used to execute a program with an adjusted scheduling priority (nice value). The nice value ranges from -20 to +19, where lower values indicate higher priority. In the given command, nice -5 /usr/bin/prog, the value -5 is specified as the nice level. This means that the program /usr/bin/prog will be executed with a nice level of -5, indicating a higher priority compared to the default value (usually 0). So, option A is correct: /usr/bin/prog is executed with a nice level of -5.

EliteAllenOption: B
Jan 3, 2024

B. /usr/bin/prog is executed with a nice level of 5. The -5 here indicates that the nice value is being increased by 5, which means that /usr/bin/prog will be less prioritized than other processes with lower nice values. The higher the nice value, the lower the CPU scheduling priority of the process. Remember that a negative nice value would require root privileges to apply, and it would mean a higher priority, not lower.

vukOption: B
Feb 6, 2021

According to Ubuntu 20.04 the answer here is correct. The process has Nice level of 5 with that command.

Borbz
Feb 16, 2021

Isn't the default NICE level 0? The first one is a nice value (niceness) which ranges from -20 (highest priority value) to 19 (lowest priority value) and the default is 0. if the default nice level is 0 and we execute a nice -5, the result should be -5. I'm I wrong? this is the second question i see about NICE levels and it seems everyone is assuming the default nice level to be 10 instead of 0. Can anyone clarify?

Borbz
Feb 16, 2021

Forget my previous reply, the command "nice -5" will actually increase the nice to 5, so answer B is correct. tested in lab.

Funkslinger
Feb 25, 2022

Default nice if command is used is 10, original priority or nice level if nice command is never used is 0, neutral.

IvandragoOption: B
Dec 20, 2021

B is correct. to set -5 use nice --5 or nice -n 5

MPA3333Option: A
Mar 29, 2024

https://www.howtogeek.com/411979/how-to-set-process-priorities-with-the-nice-and-renice-commands-in-linux/ So the nice value is 5, so it's A.

MPA3333
Mar 29, 2024

Sorry, it's B. (a positive value), my typo

9866666Option: B
Jun 25, 2024

I would say it is B.