Command not found: systemctl on Amazon Linux 2018.03
Asked Answered
L

2

36

I am following this Amazon AWS guide to install SSL certificates. I am running Apache on AWS EC2 using the Amazon Linux AMI 2018.03. The first step in the guide is to run:

sudo systemctl is-enabled httpd

I get "bash: systemctl: command not found". I suspect maybe I am running Amazon Linux, not Amazon Linux 2.

Loch answered 24/8, 2018 at 14:59 Comment(1)
First you need to check if systemd package is installed - sudo dpkg -l | grep systemdHerring
H
41
  1. First check what Amazon linux version you have runnng on using the command cat /etc/os-release
    1. If it is Amazon Linux Version 2, then it does support systemd and comes installed by default.
    2. If it is Amazon linux version 1, then it doesn't support cause Amazon Linux is ultimately based on an old version of CentOS/RHEL.

if it is version 1 (amazon linux), you just need to switch to any other linux distribution that supports systemd. You can't yum install systemd like a package

enter image description here

Herring answered 24/8, 2018 at 17:45 Comment(7)
I must be using v1?Loch
NAME="Amazon Linux AMI" VERSION="2018.03" ID="amzn" ID_LIKE="rhel fedora" VERSION_ID="2018.03" PRETTY_NAME="Amazon Linux AMI 2018.03" ANSI_COLOR="0;33" CPE_NAME="cpe:/o:amazon:linux:2018.03:ga" HOME_URL="aws.amazon.com/amazon-linux-ami"Loch
If v1 should I install systemd?Loch
As far as I know I would recommend switching to any other distribution of Linux taht supports systemd if operating systemd is mandatory for your requirement. Cause I don't think it is something that you can install as a package on your OSHerring
@Loch I confirm that the Amazon Linux AMI 2018.03 is an "Amazon Linux version 1" that does not come with systemd Announcement: Amazon Linux 2018.03 now available. So this is the reason of your issue.Denney
yes, unfortunately we've to upgrade using amzaon 2 instead. the amazon 1 was obsolete, there'll be a lot of package error / required to use systemdCementum
How do you disable a service with service. We also using a Amazon Linux v1 which does not seem to work with systemctl. All I want to achieve is to permanently stop a service without needing to uninstall.Schmidt
H
21
sudo service nginx status

just use the service command

In earlier versions of RHEL use the service command as explained in the documentation here.

# service service_name start

Therefore, in your case:

# service iptables start

You can replace start with restart, stop, status.

List all services with:

# service --status-all
Herakleion answered 17/8, 2019 at 9:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.