0

Why are commands like

"ls", "cat", "touch", "rm", "mkdir"

not internal commands when they already there when you install bash? I feel like external commands should be commands that you can download from elsewhere.

  • Related: [What is the difference between a builtin command and one that is not?](https://unix.stackexchange.com/questions/11454/what-is-the-difference-between-a-builtin-command-and-one-that-is-not) – steeldriver Dec 17 '21 at 17:36
  • All of these _can_ be downloaded form elsewhere. They are all independent binary executables. They just tend to be installed on *nix systems by default. – terdon Dec 17 '21 at 22:23

1 Answers1

3

Because these commands are not part of bash. Even though they are available on most systems by default, those come as a separate software with separate codebase. If you remove those, bash will still continue to operate without any issues.

At the same time bash has built-in tools which are described in built-in section in man (or here). Those are inseparatable from the shell.

Moreover, there's a restricted mode for shell, where you can't execute "external" commands, but builtins are still available for execution.

rush
  • 27,055
  • 7
  • 87
  • 112
  • yeah, and you can update ls to the latest version. While the (internal) command alias will always work the same unless you update the bash. Plus you can use ls on korn shell and it will have the same feature set and version as on bash. If you were to, you could even run ls on Windows Powershell. – Thorsten Staerk Dec 17 '21 at 17:53
  • @ThorstenStaerk, ksh (ksh93 / ksh2020) has both `cat` and `ls` builtin (generally not enabled by default, and the latter often not even *available* by default). There is an "example" `cat` builtin in `bash` as well (also generally not enabled by default, more as part of a proof of the concept of loadable builtins in `bash`). – Stéphane Chazelas Dec 17 '21 at 19:01