zoukankan      html  css  js  c++  java
  • wsl 支持systemctl

    wsl支持systemctl

    参考文档: https://zhuanlan.zhihu.com/p/352994199

    1. 安装 daemonize 和 fontconfig

    apt install -y fontconfig daemonize
    

    2.在文件 /etc/profile 末尾加入

    SYSTEMD_PID=$(ps -ef | grep '/lib/systemd/systemd --system-unit=basic.target$' | grep -v unshare | awk '{print $2}')
    
    if [ -z "$SYSTEMD_PID" ]; then
       sudo /usr/bin/daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target
       SYSTEMD_PID=$(ps -ef | grep '/lib/systemd/systemd --system-unit=basic.target$' | grep -v unshare | awk '{print $2}')
    fi
    
    if [ -n "$SYSTEMD_PID" ] && [ "$SYSTEMD_PID" != "1" ]; then
        exec sudo /usr/bin/nsenter -t $SYSTEMD_PID -a su - $LOGNAME
    fi
    

    3.在文件 /etc/sudoers 末尾加入

    %sudo ALL=(ALL) NOPASSWD: /usr/sbin/daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target
    %sudo ALL=(ALL) NOPASSWD: /usr/bin/nsenter -t [0-9]* -a su - [a-zA-Z0-9]*
    

    4. 重启 profile 文件使上面的配置生效

    $ sudo -s
    $ source /etc/profile
    

    5. 完成后如图所示

  • 相关阅读:
    IHttpHandler and HttpModule
    sql page reship
    prototype
    google search engine theory
    ghost
    sql split
    Missing you is a kind of my deeppain in my life
    file control
    a story of c#(reship)
    teacher and student(reship)
  • 原文地址:https://www.cnblogs.com/-xuan/p/15510417.html
Copyright © 2011-2022 走看看