command: Command forces the shell to execute the program and ignore any functions, builtins and aliases with the same name

The “command” command is a shell built-in that forces the shell to execute a program and disregard any functions, built-in commands, or aliases that may have the same name as the program being invoked. It allows you to explicitly instruct the shell to ignore any existing definitions and execute the program directly.

When you use the “command” command followed by a program name, the shell bypasses any potential name conflicts and executes the program located in the system’s executable path. This ensures that the desired program is executed without being affected by any local functions, built-ins, or aliases that may have been defined.

The primary purpose of the “command” command is to override local definitions and ensure that a specific program is executed instead. This can be useful in situations where you want to ensure that the original behavior of a program is invoked, regardless of any modifications made through functions, built-ins, or aliases.

By using the “command” command, you can avoid potential issues caused by unintentional name clashes or modifications to the default behavior of a program. It allows you to have explicit control over which version of a program is executed, ensuring consistent and predictable results.

It’s important to note that the “command” command is a shell built-in, which means it is executed within the shell itself and not as a separate program. This built-in functionality is typically available in Unix-like shells such as Bash, Zsh, or Korn Shell.

“command” Command Examples

1. Execute the ls program literally, even if an ls alias exists:

# command ls

2. Display the path to the executable or the alias definition of a specific command:

# command -v command_name

Summary

In summary, the “command” command is a shell built-in that enables you to execute a program while ignoring any functions, built-ins, or aliases with the same name. It ensures that the desired program is executed without being influenced by local definitions. The “command” command provides control over the execution of programs, allowing you to enforce the original behavior and avoid potential conflicts or unintended modifications.

Related Post