Dev Samrajya

  • An editor at Canoe
  • Pnq
  • Joined on Jun 30, 2024

posted by Dev Tuesday, March 4, 2025

Mastering the nice Command in Linux


If you’ve ever wanted to tweak how much CPU attention a process gets on your Linux system, the nice command is your go-to tool. This handy command lets you launch a process with a specific "nice value," which essentially tells the system how much priority to give it. In Linux, CPU scheduling is all about priorities, and nice gives you a simple way to influence that. 

So, what’s a nice value? It’s a number between -20 and 19 that determines a process’s priority. Here’s the breakdown: 

    19: The lowest priority (the process politely waits its turn).
    -20: -20: The highest priority (the process gets VIP treatment from the CPU).

By default, most processes start with a nice value of 0. A lower value (closer to -20) means the process hogs more CPU time, while a higher value (closer to 19) makes it less demanding. However, there’s a catch—regular users can only set nice values from 0 to 19. Want to go negative (like -20)? You’ll need root privileges for that.

How to Use It

The syntax is straightforward:  

    nice -n [nice value] [command/process]

For example, if I want to run a backup script (backup.sh) with lower priority so it doesn’t slow down my system, I’d use:


    nice -n 10 ./backup.sh   

Or, if I’m root and need a critical task to take precedence:

    nice -n -15 critical_task

Why It Matters

The nice command is all about balance. On a busy system, you can use it to ensure resource-hungry processes don’t choke everything else—or to give an important task the spotlight it deserves. It’s a simple yet powerful way to manage performance without diving deep into system internals.


Next time you’re juggling processes, give nice a try—it’s like a traffic cop for your CPU!

Labels: , , , , ,

posted by Dev Sunday, October 6, 2024

#01 CSS Geometric background: stripes, lattices, dots, board lattice background (CSS background) #01 Horizontal stripes

↓ Today's learning focus  ↓
  • Learn to draw various stripes, lattice background
  • Learn to draw various dot backgrounds
  • Learn to draw various checkerboard backgrounds 

In addition to the simple gradient color, the gradient layer can also extend to draw other patterns: such as stripes, lattices, dots, checkerboard background, etc., it's amazing! These special backgrounds are what I learned from a good CSS book "CSS Secrets". There are many magical little CSS knowledge in this book, and everyone can borrow it to see it.

But because the book came out in 2016, some grammars did not support it at the beginning, but now it has been supported. This article is dominated by the present and saves some past practices.

Before reading this article, you must first use the basic gradient color and understand the multiple backgrounds.

To make a striped background is very simple. The principle is to use a linear gradient. When the positions of the two colors overlap, a color breakpoint can be created.

Then, use again background-size Set the size of the stripes, and finally use the CSS background preset to repeat ( background-repeat: repeat ) The conditions can create different repeated striped backgrounds.



With this idea, the CSS code of the striped background produced will be:
div {
    background: linear-gradient(
                    #e16e5c 0%,
                    #e16e5c 40%,
                    #f6e3cd 40%);
    background-size: 100% 50px;
}

But there is actually a more concise approach. Here is a key point:

If the position of a color is less than the position of any color in front of it, its position will be set to the maximum position of any color stop point in front of it.

This means that if we set the position of the second color to 0, the browser will adjust its position to the position of the front color stop point, so our CSS code will be more concise and DRY:

div{
    background: linear-gradient(
                    #e16e5c 40%,
                    #f6e3cd 0);
    background-size: 100% 50px;
}

It makes the same sense to build more than two colors.

In addition, the position where the same color starts and ends in the gradient layer (also called the stop point), now the support can be written together, as follows #edb71e 0 66.66% , No need to repeat the second time as before. The latter demonstrations all use such writing.


div {
    background: linear-gradient(
                    #e16e5c 33.33%,
                    #edb71e 0 66.66%,
                    #f6e3cd 0);
    background-size: 100% 30px;
}

DEMO: CSS horizontal strips background

Labels: , , , , ,