We already talked about changing process priority while discussing top, but you don't need top
to change process priority. Let's check out how to do it from the command line.
By default, user processes are started with the same priority.
And to adjust priorities, users can use the nice command.
Non privileged users can only run processes with a lower priority.
And privileged users can increase and decrease process priority as well.
And the reach is from minus 20, which is the highest
priority, to positive 19, which is giving you the lowest priority.
And if you want to change the priority for currently running processes, you would use the renice command.
We already have seen how to do it from top.
Now let's change some priorities from the command line.
So I'm going to use sudo nice help.
Of course you don't need sudo to get help, but what I'm looking for is the syntax.
So in the syntax you can see N N is the adjustment.
Okay, so that means that I'm going To use
sudo nice n10 dd if is dev 0 of
is dev null running as a background.
And let's also do another priority, same command, sudo nice n minus 10.
And then still the best way to figure out would be top.
But hey, can we also see it from another perspective?
Figure it out. Psaox pipe grab DD and there we can
see these DD processes to give you the cycles anyway. And
that's why you can see them having the same CPU percentage.
So the first DD process with PID 6351 has the PR
set to 3030 and the nice value set to 10.
So that's the friendly process. The other one has the PR set to 10
and a nice value set to minus 10. And that's the unfriendly process.
You can also change priority on running processes.
So let me use dd if is dev0 of is
device dev null again as a background job. Oops.
So running jobs to verify that it is actually running. And I'm looking for job number five here.
And that is the one that we're talking about.
And what happens if we see it in top? Well, I can see
the student job which is running with a CPU percentage of almost 100.
Now if I want to change the priority for that,
then first I need PS A and PS A is
showing not enough information psaux Anyway, pipe grab dd.
Now let's start again with if I want to change the priority.
If I want to change the priority, I need to remember the process id 6685.
Let me quit top and let me use renice
minus n19 on pid 6685 there we can see
that it has rescheduled the priority. The old priority
was zero and the new priority is 19.
That is how you can manage priority from the command line.
Let's not forget to do a sudokel all DD because otherwise we
have too many processes that are being quite busy on this system.