LiveFire Labs: Online UNIX Training with Hands-on Internet Lab

"Taking a LiveFire Labs' course is an excellent way to learn Linux/Unix. The lessons are well thought out, the material is explained thoroughly, and you get to perform exercises on a real Linux/Unix box. It was money well spent."

Ray S.
Pembrook Pines, Florida

LiveFire Labs' UNIX and Linux Operating System Fundamentals course was very enjoyable. Although I regularly used UNIX systems for 16 years, I haven't done so since 2000. This course was a great refresher. The exercises were fun and helped me gain a real feel for working with UNIX/Linux OS. Thanks very much!"

Ming Sabourin
Senior Technical Writer
Nuance Communications, Inc.
Montréal, Canada

Read more student testimonials...

Receive UNIX Tips, Tricks, and Shell Scripts by Email

LiveFire Labs' UNIX Tip, Trick, or Shell Script of the Week

UNIX Process Priorities

As you likely know, UNIX and Linux operating systems are multiuser environments. If you have a large number of users on the system, you will also have a large number of processes running on the system. In addition to all of the user processes running on a system, there are also many processes needed to keep the system running smoothly, and to provide system services to users.

If these system processes do not receive adequate CPU time, the result could be major system problems. To ensure that these key processes get the CPU time they need, their assigned execution priority numbers are higher than those of the user processes.

A process's execution priority number is used by the operating system to schedule CPU time for the process. As implied in the previous paragraph, processes with higher execution priority numbers are given more CPU time than those with lower execution priority numbers. The operating system (kernel) automatically and continually computes and updates each process's execution priority number based on several different factors.

Although the operating system ultimately controls a process's execution priority number, there is a way for a process owner to reduce the priority of his or her processes. This may be accomplished by changing the nice number of their process.

A process's nice number is the process's priority number with respect to other processes. A process with a higher nice number, or higher level of niceness, will yield CPU time to other processes on the system. A process with a lower nice number will have a lower level of niceness relative to other processes.

The nice number of a process can be increased by the owner of the process, and increased or decreased by the superuser/root. The nice command is used when a command is started to alter the command's nice number from its default.

The syntax for the nice command is as follows:

$ nice [-adjustment] command


$ nice [-n adjustment] command

The value for adjustment can be an integer between 1 and 19. Negative adjustment numbers can be used with the nice command, but only the superuser/root can use them. The higher the adjustment number, the lower the overall priority of the process will be. If no adjustment number is specified, the default value of positive 10 will be used. This is equivalent to executing the following command:

$ nice -10 command

Don't let the hyphen in front of the 10 trick you into thinking the adjustment is negative 10. This command makes an adjustment of positive 10. If you were superuser/root and wanted to make an adjustment of negative 10, you would use the following command:

$ nice --10 command

Notice the two hyphens before the 10. The first hyphen indicates it's an option and the second hyphen indicates a negative value.

TIP: The nice command is only used when a command is first ran, or in other words when the process is first created. To change the nice number of a running process, the renice command should be used.

Need a simple script to monitor and restart your system processes automatically?

See ProcMonUX - a Simple Lightweight Process Monitor Script with Alerts, Restart and Logging for more info. It works with both UNIX and Linux...and it's FREE!