{
    "mode": "info",
    "parameter": "sg",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/sg/json",
    "generated": "2026-08-02T10:24:41Z",
    "synopsis": "sg [-] [group [-c ] command]",
    "sections": {
        "NAME": {
            "content": "sg - execute command as different group ID\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "sg [-] [group [-c ] command]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The sg command works similar to newgrp but accepts a command. The\ncommand will be executed with the /bin/sh shell. With most shells you\nmay run sg from, you need to enclose multi-word commands in quotes.\nAnother difference between newgrp and sg is that some shells treat\nnewgrp specially, replacing themselves with a new instance of a shell\nthat newgrp creates. This doesn't happen with sg, so upon exit from a\nsg command you are returned to your previous group ID.\n",
            "subsections": []
        },
        "CONFIGURATION": {
            "content": "The following configuration variables in /etc/login.defs change the\nbehavior of this tool:\n\nSYSLOGSGENAB (boolean)\nEnable \"syslog\" logging of sg activity.\n",
            "subsections": []
        },
        "FILES": {
            "content": "/etc/passwd\nUser account information.\n\n/etc/shadow\nSecure user account information.\n\n/etc/group\nGroup account information.\n\n/etc/gshadow\nSecure group account information.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "id(1), login(1), newgrp(1), su(1), gpasswd(1), group(5), gshadow(5).\n\nshadow-utils 4.8.1                02/06/2024                             SG(1)",
            "subsections": []
        }
    },
    "summary": "sg - execute command as different group ID",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "id",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/id/1/json"
        },
        {
            "name": "login",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/login/1/json"
        },
        {
            "name": "newgrp",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/newgrp/1/json"
        },
        {
            "name": "su",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/su/1/json"
        },
        {
            "name": "gpasswd",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/gpasswd/1/json"
        },
        {
            "name": "group",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/group/5/json"
        },
        {
            "name": "gshadow",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/gshadow/5/json"
        }
    ]
}