HOWTO: Install *.deb *.rpm and Source Code Files

本文介绍了在Linux系统中安装应用程序的两种主要方式:通过发行版特定的包管理和从源代码进行编译。文中详细解释了Debian和Red Hat风格包的区别,并提供了如何使用命令行工具进行安装的具体步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

In a very broad sense, GNU/Linux applications are distributed in two formats: source code and distribution-specific packages.

See Primer on Programming post.

The concept of distributing an application as source code seems foreign to many computer users, but it is extremely logical.

It is usually preferable to find a distribution specific package of the application for your distribution first. Only hunt for source code if you have a reason to such as there is no package for your distro, or the source code version is more up to date than the package version.

Distribution Specific Packages

Possibly the two most common packages out there are Debian and Red Hat style packages. There are others such as Slackware, but Debian and Red Hat are probably the most common.

Debian style packages end in the extension .deb and Red Hat style packages end in the extension .rpm. In general, if you are running a Debian-based system (like Ubuntu, Kanotix, or Debian itself) you should look for a *.deb package for the application; if you’re running a Red Hat-style system (like Fedora, SUSE, or Red Hat itself), then you should look for a *.rpm package for the application.

The words ‘In general’ are emphasized above because some distributions have gone so far off the mainstream track of their flavour that this rule does no apply. For example, Ubuntu is a Debian-based distribution and therefore you should be able to use a *.deb package to install an application. However, Ubuntu has strayed so far from the core Debian stream that there are some *.deb packages that won’t work on Ubuntu. Therefore not only do you want to look for a *.deb package for your Ubuntu but you also want to look specifically for an Ubuntu *.deb package. Attempting to install a standard *.deb package may or may not work.

I am not picking on Ubuntu – this same situation exists for many distros.

You may also have some luck grabbing the proper *.deb or *.rpm from your package manager.

In the terminal window of a Debian-based system (as root), type:

apt-get install application_name

In the terminal window of a Red Hat-based system (as root), type:

yum install application_name

If you’re successful, the application will download and install itself and you’re done.

Source Code

Source code is generally distributed as a tar archive which is usually referred to as a ‘tarball’. The advantage of compiling source code over installing a package is that the application will be built to your specific system. The disadvantage is that your system may not have all of the dependent packages that it requires in order to actually install or run the application. The activity of trying to install any required dependencies for an application is sometimes referred to as ‘dependency hell’ because it can be quite labourious.

Tarballs are generally archived in one of two ways: BZipped (usually has an extension of tar.bz or .tbz) or GZipped (usually has an extension of either .tar.gz or .tgz)

In general, the following steps are used to install a tarball:

  1. For a GZipped tarball: tar –zxvf filename.tar.gz (or filename.tgz)
  2. For a BZipped tarball: tar jzvf filename.tar.bz (or filename.tbz)
  3. ./configure
  4. make
  5. (as root) make install

The configure stage is where your system is queried to see if it has all the dependent files. The make stage is where the executable is actually compiled, and the make install stage is when the completed application is installed onto your system. Generally if you make it past the configure then you’re probably going to be OK.

From "http://www.newlinuxuser.com/howto-install-deb-rpm-and-source-code-files/"

In debian, more choises:
HOWTO: Use dpkg to Install .deb Files.
The Free World: CheckInstall - The Source Installer’s Saviour.

Update:
HOWTO: Best Of - Installing Applications in GNU/Linux
### 回答问题 你提到的是通过 `.deb` 包安装 VS Code 的命令。以下是详细的步骤和解释。 --- #### **1. 安装 VS Code** ```bash sudo dpkg -i <vscode_package>.deb ``` **解释**: - `dpkg` 是 Debian 系统中的包管理工具,用于安装、卸载和管理 `.deb` 格式的软件包。 - `-i` 参数表示安装指定的 `.deb` 文件。 - `<vscode_package>.deb` 是 VS Code 的安装包文件名,你需要将其替换为实际的文件名。 例如,如果你下载的文件名为 `code_1.74.0-1670203859_amd64.deb`,则命令为: ```bash sudo dpkg -i code_1.74.0-1670203859_amd64.deb ``` --- #### **2. 解决依赖问题** 在某些情况下,直接使用 `dpkg` 安装可能会因为缺少依赖项而失败。如果遇到以下错误: ``` dpkg: dependency problems prevent configuration of code: code depends on ... ``` 可以运行以下命令来解决依赖问题: ```bash sudo apt-get install -f ``` **解释**: - `apt-get install -f` 会自动修复未满足的依赖项,并完成软件包的安装。 --- #### **3. 验证安装** 安装完成后,可以通过以下命令验证 VS Code 是否成功安装: ```bash code --version ``` **解释**: - 如果安装成功,该命令会输出 VS Code 的版本号。 --- ### 示例代码:检查 VS Code 是否正确安装 以下是一个简单的 Bash 脚本,用于检查 VS Code 是否已正确安装: ```bash #!/bin/bash # 检查 VS Code 命令是否存在 if command -v code &> /dev/null; then echo "VS Code is installed." # 输出版本信息 version=$(code --version) echo "Version: $version" else echo "VS Code is not installed." fi ``` **解释**: - 使用 `command -v` 检查系统中是否存在 `code` 命令。 - 如果存在,则进一步调用 `code --version` 获取版本信息。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值