{"id":21746,"date":"2023-09-30T17:36:20","date_gmt":"2023-09-30T17:36:20","guid":{"rendered":"https:\/\/linuxways.net\/?p=21746"},"modified":"2023-09-30T17:36:20","modified_gmt":"2023-09-30T17:36:20","slug":"how-many-cpu-cores-do-i-have-ubuntu-22-04","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/how-many-cpu-cores-do-i-have-ubuntu-22-04\/","title":{"rendered":"How many CPU cores do I have Ubuntu 22.04?"},"content":{"rendered":"<p>Multiple <strong>CPU (Central Processing Unit) cores <\/strong>enable multitasking and execution of multiple applications simultaneously with the help of <strong>Parallel Processing<\/strong> and <strong>Multiple Threads<\/strong>. Additionally, multiple-core processors reduce power consumption while enhancing system performance.<\/p>\n<p>System performance can be optimized by knowing the CPU Cores, for example, the allocation of resources during virtual machine creation. Additionally, system administrators can utilize this information while assigning various tasks to servers and while managing servers.<\/p>\n<p>This article will demonstrate different ways of determining the number of CPU Cores on Linux\/Ubuntu 22.04 LTS as below:<\/p>\n<ul>\n<li>Using nproc Utility.<\/li>\n<li>Using lscpu Utility.<\/li>\n<li>Using top Utility.<\/li>\n<li>Using \/proc\/cpuinfo File.<\/li>\n<li>Using getconf _NPROCESSORS_ONLN.<\/li>\n<\/ul>\n<h2><a id=\"post-21746-_fftf0pcom24s\"><\/a>Method 1: Determining CPU Cores by Using nproc Utility<\/h2>\n<p>The \u201c<strong>nproc<\/strong>\u201d is a built-in command of Linux that is used to display the number of CPU cores of a system. Here is a practical demonstration of nproc command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span>nproc<\/div><\/div>\n<p>From the below image, it can be seen that there are four CPU cores in our Ubuntu system.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1826\" height=\"136\" class=\"wp-image-21747\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-1.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-1.png 1826w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-1-300x22.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-1-1024x76.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-1-768x57.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-1-1536x114.png 1536w\" sizes=\"auto, (max-width: 1826px) 100vw, 1826px\" \/><\/p>\n<h2><a id=\"post-21746-_hou9xj7tvse2\"><\/a>Method 2: Determining CPU Cores by Using lscpu Utility<\/h2>\n<p>The \u201clscpu\u201d utility displays information related to CPU Architecture, threads per core, CPU cores, etc.<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span>lscpu<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1836\" height=\"1020\" class=\"wp-image-21748\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-2.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-2.png 1836w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-2-300x167.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-2-1024x569.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-2-768x427.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-2-1536x853.png 1536w\" sizes=\"auto, (max-width: 1836px) 100vw, 1836px\" \/><\/p>\n<p>CPU information can be filtered out by using the \u201cegrep\u201d command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span>lscpu <span class=\"sy0\">|<\/span> <span class=\"kw2\">egrep<\/span> <span class=\"st_h\">'CPU\\(s\\)'<\/span><\/div><\/div>\n<p>From the below image, it can be seen that there are four CPU cores in the system.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1828\" height=\"232\" class=\"wp-image-21749\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-3.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-3.png 1828w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-3-300x38.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-3-1024x130.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-3-768x97.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-3-1536x195.png 1536w\" sizes=\"auto, (max-width: 1828px) 100vw, 1828px\" \/><\/p>\n<h2><a id=\"post-21746-_erq2027z3qai\"><\/a>Method 3: Determining CPU Cores by Using top Utility<\/h2>\n<p>\u201ctop\u201d is a built-in Linux utility to display real-time system processes.<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span>top<\/div><\/div>\n<p>Press 1 to view the CPU Core information:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1830\" height=\"1056\" class=\"wp-image-21750\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-4.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-4.png 1830w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-4-300x173.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-4-1024x591.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-4-768x443.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-4-1536x886.png 1536w\" sizes=\"auto, (max-width: 1830px) 100vw, 1830px\" \/><\/p>\n<p>From the above image, it can be seen that there are four CPU cores in the system.<\/p>\n<h2><a id=\"post-21746-_juo116hdjl46\"><\/a>Method 4: Determining CPU Cores by Using \/proc\/cpuinfo File<\/h2>\n<p>The CPU information is stored in \/proc\/cpuinfo file. This information can be accessed by using the cat command as follows:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span><span class=\"kw2\">cat<\/span> <span class=\"sy0\">\/<\/span>proc<span class=\"sy0\">\/<\/span>cpuinfo<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1828\" height=\"1060\" class=\"wp-image-21751\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-5.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-5.png 1828w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-5-300x174.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-5-1024x594.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-5-768x445.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-5-1536x891.png 1536w\" sizes=\"auto, (max-width: 1828px) 100vw, 1828px\" \/><\/p>\n<p>Additionally, specific information about the CPU core can be filtered by a combination of \u201ccat\u201d, \u201cgrep\u201d and \u201cwc\u201d commands, as demonstrated below:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span><span class=\"kw2\">cat<\/span> <span class=\"sy0\">\/<\/span>proc<span class=\"sy0\">\/<\/span>cpuinfo <span class=\"sy0\">|<\/span> <span class=\"kw2\">grep<\/span> processor <span class=\"sy0\">|<\/span> <span class=\"kw2\">wc<\/span> <span class=\"re5\">-l<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1810\" height=\"136\" class=\"wp-image-21752\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-6.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-6.png 1810w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-6-300x23.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-6-1024x77.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-6-768x58.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-6-1536x115.png 1536w\" sizes=\"auto, (max-width: 1810px) 100vw, 1810px\" \/><\/p>\n<p>From the below image, it can be seen that there are four CPU cores in the system.<\/p>\n<h2><a id=\"post-21746-_ns1708k3isyp\"><\/a>Method 5: Determining CPU Cores by Using getconf_NPROCESSORS_ONLN<\/h2>\n<p>The number of cores of the system is stored in \u201cgetconf_NPROCESSORS_ONLN\u201d in a variable and can be displayed by using the echo statement:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span><span class=\"kw3\">echo<\/span> <span class=\"st0\">&quot;Number of CPU\/cores available <span class=\"es2\">$HOSTNAME<\/span> is: <span class=\"es4\">$(getconf _NPROCESSORS_ONLN)<\/span>&quot;<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1838\" height=\"186\" class=\"wp-image-21753\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-7.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-7.png 1838w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-7-300x30.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-7-1024x104.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-7-768x78.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21746-7-1536x155.png 1536w\" sizes=\"auto, (max-width: 1838px) 100vw, 1838px\" \/><\/p>\n<p>From the above image, it can be seen that there are four CPU cores in the system.<\/p>\n<h2><a id=\"post-21746-_532nh5vy46eo\"><\/a>Conclusion<\/h2>\n<p>In Ubuntu 22.04, CPU core information is displayed by \u201cnproc\u201d, \u201clscpu\u201d, \u201ctop\u201d utility, the \u201cproc\/cpuinfo\u201d file output, and by using the \u201cgetconf _NPROCESSORS_ONLN\u201d variable. This article has demonstrated different ways of determining the number of CPU Cores on Linux\/Ubuntu 22.04 LTS.<\/p>","protected":false},"excerpt":{"rendered":"<p>Multiple CPU (Central Processing Unit) cores enable multitasking and execution of multiple applications simultaneously with the help of Parallel Processing and Multiple Threads. Additionally, multiple-core processors reduce power&hellip;<\/p>","protected":false},"author":110,"featured_media":21754,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-21746","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/21746","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/110"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=21746"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/21746\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/21754"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=21746"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=21746"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=21746"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}