How to identify command type?

068

You can identify whether a command is a built-in command or an external command in Linux using the following methods:

1. Using type Command

The type command can be used to determine the type of a command.

type <command_name>

Example:

type cd

Output:

cd is a shell builtin

2. Using which Command

The which command shows the path of the executable file for external commands.

which <command_name>

Example:

which ls

Output:

/bin/ls

If the command is a built-in, which will not return a path.

3. Using command -v

The command -v command provides similar functionality to type.

command -v <command_name>

Example:

command -v echo

Output:

echo

If it’s a built-in, it will just return the command name without a path.

Summary

  • Use type to check if a command is built-in or external.
  • Use which to find the path of external commands.
  • Use command -v for a concise output of the command type.

0 Comments

no data
Be the first to share your comment!