Change Course of Precedence in Linux With good and renice

Would you like to change the priority of certain processes on Linux? You can just do this with the nice and renice command.

Linux lets you run many processes on a computer without missing a clock. Sometimes an intense process can slow down your system. Wouldn't it be great if there was a way to kind of take a back seat as you move on to other tasks? You can use a utility called nice.

Play well with processes

Nice is a utility built into Linux and Unix systems that can reduce the CPU priority of a process. This utility is an artifact from when Unix ran on multi-user minicomputers and mainframes. However, it is still useful on single-user desktops today.

You may be playing a game and experiencing delays due to an intense process that you know will take a long time to output, like a torrent client. Just assign it to the background and keep playing.

Nice is either a stand-alone program or integrated into the shell. To find out what is happening on your system, enter the following:

what beautiful

On Ubuntu, the version of nice install is the GNU version.

Nice uses the concept of a "nice number" which is the process priority of any process. In the GNU version, it ranges from 19 to -20. The negative numbers give more priority to the process while the positive numbers give less. You can see this lovely number for that NI Column in utilities like above or htop.

Use this command to run a lower priority process:

nice process name

Replace Task name with the process you want to run. By default, nice assigns the nice number 10. All normally started processes are set to 0 by default.

If you want a specific number, in this case the absolute minimum priority, use that -n Option with the beautiful number you want:

nice -n 19 process name

Changing the process priority With renice

Now you can start commands with a reduced priority. But what about changing the priority of executing processes? You can also do this with another utility, renice.

You need the PID or Process ID of the process you want to change. You can determine this with the ps, top, or htop command. Once you find that, all you have to do is run it to the renice command.

Enter the following to set a new nice number for your PID:

Renice Priority PID

…Where priority is the cute number that you want to use.

The -n The flag changes the process priority by the increment you mentioned, either positive or negative. So if you had a process with 10 and wanted to change it to 8, enter this:

sudo renice -n -2 PID

Only the superuser can redefine processes that belong to another user or increase the priority of a process. You can use the … -u Switch followed by the Username To set the priority for each user:

Renice priority -u username

Connected: What is a process on Linux?

Now you can change the process priorities for the best performance

With nice and renice you can change the priority of any process on Linux. This will surely help you in times when a heavy process is consuming a large chunk of your system resources. It can also be helpful to use monitoring tools such as Stacer to optimize system performance.

Optimize and monitor the performance of your Linux system with Stacer

Would you like to have a better experience by improving the performance of a Linux computer? Everything you need to know about Stacer can be found here.

Continue reading

About the author

David Delony
(17 articles published)

David is a freelance writer living in the Pacific Northwest but originally from the Bay Area. He has been a technology enthusiast since childhood. David's interests include reading, watching quality TV shows and movies, retro games, and collecting records.

By David Delony

Subscribe to our newsletter

Sign up for our newsletter to receive tech tips, reviews, free e-books, and exclusive offers!

One more step …!

Please confirm your email address in the email we just sent you.

Leave a Reply

Your email address will not be published. Required fields are marked *