Systemd system and services manager can be controlled using the systemctl command line utility. It enables you to manage systemd locally or on a remote Linux machine over the SSH protocol.
In this short article, we will show you how to manage systemd system and service manager on a remote Linux machine over a SSH session.
Attention: We recommend using public/private key pairs for passwordless authentication for SSH, as opposed to passwords, and also employing additional methods to secure SSH service, as explained in these guides.
- SSH Passwordless Login Using SSH Keygen in 5 Easy Steps
- 5 Best Practices to Secure and Protect SSH Server
- How to Block SSH and FTP Access to Specific IP and Network Range
To connect to a remote server, run systemctl with the --host or -H flag as follows. In the command below, we are connecting to the remote server as the root user and status is a subcommand of systemctl utility used to view the status of the httpd service on centos.temint.lan (remote Linux server).
$ systemctl --host [email protected] status httpd.service
OR
$ systemctl -H [email protected] status httpd.service

Manage Systemd Service on Remote Linux
Similarly, you can also start, stop or restart remote systemd service as shown.
$ systemctl --host [email protected] start httpd.service
$ systemctl --host [email protected] stop httpd.service
$ systemctl --host [email protected] restart httpd.service
To end the session, simply type [Ctrl+C]. For more information and usage options, see the systemctl man page:
$ man systemctl
That’s all for now! What follows is an assortment of systemd articles which you’ll find useful:
- The Story Behind: Why ‘init’ Needed to be Replaced with ‘systemd’ in Linux
- Managing System Startup Process and Services (SysVinit, Systemd and Upstart)
- Manage Log Messages Under Systemd Using Journalctl [Comprehensive Guide]
- How to Create and Run New Service Units in Systemd Using Shell Script
- How to Change Runlevels (targets) in SystemD
In this article, we showed you how to manage systemd system and service manager on a remote Linux machine. Use the feedback section to ask questions or share your thoughts about this guide.
',
enableHover: false,
enableTracking: true,
buttons: { twitter: {via: 'tecmint'}},
click: function(api, options){
api.simulateClick();
api.openPopup('twitter');
}
});
jQuery('#facebook').sharrre({
share: {
facebook: true
},
template: '
{total}
',
enableHover: false,
enableTracking: true,
click: function(api, options){
api.simulateClick();
api.openPopup('facebook');
}
});
jQuery('#googleplus').sharrre({
share: {
googlePlus: true
},
template: '
{total}
',
enableHover: false,
enableTracking: true,
urlCurl: 'https://www.tecmint.com/wp-content/themes/tecmint/js/sharrre.php',
click: function(api, options){
api.simulateClick();
api.openPopup('googlePlus');
}
});
jQuery('#linkedin').sharrre({
share: {
linkedin: true
},
template: '
{total}
',
enableHover: false,
enableTracking: true,
buttons: {
linkedin: {
description: 'How to Control Systemd Services on Remote Linux Server',media: '/uploads/2018/01/Control-Systemd-Services-on-Remote-Linux.png' }
},
click: function(api, options){
api.simulateClick();
api.openPopup('linkedin');
}
});
// Scrollable sharrre bar, contributed by Erik Frye. Awesome!
var shareContainer = jQuery(".sharrre-container"),
header = jQuery('#header'),
postEntry = jQuery('.entry'),
$window = jQuery(window),
distanceFromTop = 20,
startSharePosition = shareContainer.offset(),
contentBottom = postEntry.offset().top + postEntry.outerHeight(),
topOfTemplate = header.offset().top;
getTopSpacing();
shareScroll = function(){
if($window.width() > 719){
var scrollTop = $window.scrollTop() + topOfTemplate,
stopLocation = contentBottom - (shareContainer.outerHeight() + topSpacing);
if(scrollTop > stopLocation){
shareContainer.offset({top: contentBottom - shareContainer.outerHeight(),left: startSharePosition.left});
}
else if(scrollTop >= postEntry.offset().top-topSpacing){
shareContainer.offset({top: scrollTop + topSpacing, left: startSharePosition.left});
}else if(scrollTop < startSharePosition.top+(topSpacing-1)){
shareContainer.offset({top: startSharePosition.top,left:startSharePosition.left});
}
}
},
shareMove = function(){
startSharePosition = shareContainer.offset();
contentBottom = postEntry.offset().top + postEntry.outerHeight();
topOfTemplate = header.offset().top;
getTopSpacing();
};
/* As new images load the page content body gets longer. The bottom of the content area needs to be adjusted in case images are still loading. */
setTimeout(function() {
contentBottom = postEntry.offset().top + postEntry.outerHeight();
}, 2000);
if (window.addEventListener) {
window.addEventListener('scroll', shareScroll, false);
window.addEventListener('resize', shareMove, false);
} else if (window.attachEvent) {
window.attachEvent('onscroll', shareScroll);
window.attachEvent('onresize', shareMove);
}
function getTopSpacing(){
if($window.width() > 1024)
topSpacing = distanceFromTop + jQuery('.nav-wrap').outerHeight();
else
topSpacing = distanceFromTop;
}
});
Source:
tecmint.com