How does `type` differ from `which`?

0154

The type and which commands in Linux serve different purposes:

  1. type:

    • Provides information about how a command is interpreted by the shell.
    • It can indicate if a command is a built-in shell command, an alias, a function, or an executable file.
    • Example usage:
      type ls
  2. which:

    • Locates the executable file associated with a command in the directories listed in the PATH environment variable.
    • It only returns the path of the executable file if it exists.
    • Example usage:
      which ls

In summary, type gives more detailed information about the command's nature, while which simply finds the path of the executable.

0 Comments

no data
Be the first to share your comment!