---
# System prepended metadata

title: What is the running system and service manager?
tags: [CLI, '*nix', UN*X]

---

# What is the running system and service manager?

[TOC]

###### tags: `*nix` `cli`

---

## First Method

系統第一個啟動的 process。

### SysV

```shell
$ ps -p 1
    PID TTY          TIME CMD
      1 ?        00:00:01 init
```

### systemd

```shell
$ ps -p 1
    PID TTY          TIME CMD
      1 ?        00:00:03 systemd
```

### upstart

```shell
$ ps -p 1
    PID TTY          TIME CMD
      1 ?        00:00:01 init
```

## Second Method

系統第一個啟動的 process 的 symbolic link。

### SysV

```shell
$ sudo ls -l /proc/1/exe
lrwxrwxrwx 1 root root 0 Jan  1 00:00 /proc/1/exe -> /sbin/init
```

或

```shell
$ sudo stat /proc/1/exe | grep File
  File: /proc/1/exe -> /sbin/init
```

### systemd

```shell
$ sudo ls -l /proc/1/exe
lrwxrwxrwx 1 root root 0 Jan  1 00:00 /proc/1/exe -> /usr/lib/systemd/systemd
```

或

```shell
$ sudo stat /proc/1/exe | grep File
  File: /proc/1/exe -> /usr/lib/systemd/systemd
```

### upstart

```shell
$ sudo ls -l /proc/1/exe
lrwxrwxrwx 1 root root 0 Jan  1 00:00 /proc/1/exe -> /sbin/upstart
```

或

```shell
$ sudo stat /proc/1/exe | grep File
  File: /proc/1/exe -> /sbin/upstart
```

## Third Method

`/sbin/init` 的指向。

### SysV

```shell
$ sudo ls -l /sbin/init
lrwxrwxrwx 1 root root 0 Jan  1 00:00 /sbin/init
```

### systemd

```shell
$ sudo ls -l /sbin/init
lrwxrwxrwx 1 root root 0 Jan  1 00:00 /sbin/init -> /lib/systemd/systemd
```

### upstart

```shell
$ sudo ls -l /sbin/init
lrwxrwxrwx 1 root root 0 Jan  1 00:00 /sbin/init -> upstart
```

## Reference

- [Detecting which system manager is running on Linux System](https://linuxconfig.org/detecting-which-system-manager-is-running-on-linux-system)

## See Also

- [Spring Boot Application as a Service](https://www.baeldung.com/spring-boot-app-as-a-service)
