{"id":36307,"date":"2025-03-06T03:39:24","date_gmt":"2025-03-06T03:39:24","guid":{"rendered":"https:\/\/green.cloud\/docs\/docs\/greencloud-documents\/linux-operating-systems\/how-to-use-stress-command-on-linux\/"},"modified":"2026-01-30T04:33:10","modified_gmt":"2026-01-30T04:33:10","slug":"how-to-use-stress-command-on-linux","status":"publish","type":"docs","link":"https:\/\/green.cloud\/docs\/how-to-use-stress-command-on-linux\/","title":{"rendered":"How to use stress command on linux"},"content":{"rendered":"<h2>Overview<\/h2>\n<p>Stress is a command used to apply a load to the system to test its load capacity in practice. It will create processes that use a lot of system resources, such as CPU, RAM, or disk, so that we can test the capacity and threshold at which our system works best. It is also very useful to reproduce the high load state that causes system errors so that we can find a way to handle it.<\/p>\n<p><iframe title=\"How to Use the stress Command on Linux | VPS Tutorial\" width=\"1170\" height=\"658\" src=\"https:\/\/www.youtube.com\/embed\/9DSYrhDH4f8?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<h2>Installation<\/h2>\n<p>To use stress, you need to install stress packages<\/p>\n<h3>On CentOS<\/h3>\n<pre>yum install stress<\/pre>\n<h3>On Ubuntu<\/h3>\n<pre>apt-get install stress<\/pre>\n<p>Usage<br \/>\nYou can stress your system with CPU, memory, I\/O, and HDD parameters, or stress multiple parameters simultaneously. Below, I will give some specific examples so you can know how to use it.<\/p>\n<h3><strong>Test CPU<\/strong><\/h3>\n<p>To test CPU, use the &#8211;cpu or -c option<\/p>\n<p>Command<\/p>\n<pre>stress -c 1<\/pre>\n<p>You can see the CPU before using the stress command<br \/>\n<img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full wp-image-36483\" src=\"https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_1.png\" alt=\"\" width=\"898\" height=\"194\" srcset=\"https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_1.png 898w, https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_1-300x65.png 300w, https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_1-768x166.png 768w\" sizes=\"(max-width: 898px) 100vw, 898px\" \/><\/p>\n<p>I went on a stressful fishing run<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-36485\" src=\"https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_2.png\" alt=\"\" width=\"897\" height=\"51\" srcset=\"https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_2.png 897w, https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_2-300x17.png 300w, https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_2-768x44.png 768w\" sizes=\"(max-width: 897px) 100vw, 897px\" \/><\/p>\n<div class=\"gtx-body\">And here is the CPU<br \/>\n<img decoding=\"async\" class=\"alignnone size-full wp-image-36487\" src=\"https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_3.png\" alt=\"\" width=\"903\" height=\"198\" srcset=\"https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_3.png 903w, https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_3-300x66.png 300w, https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_3-768x168.png 768w\" sizes=\"(max-width: 903px) 100vw, 903px\" \/><\/div>\n<div>With this command, a process is created to calculate the sqrt() function of any number. The CPU will continue to calculate until you press Ctrl+C or set a time limit by adding the &#8211;timeout or -t option. For example<\/div>\n<div>\n<pre>stress --cpu 1 --timeout 30<\/pre>\n<p>Then, this command will automatically stop after 30sBecause each sqrt() function pushed in will be a process, it will occupy the entire CPU. So what will happen when the number of processes is more than the number of CPUs we have? Here, I pushed in 2 processes that are twice as large as the number of CPUs in my machine<\/p>\n<pre>stress -c 2<\/pre>\n<p>And this is the result<\/p>\n<\/div>\n<div><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-36489\" src=\"https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_1-1.png\" alt=\"\" width=\"904\" height=\"192\" srcset=\"https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_1-1.png 904w, https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_1-1-300x64.png 300w, https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_1-1-768x163.png 768w\" sizes=\"(max-width: 904px) 100vw, 904px\" \/><br \/>\nAt this time, each process will only use 50% of the CPU, which means the processing speed will be reduced by half<\/p>\n<h3><strong>Test memory<\/strong><\/h3>\n<p>To push the load into RAM for testing, we use the -m or &#8211;vm option<\/p>\n<p>Command<\/p>\n<pre>stress -m 1<\/pre>\n<p>This command will use the malloc() function to allocate memory for a process, here, it will be 256M. Or we can indicate the capacity allocated to a process using the &#8211;vm-bytes option. For example, allocate 500M to each process<\/p>\n<pre>stress -m --vm-bytes 500M<\/pre>\n<p>You can see the RAM usage level before using the stress command<\/p>\n<\/div>\n<div><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-36493\" src=\"https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_1-2.png\" alt=\"\" width=\"905\" height=\"192\" srcset=\"https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_1-2.png 905w, https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_1-2-300x64.png 300w, https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_1-2-768x163.png 768w\" sizes=\"(max-width: 905px) 100vw, 905px\" \/><br \/>\nWe see that RAM is used less and swap memory is not used. Now we run the stress command<\/p>\n<pre>stress -m 1 --vm-bytes 600M\r\nstress: info: [10768] dispatching hogs: 0 cpu, 0 io, 1 vm, 0 hdd<\/pre>\n<p>We observe the RAM at this time<\/p>\n<\/div>\n<div><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-36495\" src=\"https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_2-1.png\" alt=\"\" width=\"903\" height=\"192\" srcset=\"https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_2-1.png 903w, https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_2-1-300x64.png 300w, https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_2-1-768x163.png 768w\" sizes=\"(max-width: 903px) 100vw, 903px\" \/><br \/>\nThe RAM value changes continuously because this command uses two malloc functions to allocate memory and then the free function to free it.<\/p>\n<h3><strong>Test disk<\/strong><\/h3>\n<p>You can also see how your system works when it is constrained by I\/O. You use the -i option<\/p>\n<p>Command<\/p>\n<pre>stress -i 1<\/pre>\n<p>This command will call the sync() function. In addition, you can test the disk&#8217;s ability to write data by using the -d option.<\/p>\n<pre>stress -d 1 --timeout 10s<\/pre>\n<p>The command writes a 1 GB file to the disk. You can specify its capacity by adding the &#8211;hdd-bytes option. For example, if you want to write a 2 GB file<\/p>\n<pre>stress -d 1 2G --timeout 1m<\/pre>\n<p>You don&#8217;t have to worry about cleaning up these files after running the command because it will clean up these files for you when the command ends.<\/p>\n<h2>Summary<\/h2>\n<p>Here are some specific examples of the stress command. This command can help you a lot. There are certainly many shortcomings in the article. I look forward to your comments.<\/p>\n<p>Good luck!<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Overview Stress is a command used to apply a load to the system to test its load capacity in practice. It will create processes that use a lot of system resources, such as CPU, RAM, or disk, so that we can test the capacity and threshold at which our system works best. It is also [&hellip;]<\/p>\n","protected":false},"author":15,"featured_media":0,"parent":17817,"menu_order":401,"comment_status":"closed","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-36307","docs","type-docs","status-publish","hentry","no-post-thumbnail"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to use stress command on linux - GreenCloud Documentation<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/green.cloud\/docs\/how-to-use-stress-command-on-linux\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to use stress command on linux - GreenCloud Documentation\" \/>\n<meta property=\"og:description\" content=\"Overview Stress is a command used to apply a load to the system to test its load capacity in practice. It will create processes that use a lot of system resources, such as CPU, RAM, or disk, so that we can test the capacity and threshold at which our system works best. It is also [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/green.cloud\/docs\/how-to-use-stress-command-on-linux\/\" \/>\n<meta property=\"og:site_name\" content=\"GreenCloud Documentation\" \/>\n<meta property=\"article:modified_time\" content=\"2026-01-30T04:33:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"898\" \/>\n\t<meta property=\"og:image:height\" content=\"194\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/green.cloud\\\/docs\\\/how-to-use-stress-command-on-linux\\\/\",\"url\":\"https:\\\/\\\/green.cloud\\\/docs\\\/how-to-use-stress-command-on-linux\\\/\",\"name\":\"How to use stress command on linux - GreenCloud Documentation\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/green.cloud\\\/docs\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/green.cloud\\\/docs\\\/how-to-use-stress-command-on-linux\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/green.cloud\\\/docs\\\/how-to-use-stress-command-on-linux\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/green.cloud\\\/docs\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/Screenshot_1.png\",\"datePublished\":\"2025-03-06T03:39:24+00:00\",\"dateModified\":\"2026-01-30T04:33:10+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/green.cloud\\\/docs\\\/how-to-use-stress-command-on-linux\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/green.cloud\\\/docs\\\/how-to-use-stress-command-on-linux\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/green.cloud\\\/docs\\\/how-to-use-stress-command-on-linux\\\/#primaryimage\",\"url\":\"https:\\\/\\\/green.cloud\\\/docs\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/Screenshot_1.png\",\"contentUrl\":\"https:\\\/\\\/green.cloud\\\/docs\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/Screenshot_1.png\",\"width\":898,\"height\":194},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/green.cloud\\\/docs\\\/how-to-use-stress-command-on-linux\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/green.cloud\\\/docs\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"GreenCloud Documents\",\"item\":\"https:\\\/\\\/green.cloud\\\/docs\\\/docs\\\/greencloud-documents\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Linux Operating Systems\",\"item\":\"https:\\\/\\\/green.cloud\\\/docs\\\/linux-operating-systems\\\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"How to use stress command on linux\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/green.cloud\\\/docs\\\/#website\",\"url\":\"https:\\\/\\\/green.cloud\\\/docs\\\/\",\"name\":\"GreenCloud Documentation\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/green.cloud\\\/docs\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to use stress command on linux - GreenCloud Documentation","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/green.cloud\/docs\/how-to-use-stress-command-on-linux\/","og_locale":"en_US","og_type":"article","og_title":"How to use stress command on linux - GreenCloud Documentation","og_description":"Overview Stress is a command used to apply a load to the system to test its load capacity in practice. It will create processes that use a lot of system resources, such as CPU, RAM, or disk, so that we can test the capacity and threshold at which our system works best. It is also [&hellip;]","og_url":"https:\/\/green.cloud\/docs\/how-to-use-stress-command-on-linux\/","og_site_name":"GreenCloud Documentation","article_modified_time":"2026-01-30T04:33:10+00:00","og_image":[{"width":898,"height":194,"url":"https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_1.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/green.cloud\/docs\/how-to-use-stress-command-on-linux\/","url":"https:\/\/green.cloud\/docs\/how-to-use-stress-command-on-linux\/","name":"How to use stress command on linux - GreenCloud Documentation","isPartOf":{"@id":"https:\/\/green.cloud\/docs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/green.cloud\/docs\/how-to-use-stress-command-on-linux\/#primaryimage"},"image":{"@id":"https:\/\/green.cloud\/docs\/how-to-use-stress-command-on-linux\/#primaryimage"},"thumbnailUrl":"https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_1.png","datePublished":"2025-03-06T03:39:24+00:00","dateModified":"2026-01-30T04:33:10+00:00","breadcrumb":{"@id":"https:\/\/green.cloud\/docs\/how-to-use-stress-command-on-linux\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/green.cloud\/docs\/how-to-use-stress-command-on-linux\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/green.cloud\/docs\/how-to-use-stress-command-on-linux\/#primaryimage","url":"https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_1.png","contentUrl":"https:\/\/green.cloud\/docs\/wp-content\/uploads\/2025\/03\/Screenshot_1.png","width":898,"height":194},{"@type":"BreadcrumbList","@id":"https:\/\/green.cloud\/docs\/how-to-use-stress-command-on-linux\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/green.cloud\/docs\/"},{"@type":"ListItem","position":2,"name":"GreenCloud Documents","item":"https:\/\/green.cloud\/docs\/docs\/greencloud-documents\/"},{"@type":"ListItem","position":3,"name":"Linux Operating Systems","item":"https:\/\/green.cloud\/docs\/linux-operating-systems\/"},{"@type":"ListItem","position":4,"name":"How to use stress command on linux"}]},{"@type":"WebSite","@id":"https:\/\/green.cloud\/docs\/#website","url":"https:\/\/green.cloud\/docs\/","name":"GreenCloud Documentation","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/green.cloud\/docs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"permalink_manager":null,"_links":{"self":[{"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/docs\/36307","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/comments?post=36307"}],"version-history":[{"count":12,"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/docs\/36307\/revisions"}],"predecessor-version":[{"id":40993,"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/docs\/36307\/revisions\/40993"}],"up":[{"embeddable":true,"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/docs\/17817"}],"wp:attachment":[{"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/media?parent=36307"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/doc_tag?post=36307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}