找不到命令:Amazon Linux 2018.03上的systemctl

时间:2018-08-24 14:59:42

标签: amazon-web-services amazon-linux

我正在关注this Amazon AWS guide to install SSL certificates。我正在使用Amazon Linux AMI 2018.03在AWS EC2上运行Apache。该指南的第一步是运行:

sudo systemctl is-enabled httpd

我收到“ bash:systemctl:找不到命令”。我怀疑也许我正在运行Amazon Linux,而不是Amazon Linux 2。

3 个答案:

答案 0 :(得分:10)

  1. 首先使用来检查您运行的Amazon Linux版本 命令cat /etc/os-release
    1. 如果它是Amazon Linux版本2,则 它确实支持systemd并默认安装。
    2. 如果是 Amazon Linux版本1,则不支持,原因是Amazon Linux 最终基于旧版本的CentOS / RHEL。

如果它是版本1(amazon linux),则只需切换到支持systemd的任何其他linux发行版。您不能像软件包一样安装systemd

enter image description here

答案 1 :(得分:3)

sudo service nginx status

只需使用服务命令

在早期版本的RHEL中,按照documentation here中的说明使用service命令。

# service service_name start

因此,在您的情况下:

# service iptables start

您可以将start替换为restartstopstatus

列出以下所有服务:

# service --status-all

答案 2 :(得分:-6)

Amazon Linux是JUNK。不要使用它。选择其他发行版。

[ec2-user@ip-172-30-0-61 ~]$ cat /etc/os-release
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="http://aws.amazon.com/amazon-linux-ami/"

[ec2-user@ip-172-30-0-61 ~]$ sudo systemd
sudo: systemd: command not found