{
    "mode": "man",
    "parameter": "WHICH",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/WHICH/1/json",
    "generated": "2026-09-17T08:28:36Z",
    "synopsis": "which [-as] filename ...",
    "sections": {
        "NAME": {
            "content": "which - locate a command\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "which [-as] filename ...\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "which  returns  the  pathnames of the files (or links) which would be executed in the current\nenvironment, had its arguments been given as commands in a strictly  POSIX-conformant  shell.\nIt  does this by searching the PATH for executable files matching the names of the arguments.\nIt does not canonicalize path names.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-a",
                    "content": "",
                    "flag": "-a"
                },
                {
                    "name": "-s",
                    "content": "",
                    "flag": "-s"
                }
            ]
        },
        "EXIT STATUS": {
            "content": "0      if all specified commands are found and executable\n\n1      if one or more specified commands is nonexistent or not executable\n\n2      if an invalid option is specified\n\nDebian                                       29 Jun 2016                                    WHICH(1)",
            "subsections": []
        }
    },
    "summary": "which - locate a command",
    "flags": [
        {
            "flag": "-a",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "-s",
            "long": null,
            "arg": null,
            "description": ""
        }
    ],
    "examples": [],
    "see_also": [],
    "tldr": {
        "source": "official",
        "description": "Locate a program in the user's `$PATH`.",
        "examples": [
            {
                "description": "Search the `$PATH` environment variable and display the location of any matching executables",
                "command": "which {{executable}}"
            },
            {
                "description": "If there are multiple executables which match, display all",
                "command": "which {{-a|--all}} {{executable}}"
            }
        ]
    }
}