美文网首页
mac 上有些命令需要转root

mac 上有些命令需要转root

作者: 芒鞋儿 | 来源:发表于2020-12-20 11:28 被阅读0次

    mac本来自己的account 是有最高权限的,但实际一些命令还需要转成root 才能正确执行,比如lsof -i 这类查看设备进程和端口的命令,就需要root 才能正确执行。
    原因是linux系统中被设置成root权限的并不等于是和root同等权限。

    xxxxxx@xxxnoMacBook-Pro tinyphp % sudo /bin/bash
    Password:
    
    The default interactive shell is now zsh.
    To update your account to use zsh, please run `chsh -s /bin/zsh`.
    For more details, please visit https://support.apple.com/kb/HT208050.
    bash-3.2# lsof -nP -i TCP:80 | grep LISTEN
    httpd    136 root    4u  IPv6 0x504faff83a7aa681      0t0  TCP *:80 (LISTEN)
    httpd    399 _www    4u  IPv6 0x504faff83a7aa681      0t0  TCP *:80 (LISTEN)
    httpd   7304 _www    4u  IPv6 0x504faff83a7aa681      0t0  TCP *:80 (LISTEN)
    httpd   7307 _www    4u  IPv6 0x504faff83a7aa681      0t0  TCP *:80 (LISTEN)
    httpd   7308 _www    4u  IPv6 0x504faff83a7aa681      0t0  TCP *:80 (LISTEN)
    

    当要回到原来的account

    su -
    

    https://www.jianshu.com/p/f4a53d765868

    相关文章

      网友评论

          本文标题:mac 上有些命令需要转root

          本文链接:https://www.haomeiwen.com/subject/bezhnktx.html