• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

taskset Command Examples in Linux

by Deepika

taskset is a Linux command-line utility that allows you to get or set the CPU affinity of a process or start a new process with a defined CPU affinity. The CPU affinity of a process determines which CPU cores are allowed to execute the process’s threads.

By default, a process can run on any CPU core that is available at the time of execution. However, setting CPU affinity can help you optimize the performance of your system. For example, if you have a multi-core processor and you want to dedicate a particular core to a specific process, you can use taskset to do this.

taskset Command Examples

1. Get a running process’ CPU affinity by PID:

# taskset --pid --cpu-list pid

2. Set a running process’ CPU affinity by PID:

# taskset --pid --cpu-list cpu_id pid

3. Start a new process with affinity for a single CPU:

# taskset --cpu-list cpu_id command

4. Start a new process with affinity for multiple non-sequential CPUs:

# taskset --cpu-list cpu_id_1,cpu_id_2,cpu_id_3

5. Start a new process with affinity for CPUs 1 through 4:

# taskset --cpu-list cpu_id_1-cpu_id_4

Summary

In summary, taskset is a useful tool for managing the CPU affinity of processes on a Linux system. It can help you optimize the performance of your system by dedicating specific CPU cores to specific processes. More information about the command can be found in the manual page by typing “man taskset” in the terminal.

Filed Under: Linux

Some more articles you might also be interested in …

  1. “git difftool” Command Examples
  2. Ubuntu Linux – yED(Graph Editor) Alternate of Microsoft Office Visio
  3. How to uninstall local-apt-repository software package in Ubuntu
  4. gnome-terminal Command Examples in Linux
  5. RPM : package installation Error : cpio: read failed
  6. btrfs balance Command Examples in Linux
  7. fossa: CLI for the Fossa service
  8. Linux Network File System (NFS) interview questions
  9. “git reauthor” Command Examples
  10. ipcmk Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright