为什么我收到“找不到命令'deb'”的错误提示?

我遇到了几个安装指南,其中包含了deb命令。但是在我的安装中似乎没有这个命令。
我应该从哪里获取这个命令?有没有其他解决办法?

4请在您有一个好答案的问题上接受一个答案,以显示您喜欢这个答案并且它对您有所帮助。您可以通过左侧的勾选标记来进行操作。 - nanofarad
4我感到很尴尬,我没有意识到我所阅读的指示并不是要我在命令行中输入内容,而是要我将一行文字放入文件中。很高兴你提出了这个问题! - Tyler Collier
6个回答

deb不是一个命令。它在/etc/apt/sources.list文件中用于指示Debian软件仓库。

来自Ubuntu手册 - sources.list

The source list is designed to support any number of active sources and a variety of source media. The file lists one source per line, with the most preferred source listed first. The format of each line is: type uri args. The first item, type determines the format for args. uri is a Universal Resource Identifier (URI), which is a superset of the more specific and well-known Universal Resource Locator, or URL.

The deb type describes a typical two-level Debian archive, distribution/component. The format for a sources.list entry using the deb and deb-src types is:

deb [ options ] uri distribution [component1] [component2] [...]

The URI for the deb type must specify the base of the Debian distribution, from which APT will find the information it needs. distribution can specify an exact path, in which case the components must be omitted and distribution must end with a slash (/). This is useful for when the case only a particular sub-section of the archive denoted by the URI is of interest. If distribution does not specify an exact path, at least one component must be present.

所以,如果我的sources.list文件中有deb http://archive.ubuntu.com/ubuntu/ quantal main restricted - 它表示:我有一个基于http://archive.ubuntu.com/ubuntu/的Debian存档,其中的发行版是quantal,组件是main和restricted。

26sources.list位于12.04版本的/etc/apt/目录下。 - Ahmed Fasih
6如果你说“deb”行是添加到Aptitude源列表的指令,那将会减少整个问题所造成的困惑。这样做可能会很有用。 - Gelmir
因为pgAdmin安装页面中的指引不清晰,我遇到了相同的问题。 - icc97
在我的情况下,复制/粘贴问题将双引号(")转换为类似但不同的字符,导致命令出现以下错误。请注意 deb 前面的奇怪引号字符。 在源列表 /etc/apt/sources.list.d/cloudfoundry-cli.list 的第一行中,“deb” 是未知的。 - user92240

deb不是一个Unix命令。如果你有类似下面这样的一行(用于Docker的源代码):

deb https://apt.dockerproject.org/repo ubuntu-xenial main

这是一行必须在你的Ubuntu的sources.list文件中可用的内容,以便apt-get可以从这个新源找到未来的软件包。
然而,直接编辑/etc/apt/sources.list文件并不是一个好的做法。相反,将deb行作为一个条目添加到/etc/apt/sources.list.d/目录下的一个新的.list文件中。我们将创建一个名为docker.list的文件,内容如下:
echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list

完成后,记得执行sudo apt-get update命令,然后你就可以轻松地从这个源中找到新的软件包了。

就像@Eric Carvalho回答的那样,deb不是命令行。如果你有一个deb文件,URL应该是这样的:
deb http://download.virtualbox.org/virtualbox/debian trusty contrib 

编辑

@muru的提交一样,您需要在/etc/apt/source.list.d/文件夹中创建一个带有扩展名.list的新文件:

示例: 我想下载Oracle虚拟机,创建新文件:

sudo gedit /etc/apt/sources.list.d/oracle-virtualbox-trusty.list 

然后将deb行复制并粘贴到此文件中

1
  1. 这是“apt”,而不是“opt”(尽管有一个“opt”)。
  2. 除非是Ubuntu镜像/官方仓库,否则请勿编辑/etc/apt/sources.list文件以添加一行。在/etc/apt/sources.list.d目录下创建一个扩展名为.list的新文件,并将该行添加进去。
- muru
1@muru “除非是Ubuntu镜像/官方仓库,否则不要编辑/etc/apt/sources.list以添加一行内容。”为什么?当然,在这种情况下,我会在/etc/apt/sources.list.d中创建.list文件,并且通常会推荐这样做。但我看不出坚持让用户手动添加的第三方软件源放在/etc/apt/sources.list.d中的理由。有些配置文件最好不要由用户编辑(例如,使用/etc/profile.d而不是/etc/profile,可以说使用/etc/sudoers.d而不是/etc/sudoers),但sources.list经常会被更改。(甚至由Ubiquity定制为区域镜像。) - Eliah Kagan
@EliahKagan,你何时见过Ubiquity向sources.list添加第三方仓库(而不是镜像)?或者说,任何官方工具都一样?存在sources.list.d是有原因的。我将继续坚持使用它来添加第三方仓库。 - muru
@muru 抱歉,我表达不清楚。我提到Ubiquity的行为是为了指出/etc/apt/sources.list不是那种可以放任不管以便更顺利升级的配置文件之一 - 因为这通常(也许通常)是在强烈建议下,优先创建X.d目录中的文件而不是编辑X文件的动机。我并不是在暗示Ubiquity以任何方式启用第三方软件源。然而,你还没有解释这些软件源有什么特别之处,以至于将它们放入sources.list实际上是错误的(即,“永远不要编辑...”)。 - Eliah Kagan
@EliahKagan 如果这是你对该陈述的问题,那么在这样做上没有“实际错误”。“永远不要[做X]”并不总是意味着做X是错误的,它可以并且确实意味着做X是一种不好的做法(“永远不要使用GOTO。”)。现在开心了吗?重申一遍:我将继续坚持使用sources.list.d来放置第三方存储库和sources.list仅用于镜像和官方存储库,除非你能给我一个明确、合理的理由说明不这样做是个好主意。 - muru
@muru 你是正确的,我修改了我的回答。 - ahmed hamdy

在Ubuntu上,您不需要手动编辑source.list来添加存储库。 相反,您可以使用add-apt-repository,就像为PPA一样操作。
例如,要添加LLVM存储库,您可以执行以下命令:
sudo add-apt-repository 'deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty main'

如你所见,我们必须将deb行作为一个单独的参数传递给命令。

Deb其实不是一个命令(我一开始也是这么认为的)-- 假设你想要下载/安装一个deb文件,可以按照以下步骤进行操作(以此为例):
使用以下命令下载deb文件: wget http://whatever.com/whatever.deb
然后使用以下命令安装deb文件: dpkg -i whatever.deb
接着运行以下命令:
sudo apt-get update

2他显然正尝试下载/安装一个 .deb 文件。 - dylanh724

这不是CLI命令。

这是关于某个Debian软件包仓库的信息(也可被Ubuntu使用)。

如果您想要使用这个仓库:

  1. 以管理员权限打开文件/etc/apt/sources.list

  2. 在该文件中添加一行包含有关仓库信息的内容,以deb ...开头。

  3. 保存文件。

  4. 运行以下命令:

    apt-get update

现在您可以使用这个仓库了。