Linux – nice sudo or sudo nice

linuxprocess-priorityroot

is there any difference between running an intensive task over sudo with the following commands?:

  1. nice sudo [intensive command here]
  2. sudo nice [intensive command here]

BTW this is for Linux 3.x.

Best Answer

There's a difference, a crucial one.

If you want to decrease the process' priority, the order does not matter. On the other hand, if you want to increase it, you must put sudo before nice.

Since you are running the command as a normal user (otherwise you would not bother with sudo at all), you can only decrease the priority of your command. But if you use sudo first, you can increase it if you want.