Close Menu
    X (Twitter)
    Hectic GeekHectic Geek
    • Apps
      • Apps for Mac
      • Apps for PCs
      • Best Apps
    • Concepts
      • Comparison
      • For Geeks
      • IT Careers
    • Gadgets
      • Accessories
      • Best Work Laptops
      • Budget Laptops
    • GNU/Linux
      • Ubuntu
    • How To
      • Virtualization
      • Windows
      • Windows How-To
    Hectic GeekHectic Geek
    Home » Stress Test Your Ubuntu Computer with ‘Stress’
    Ubuntu

    Stress Test Your Ubuntu Computer with ‘Stress’

    GayanBy GayanNovember 21, 2012Updated:December 17, 201712 Comments5 Mins Read
    Twitter Reddit Telegram WhatsApp Email
    Share
    Twitter Reddit Telegram WhatsApp Email

    Sometimes, stress testing a computer (despite what operating system it uses) can be a very useful thing. For example, if you have a faulty hardware, say a hard disk drive that is having performance issues, then you can run disk I/O intensive tests to see whether it is stable or not.

    Or, if you have just overclocked your hardware (CPU, GPU, RAM …) and want to make sure that it won’t make your computer unstable, before applying those changes permanently, then stress testing is among the best ways of knowing that also (or for evaluating the capability of your PC in general).

    Stress testing can also be used to benchmark certain software applications, such as an I/O scheduler or a task scheduler (for instance) as well. If you use Ubuntu and prefer a tool with a GUI, then you can use ‘lbench’. It has a simple user interface and very easy to use, and is primarily a benchmarking tool. But, if you are okay with using the command-line, then you can also try ‘Stress’.

    It lets you put stress on your:

    *. CPU

    *. RAM

    *. Disk Drive (only supports write tests).

    It can not stress other hardware such as the GPU though. You can also delay the starting of the stress tests and make it automatically exit after running for a certain amount of time (in seconds) as well.

    Remember, ‘Stress’ is not actually a benchmarking utility, as it does not give you any speed related outputs (like ‘lbench’ does), but is only a utility that lets you stress your computer. Still, you can use it as a work load generator, for while benchmarking other utilities, such as an I/O scheduler, as mentioned above too.

    If interested, you can install it in Ubuntu 12.10 Quantal Quetzal, 13.04, 12.04 Precise Pangolin, 11.10, 10.10 and 10.04 by using the below command in your Terminal window.

    sudo apt-get install stress

    How to use it?

    You can use ‘Stress’ to stress the above mentioned hardware individually or you can stress them all at the same time too.

    Stressing the CPU

    If you want only to stress the CPU, then you can use it in the below format (on your Terminal window, of course).

    stress -c 1

    Depending on the type of your CPU, make sure to replace ‘1‘ accordingly. For example, if you have a CPU with four cores and would like to stress them all, then you should be using the below command.

    stress -c 4

    You can also enter a number, higher than the available CPU cores for adding a lot more stress on the CPU as well. In other words, if I put 50 individual processes to stress my CPU (‘stress -c 50‘), rather than using 4 processes, it will make the OS more unstable.

    Note: You can cancel (exit) ‘Stress’ anytime by pressing ‘Ctrl’ + ‘c’ keys or by closing the Terminal window.

    Stressing the Memory (RAM)

    Let’s say that I wanted to stress my 4GB RAM module using three processes, with each about 256MiB in size (by default). Then I’ll use the below command.

    stress -m 3

    You can again replace ‘3‘ with the number of processes to be used, plus, can also change the size of the processes by using the ‘–vm-bytes …’ attribute.

    So if I wanted to use 4 process with each sizing around 300MiB, then I’ll use the below command.

    stress -m 4 –vm-bytes 300M

    Note: However, for stressing your RAM, the CPU also has to do a lot of work as well. And as a result, if the used processes were more or equal to the available cores, then they will use 100% of your CPU power.

    Stressing the Disk Drive

    If you want to stress the disk drive only, then use the below command.

    stress -d 1

    ‘1‘ represents the number of processes that will be used to stress your disk drive. Again, you can replace this number accordingly. By default, ‘Stress’ uses 1GB file size for each process (you use the ‘–hdd-bytes’ argument for changing that), so make sure your have enough free space left before running this test.

    For stressing my HDD with 2 processes, with each sizing around 512MB, I can use the below command.

    stress -d 2 –hdd-bytes 512M

    Note: Unlike with the RAM stress test, HDD stress test does not require a lot of CPU usages.

    Stressing CPU, RAM and HDD simultaneously

    If I wanted to stress the CPU, RAM and the HDD at the same time, then I can use it in the below format.

    stress -c 4 -m 2 -d 1

    As you can see, in this instance, ‘Stress’ will stress the CPU using four processes, RAM will be stressed using 2 processes (each sizing around 256MiB) and the disk will be stressed with a process that is about 1GB in size.

    Setting up a timeout

    ‘Stress’ also lets you run these tests for a chosen time frame. Let’s say that I wanted to run the above test, only for 40 seconds, then I’ll simply add the ‘-t’ argument and the new command will look like the below one.

    stress -c 4 -m 2 -d 1 -t 40s

    After running for 40 seconds, it will exit automatically.

    You can also use the ‘-t’ argument while running other individual tests as well. Its manual contains all these details. You can use the below command for reading it.

    man stress

    But please remember that, stressing your hardware unnecessarily is not recommended as it can easily damage them. So use it only, when it is absolutely necessary.

    Share. Twitter Reddit Telegram WhatsApp Email
    Gayan

    An RHCE, 'Linux' user with 14+ years of experience. Extreme lover of Linux and FOSS. He is passionate to test every Linux distribution & compare with the previous release to write in-depth articles to help the FOSS community.

    Related Posts

    Debian vs Ubuntu Server: A Brief Comparison for Beginners

    July 2, 2023

    CPU Based Simple System Stability and Benchmark Tester for Ubuntu Linux – systester

    June 16, 2023

    Typespeed: Typing Speed Testing Game for Ubuntu Linux

    March 12, 2023

    Debian vs Ubuntu in 2023- Which Linux OS is Right for You?

    January 6, 2023

    How to Remove PulseAudio & use ALSA in Ubuntu Linux?

    October 2, 2022

    How to Show Hidden Files in Ubuntu 22.04 LTS (and hide them)

    May 25, 2022

    12 Comments

    1. Sainik Biswas on May 28, 2014 4:03 pm

      I was looking for a way to stress my cpu to so that I can check that my cooler master hyper tx3 cpu cooler was working or not. It works nicely. Thanks a lot.

      Reply
      • Gayan on May 29, 2014 6:38 am

        You’re welcome Sainik.

        Reply
    2. Pista on June 26, 2014 6:31 pm

      Is there any way to load CPU with 75% or 50%? I mange to load 25% by adding some usleep into code but cant get 75% of CPU load.

      Reply
      • Gayan on June 27, 2014 7:01 am

        Hi Pista,

        I’m not sure if that is possible. But if your CPU has 4 or more cores, then as I mentioned in the article, it is possible to stress each individually and get a similar effect using the below command.

        stress -c 1

        Replace ‘1’ with the number of cores that you want to stress. You can also have a look into its manual for more information.

        info stress

        Reply
    3. Henry on July 25, 2014 3:34 pm

      Hi Gayan,

      I am new to linux, want to try learn it, bought a cheap second hand intel core2 dell, with 3 gig ram, and 160g HDD, I want to stress the system to check if machine is ok, like not overheating.

      What would be a nice stress that I could run for a long period to monitor it?

      Regards,

      Henry

      Reply
      • Gayan on July 26, 2014 11:09 am

        Hi Henry,

        You could use the below command which will consume 50% of your total CPU power (assuming that your CPU has two cores), 1500MiB of your RAM and will stress your HDD with 4 processess (100MB each).

        stress -c 1 -m 3 --vm-bytes 500M -d 4 --hdd-bytes 100M

        You can also add the ‘-t’ option to execute it for a given time-frame (in seconds) as well. For instance, if you want to execute the above ‘stress’ custom profile for about 3 minutes, then you should use it as below:

        stress -c 1 -m 3 --vm-bytes 500M -d 4 --hdd-bytes 100M -t 180s

        Feel free to change the arguments to suite your needs (increase the number of CPU cores that should be involved if you have more than two, for instance) but try not to be too aggressive… good luck.

        Reply
    4. paul on February 28, 2015 3:45 am

      Is it possible to write the output of these commands to file? or is it possible to run these with vmstat etc simultaneously?
      or do i need to run the stress and compare vmstat before and after stress?

      Reply
      • Gayan on March 5, 2015 7:26 am

        Hi Paul,

        Sorry about the late response. And yes, you can write the output of ‘stress’ to a file and run ‘vmstat’ while running ‘stress’ as well. The command would look something like the below one…:

        stress --cpu 8 --io 4 --vm 2 --vm-bytes 128M --timeout 30s >> stress_output.txt & watch -d -n 1 vmstat

        If you want the output of ‘stress’ to include more information, then you can include the ‘-v’ option as well:

        stress --cpu 8 --io 4 --vm 2 --vm-bytes 128M -v --timeout 30s >> stress_output.txt & watch -d -n 1 vmstat

        Hope this helps.

        Reply
    5. miniziomek on November 9, 2015 9:19 am

      Hi!

      One quick question,
      If I do:

      stress -m 4

      do I actually testing all of ram but sequentially, or I’m just testing couple of megs like a range for example from 0 to 600M ? Do the program testing all of my ram just writing to different location and freeing other and then accomplish test of all of my ram eventually?

      I don’t know how to ask, but do I have to know special command for testing 8 gigs of ram to be tested properly all of them? For example:

      stress -m 4 –vm-bytes 1000M

      Do I actually testing only range of ram from 0 – 1000M or its only chunk of data tested in one sub test and freed step by step, eventually testing all of my ram?

      I’m not a specialist, but its good to know how it works, cause I don’t know how to test my 8 gigs of ram, cause I can’t do it with memtest86+ cause the never version (only new version is working properly from what I know for newer ram modules) is only for UEFI bios and I don’t have one. Its relatively new hardware but without UEFI support. The ram is Patriot 1600MHz, and when I do memtest86+, at first it just works and then it is slowing down. So the gurus from memtest are recommending me to use newer memtest like from 6 version, but It cant run from non UEFI bios and its sad…

      Also if anyone knows how to run this never memtest, let me know please.

      Reply
      • Gayan on November 10, 2015 8:04 am

        Hi,

        If all you want is to test a certain portion of your RAM, all at once, then you should use the ‘–vm-keep’ argument. For instance, to test 1GB at once, the below command should be used:

        stress -m 4 --vm-keep

        As soon as it runs, it’ll increase the RAM usage by 1GB (at once), which can be confirmed if you have the system monitor opened. Does that answer your question?

        Reply
    6. Alex on July 13, 2017 6:21 pm

      Checkout this tool we have created for linux. It uses stress and has a stress options menu. It also show the current Frequency Utilization and Temperature of you CPU. Perfect for stability testing

      Reply
      • Gayan on July 25, 2017 10:54 am

        Hi Alex,

        Where’s the link?

        Reply

    Leave A Reply Cancel Reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    Latest Posts

    [Fixed] HDMI No Signal to TV or Monitor on Windows 10/11

    November 7, 2023

    AlmaLinux vs Ubuntu – How to Select the Best One?

    October 22, 2023

    Why Does My Gaming Laptop’s Battery Drain So Fast? The Science Behind It

    October 9, 2023

    Top 10 Best email Encrypting Software for Business and Personal Use

    October 7, 2023

    7 Essential Features A Learning Management System Should Include

    October 2, 2023

    The Importance of DNS for Mac Users: Why You Need to Know How It Works

    September 25, 2023

    Subscribe to Updates

    Get the latest news and updates from Hectic Geek. We won't overload you or sell your data!

    Contact
    • About Us
    • Contact Us
    • Privacy Policy
    • Write for Us
    X (Twitter)
    © 2023 Hectic Geek.

    Type above and press Enter to search. Press Esc to cancel.