How to make `apt-get upgrade` use less resources?

When I run sudo apt-get upgrade with a lot of packages on my low-end laptop, I get a perceptible system slowdown, sometimes with up to 3 second screen freezes.

Is there any way to mark this job as very low priority, i.e. use very little CPU, MEM and HDD? I don't really care if it would make apt-get upgrade two hours longer to finish, I just want to keep working without the disruptions during the upgrade.


The command nice can be used to manipulate process CPU scheduling priorities. The command assigns a "niceness" value from -20 (most important) to +19 (least important) to the process. Root can assign any value, other users only positive ones (minor importance). The default value is 0.

nice -n <niceness> <command>

To set the priority of an apt-get command to the least value, you can use the command

sudo nice -n 19 apt-get upgrade

To set the priority of an already running process, the command renice can be used:

renice -n <niceness> -p <pid>

Edit: Thanks to @David for mentioning the ionice command, which lets you manipulate disk I/O priority. It can put a process into three different classes:

  • Idle only gives the process disk time, if no other process claims it at the moment.
  • Best-effort (default class). This allows you to assign priorities from 0 to 7, where 0 is most important and 7 least. You may try assigning -n 7 as the priority level.
  • Realtime processes are handled before everything else, suspending disk I/O for other processes, as soon as they require it for themselves. Use with care!

IOnice combines the syntax of nice and renice:

ionice [-c class] [-n level] command             #To start a new process
ionice [-c class] [-n level] -p pid              #To change a running process

Both commands can be combined, e.g.

sudo ionice -n 7 nice -n 19 apt-get upgrade      #Omitting the -c switch will assign Best-effort
sudo nice -n 19 ionice -n 7 apt-get upgrade
nice -n 19 ionice -n 7 sudo apt-get upgrade
...