User anna started a job that currently has nice value 10. As anna, she runs `renice 5 -p <pid>` to set its nice value to 5. What happens?
LPIC-1 Exam 101-500, objective 103. GNU and Unix commands hard
Draft — not checked yet. This question was written from the published exam objectives and cites the clause it comes from, but nobody has yet read it against that clause and signed for it.
It is kept out of search results and out of mock exams until they have. Read the source below before you take the answer as settled.
The options
Correct It fails with a permission error, because lowering a nice value requires root privileges.
Correct. Going from 10 to 5 raises the process's priority, and an unprivileged user may only increase a nice value, never decrease it.
Not correct It succeeds and the process becomes less favourable to the scheduler.
Wrong twice over. Moving from 10 to 5 would make the process MORE favourable, and an unprivileged user is not allowed to make that change at all.
Not correct It succeeds, because a user may always renice their own processes to any value.
Wrong. Ownership lets an unprivileged user raise the nice value of their own processes; it never permits lowering it. That restriction is what stops users from grabbing CPU.
Not correct It succeeds but the change only takes effect for child processes started afterwards.
Wrong. renice changes the nice value of the running process immediately. Children started later inherit the value in effect when they are forked.
Why
Only root (strictly, a process with CAP_SYS_NICE, or a user given room by the RLIMIT_NICE limit) may lower a nice value and so raise priority. An ordinary user can only be nicer: raise the number. This is a one-way ratchet — anna could go from 10 to 15, but not back down to 10 afterwards. Note that the priority given directly as the first argument is always an absolute value; the -n form is absolute too on Linux's util-linux renice, but POSIX and the BSD renice treat -n as a relative increment, so prefer the positional form when in doubt.
Where this comes from
- Cited
- LPI exam objective 103.6
- What it says
- Only the superuser may decrease a process's nice value.
Practise this
Reading one question is not practice. The trainer will draw a set from objective 103 and space the ones you get wrong.