DEV Community 👩‍💻👨‍💻


Posted on • Originally published at on

Running Systemd commands on remote host from your local host

While I was reading the pretty awesome Archlinux wiki for something completely different, I found out that one can launch any systemctlcommand to a remote host via the --host (or -H) flag.

So let say you want to check the cron process on a server named kitten:

$ systemctl -H root@kitten status cron
● cron.service - Regular background program processing daemon
   Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2018-07-28 11:36:37 CST; 2 months 25 days ago
     Docs: man:cron(8)
 Main PID: 1045
    Tasks: 1 (limit: 4643)
   CGroup: /system.slice/cron.service
           └─1045 /usr/sbin/cron -f

Nice right? Under the hood this use SSH so you must have access to the host. And you can, of course, use any systemctl command, not just status ;)

Have fun 👋

This post was originally published on

Top comments (3)

ferricoxide profile image
Thomas H Jones II

Nice trick ...though feels like making Linux a bit more Windows-y. :p

mayeu profile image
Mayeu Author

What are you referring to in Windows that is similar?

ferricoxide profile image
Thomas H Jones II

Most of the Windows system administrator tools allow you to run them either locally or against a remote system.

Our newest Hackathon

Join the DEV x MongoDB Atlas Hackathon 2022 and use your ingenuity and creativity to build an application using MongoDB's cloud based developer data platform, MongoDB Atlas.

Get Started