Install stress Command on Ubuntu 23.10

Install stress Command on Ubuntu 23.10

Stress command is a versatile tool used to impose load on a Linux system, allowing users to simulate various type of stress conditions on CPU, memory, I/O, and other system components. It plays a major role in testing system stability, performance analysis, and evaluating how a system behaves under different workloads. With configurable parameters, it can create load on specific resources, making it a handy utility for performance testing and troubleshooting.

Prerequisites

  • Linux based Server (Ubuntu 23.10).
  • Access of Root or Sudo user.

Also Read: How to Clear RAM Memory Cache, Buffer and Swap Space on Linux

Installation

  • Update the server repositories.
sudo apt update
  • Install the stress command with some prerequisites packages on the server.
sudo apt install -y htop stress
  • To verify the installation, run the following command to check the version.
stress --version

Test the Stress command

There are two ways to generate server load: by stressing the CPU or by imposing load on the RAM. To test the stress command, we will use two SSH sessions: one to initiate the command and another to monitor the server’s load.

Stress on CPU

To create load on the CPU, run the following command.

sudo stress --cpu 2 --timeout 60

Adjust the number of CPU and the Timeout value as per your requirement to increase the load on CPU. After executing the above command, detach from the screen session.

Stress on RAM

To create load on the RAM, run the following command.

stress --vm 1 --vm-bytes 700M --vm-hang 0

Replace <size> with the amount of memory on which you want to create load. Make sure the value of “–vm-bytes” must be lower than the value of RAM, Otherwise the command will not work. For instance, to create load on 1GB of RAM, use 700M.

Monitor the Stress

We can monitor the server with several commands such as top, uptime and many more. In this tutorial, we will use the htop command utility to monitor the server load.

sudo htop
Monitor the load created by stress command

Remove the Stress command

To remove the stress command from the server, simply execute the following command.

sudo apt purge --autoremove -y stress

Conclusion

In today’s tutorials, we have learned how we can use stress command to test our server resources by simulating various type of load conditions on CPU and Memory. Creating a swap file on a server is recommended to enhance resource utilization and assist in managing server load effectively and efficiently. If you guys have any queries and question then please share your queries in the comment section.