I was reading about packages, and I wondered what are package names for commands like "ls" and "echo"? These commands were installed on every Linux machine I've worked with, and I don't know which package installs them.
$ sudo apt purge ls
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package ls
$ sudo apt purge echo
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package echo
And the same thing happened for lots of other commands.
Q1. Is there any package which has all these primary commands in?
Q2. Do "ls" or "echo" or ... have a package? or they are just some commands?
Q3. How can I find the package name of commands like "ls", "echo", "read" and so other?
type read
I getread is a shell builtin
. – DK Bose Jun 29 '19 at 09:43apt-file search $(which ls)
outputscoreutils: /bin/ls
.coreutils
is the package that provides/bin/ls
. Another option isdpkg -S
if you know you have the package installed. – Stewart Jun 29 '19 at 11:01read
command?which read
returns "1" as exit status code. – Mohammad Kholghi Jun 29 '19 at 11:06read
is a built-in bash command. See http://manpages.ubuntu.com/manpages/bionic/man7/bash-builtins.7.html. It doesn't have an executable/file because it's in the bash binary. Ifwhich foo
returns 1, then it's probably a built-in shell command. – Stewart Jun 29 '19 at 11:18echo
is a built-in command too, but it has an executable path/bin/echo
@Stewart. How can I understand the difference? – Mohammad Kholghi Jul 01 '19 at 18:34echo
as a builtin and my answer talks about why/bin/echo
exists. Note that theecho
builtin does not have an executable path. Instead, the builtin and the external command are separateecho
commands. They behave similarity but one is part of bash while the other is its own separate program. – Eliah Kagan Jul 02 '19 at 00:40