Check if a user is in a group

后端 未结 13 2054
梦如初夏
梦如初夏 2021-01-31 02:42

I have a server running where I use php to run a bash script to verify certain information of a user. For example, I have a webhosting server set up, and in order to be able to

13条回答
  •  我在风中等你
    2021-01-31 03:00

    Bash single line:

    [[ " $(groups) " =~ ' spark ' ]] && echo 'Is in group'
    

    Bash multi line:

    if [[ " $(groups) " =~ ' spark ' ]]; then
        echo 'Is in group'
    fi
    

提交回复
热议问题