0

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?

  • @andrew.46 if I run type read I get read is a shell builtin. – DK Bose Jun 29 '19 at 09:43
  • 2
    See https://askubuntu.com/questions/512918/how-do-i-list-all-available-shell-builtin-commands as well. – DK Bose Jun 29 '19 at 09:45
  • 1
    apt-file search $(which ls) outputs coreutils: /bin/ls. coreutils is the package that provides /bin/ls. Another option is dpkg -S if you know you have the package installed. – Stewart Jun 29 '19 at 11:01
  • Thanks, but how to use with read command? which read returns "1" as exit status code. – Mohammad Kholghi Jun 29 '19 at 11:06
  • 2
    That one is a bit tougher. read 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. If which foo returns 1, then it's probably a built-in shell command. – Stewart Jun 29 '19 at 11:18
  • I didn't see your command before. echo 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:34
  • 2
    @MohammadKholghi See Why is there a /bin/echo and why would I want to use it? where muru's answer is about why bash and some other shells provide echo as a builtin and my answer talks about why /bin/echo exists. Note that the echo builtin does not have an executable path. Instead, the builtin and the external command are separate echo 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

0 Answers0