nerdexam
CompTIA

LX0-103 · Question #65

Which of the following commands shows the definition of a given shell command?

The correct answer is C. type. The type shell builtin reveals what a given command is - a builtin, alias, function, or external binary - and shows its full definition where applicable.

GNU and Unix Commands

Question

Which of the following commands shows the definition of a given shell command?

Options

  • Awhere
  • Bstat
  • Ctype
  • Dcase

How the community answered

(45 responses)
  • A
    2% (1)
  • B
    2% (1)
  • C
    87% (39)
  • D
    9% (4)

Why each option

The `type` shell builtin reveals what a given command is - a builtin, alias, function, or external binary - and shows its full definition where applicable.

Awhere

`where` (or `whereis`) locates the filesystem path of an external binary but does not reveal shell aliases, functions, or builtins and their definitions.

Bstat

`stat` reports filesystem metadata about a file (size, timestamps, inode, permissions) and has nothing to do with showing a shell command's definition.

CtypeCorrect

In bash and POSIX-compatible shells, `type` is a builtin that identifies the nature of any command name. For shell functions and aliases it prints their complete definition, and for external binaries it prints the resolved path. This makes it the correct tool for inspecting how a shell command is defined.

Dcase

`case` is a shell flow-control construct for pattern matching, not a utility for inspecting other commands.

Concept tested: Shell `type` builtin for command introspection

Source: https://www.gnu.org/software/bash/manual/bash.html#index-type

Topics

#type command#shell built-ins#command lookup

Community Discussion

No community discussion yet for this question.

Full LX0-103 Practice