• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Friday, May 23, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System Linux

4 Useful Tools to Run Commands on Multiple Linux Servers

How VPS by How VPS
November 2, 2018
in Linux, Operating System
0
0
SHARES
32
VIEWS
Share on FacebookShare on Twitter

Contents

  1. 1. PSSH – Parallel SSH
  2. 2. Pdsh – Parallel Remote Shell Utility
  3. 3. ClusterSSH
  4. 4. Ansible

In this article, we will show how to run commands on multiple Linux servers at the same time. We will explain how to use some of the widely known tools designed to execute repetitive series of commands on multiple servers simultaneously. This guide is useful for system administrators who usually have to check the health of multiple Linux servers everyday.

For the purpose of this article, we assume that you already have SSH setup to access all your servers and secondly, when accessing multiple servers simultaneously, it is appropriate to set up key-based password-less SSH on all of your Linux servers. This above all enhances server security and also enables ease of access.

Read Also: How to Configure Custom SSH Connections to Simplify Remote Access

1. PSSH – Parallel SSH

Parallel-SSH is an open source, fast and easy-to-use command line based Python toolkit for executing ssh in parallel on a number of Linux systems. It contains a number of tools for various purposes such as parallel-ssh, parallel-scp, parallel-rsync, parallel-slurp and parallel-nuke (read the man page of a particular tool for more information).

To install parallel-ssh, you need to first install PIP on your Linux system.

$ sudo apt install python-pip python-setuptools 	#Debian/Ubuntu 
# yum install python-pip python-setuptools	        #RHEL/CentOS 
# dnf install python-pip python-setuptools	        #Fedora 22+

Then install parallel-ssh using pip as follows.

$ sudo pip install parallel-ssh

Next, enter the hostnames or IP addresses of remote Linux server with SSH Port in a file called hosts (you can name it anything you want):

$ vim hosts
pssh hosts file
192.168.0.10:22
192.168.0.11:22
192.168.0.12:22

Save the file and close it.

Now run parallel-ssh, specify the hosts file using the -h option and a command(s) that will be executed on all the specified servers. The -i flag means display std output and std error as execution of the command on each server completes.

$ parallel-ssh -h hosts "uptime; df -h"
4 Useful Tools to Run Commands on Multiple Linux Servers

Pssh Run Commands on Multiple Linux Servers

You should also check out: How to Run Multiple Commands on Multiple Linux Servers

2. Pdsh – Parallel Remote Shell Utility

Pdsh is an open source, simple parallel remote shell tool for executing commands on multiple Linux servers at the same time. It employs a sliding window of threads to execute remote commands.

To install Pdsh on your Linux machines, run the appropriate command below.

$ sudo apt install pdsh 	#Debian/Ubuntu 
# yum install pdsh	        #RHEL/CentOS 
# dnf install pdsh              #Fedora 22+

To run commands on multiple servers, add the servers to a hosts file as explained before. Then run pdsh as shown; the flag -w is used to specify the hosts file, and -R is used to specify the remote command module (available remote command modules include ssh, rsh, exec, the default is rsh).

Take note of the ^ before the hosts file.

$ pdsh -w ^hosts -R ssh "uptime; df -h"
4 Useful Tools to Run Commands on Multiple Linux Servers

pdsh – Execute Commands in Multiple Linux Servers

In case you do not specify a remote command to be executed on the command line as shown above, pdsh runs interactively, prompting you for commands and running them when terminated with a carriage return. For more information, see the pdsh man page:

$ man pdsh 

3. ClusterSSH

ClusterSSH is a command line tool for administering clusters of multiple servers at the same time. It launches an administration console and an xterm to all specified servers enabling you to run the same command on all of them.

To use clusterssh, start by installing it on your local Linux computer as shown.

$ sudo apt install clusterssh    #Debian/Ubuntu 
# yum install clusterssh         #RHEL/CentOS 
$ sudo dnf install clusterssh    #Fedora 22+

Now that you have it installed, open an admin console and an xterm on remote servers at once, as follows. To run a command on all the servers, click in the xterm input bar, and type your command; to manage a single host, use its admin console.

$ clusterssh linode cserver contabo
OR
$ clusterssh [email protected] [email protected] [email protected] 
4 Useful Tools to Run Commands on Multiple Linux Servers

Clusterssh – Administer Multiple SSH Sessions

For more information, see the clusterssh man page:

$ man clusterssh

4. Ansible

Ansible is an open source and popular tool to automate IT processes. It is used for configuring and managing systems, deploying applications and so much more.

To install Ansible on Linux systems, run the appropriate command below:

$ sudo apt install ansible       #Debian/Ubuntu 
# yum install ansible            #RHEL/CentOS 
$ sudo dnf install ansible       #Fedora 22+

Once you have installed ansible, you can add your server’s hostnames or IP addresses in the file /etc/anasible/hosts.

$ sudo vim /etc/anasible/hosts

Specify them in groups, e.g webservers.

# Ex 2: A collection of hosts belonging to the 'webservers' group
[webservers]
139.10.100.147
139.20.40.90
192.30.152.186

Save the file and close it.

Now to check the uptime and users connected to all the servers specified in the group webserver, in hosts config file above, simply run the ansible command line tool as follows.

The -a options is used to specify the arguments to pass to the module and -u flag specifies the default username to connect to the remote servers via SSH.

Note that the ansible CLI tool only allows you to execute at most only one command.

$ ansible webservers -a "w " -u admin
4 Useful Tools to Run Commands on Multiple Linux Servers

Ansible – Run Command on Multiple Linux Servers

That’s all! In this article, we have explained how to run commands on multiple remote Linux servers at the same time using widely used tools. If you know of any tools out there for the same purpose, that we have not included in this article, let us know via the comment form below.

Source: tecmint.com

Tags: Linux Commandslinux guidelinux vps setup guide
Previous Post

15 Useful ‘Sockstat Command Examples’ to Find Open Ports in FreeBSD

Next Post

How to Delete Root Mails (Mailbox) File in Linux

Next Post

How to Delete Root Mails (Mailbox) File in Linux

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet