STUDY/Windows
WSL 우분투 "System has not been booted with systemd as init system" 에러
끄적이는 보송
2021. 7. 4. 21:21
반응형
sudo systemctl start
윈도우 WSL 우분투 환경에서 이 간단한 명령어가 안먹혀 당황스러웠다. 이유는 해당 OS는 systemd 를 사용하지 않기 때문이라고 한다. 하지만 (대부분) SysV init system (sysvinit) 을 사용한다. 그렇다면 어떻게 에러는 어떻게 해결할 수 있을 까? 답은 간단하다. 안쓰면 된다
다음 표를 참고하자
systemctl start service_name | service service_name start |
systemctl stop service_name | service service_name stop |
systemctl restart service_name | service service_name restart |
systemctl status service_name | service service_name status |
systemctl enable service_name | service service_name on |
systemctl disable service_name | service service_name off |
간단한 예시다. 이게 싫다면 명령어를 맵핑하는 방법을 꾀할 수 있다. 어떻게?
/usr/sbin/systemctl 을 수정하자 !
해당 경로의 파일을 다음과 같이 수정 및 저장하고 적절한 권한을 부여하면 된다.
#!/bin/bash
command=$1 lookup_find=('start' 'stop' 'restart' 'status' 'enable' 'disable')
lookup_replace=('start' 'stop' 'restart' 'status' 'on' 'off')
for i in "${!lookup_find[@]}";
do if [[ "${lookup_find[i]}" = "$command" ]];
then
command="${lookup_replace[i]}"
fi
done
service "$2" "$command"
그 결과 아주 잘 된다!
반응형