软件安装和程序包管理器如何在Linux上工作

image

Installing software on Linux involves package managers and software repositories, not downloading and running .exe files from websites like on Windows. If you’re new to Linux, this can seem like a dramatic culture shift.

在Linux上安装软件涉及软件包管理器和软件存储库,而不是从Windows上的网站下载并运行.exe文件。 如果您不熟悉Linux,那么这似乎是一种巨大的文化转变。

While you can compile and install everything yourself on Linux, package managers are designed to do all the work for you. Using a package manager makes installing and updating software easier than on Windows.

虽然您可以自己在Linux上编译和安装所有内容,但软件包管理器旨在为您完成所有工作。 使用软件包管理器比Windows上的安装和更新软件更容易。

Linux与Windows (Linux vs. Windows)

There are a wide variety of Linux distributions and a wide variety of package managers. Linux is built from open-source software, which means that each Linux distribution compiles its own software with its desired library versions and compilation options. Compiles Linux applications generally don’t run on every distribution – even if they could, installation would be hindered by competing package formats.If you locate a Linux application’s website, you’ll likely see a variety of download links for different package formats and Linux distributions – assuming the application’s website provides pre-compiled versions at all. The application may tell you to download the source code and compile it yourself.

有各种各样Linux发行版和各种各样的软件包管理器。 Linux是从开源软件构建的,这意味着每个Linux发行版都将使用所需的库版本和编译选项来编译自己的软件。 编译Linux应用程序通常不会在每个发行版上运行,即使它们可以运行,竞争的软件包格式也会阻碍安装。如果您找到Linux应用程序的网站,则可能会看到各种针对不同软件包格式和Linux的下载链接。发行版-假设应用程序的网站完全提供了预编译版本。 该应用程序可能会告诉您下载源代码并自己进行编译。

image

软件仓库 (Software Repositories)

Linux users don’t normally download and install applications from the applications’ websites, like Windows users do. Instead, each Linux distribution hosts their own software repositories. These repositories contain software packages specially compiled for each Linux distribution and version. For example, if you’re using Ubuntu 12.04, the repositories you use contain packages specially compiled for Ubuntu 12.04. A Fedora user uses a repository full of packages specially compiled for their version of Fedora.

Linux用户通常不像Windows用户那样从应用程序的网站下载和安装应用程序。 相反,每个Linux发行版都托管自己的软件存储库。 这些存储库包含为每个Linux发行版和版本专门编译的软件包。 例如,如果您使用的是Ubuntu 12.04,则您使用的存储库包含专门为Ubuntu 12.04编译的软件包。 Fedora用户使用的存储库中充满了针对其Fedora版本专门编译的软件包。

image

包装经理 (Package Managers)

Think of a package manager like a mobile app store – except they were around long before app stores. Tell the package manager to install software and it will automatically download the appropriate package from its configured software repositories, install it, and set it up – all without you having to click through wizards or hunt down .exe files on websites. When an update is released, your package manager notices and downloads the appropriate update. Unlike on Windows, where each application must have its own updater to receive automatic updates, the package manager handles updates for all installed software — assuming they were installed from the software repositories.

可以将包裹管理器想象成一个移动应用商店,只是他们离应用商店很久。 告诉程序包管理器安装软件,它将自动从其配置的软件存储库中下载适当的程序包,进行安装和设置-所有这些都无需单击向导或在网站上查找.exe文件。 发布更新后,您的程序包管理器会注意到并下载适当的更新。 与Windows上不同,在Windows上,每个应用程序必须具有自己的更新程序才能接收自动更新,而程序包管理器则处理所有已安装软件的更新-假定它们是从软件存储库中安装的。

image

什么是包裹? (What’s a Package?)

Unlike on Windows, where applications come in .exe installer files that can do anything they like to the system, Linux uses special package formats. There are a variety of package types – most notably DEB on Debian and Ubuntu and RPM on Fedora, Red Hat, and others. These packages are essentially archives containing a list of files. The package manager opens the archive and installs the files to the location the package specifies. The package manager remains aware of which files belong to which packages – when you uninstall a package, the package manager knows exactly which files on the system belong to it. Windows has no idea what files belong to an installed application – it lets application installers manage installation and uninstallation themselves.

与Windows上的应用程序包含可以执行其系统所需功能的.exe安装程序文件不同,Linux使用特殊的程序包格式。 软件包类型多种多样-最值得注意的是Debian和Ubuntu上的DEB以及Fedora,Red Hat等上的RPM。 这些软件包实质上是包含文件列表的存档。 程序包管理器将打开存档,并将文件安装到程序包指定的位置。 程序包管理器会知道哪些文件属于哪些程序包–卸载程序包时,程序包管理器会确切知道系统上的哪些文件属于该程序包。 Windows不知道哪些文件属于已安装的应用程序-它允许应用程序安装程序自己管理安装和卸载。

Packages can also contain scripts that run when the package is installed and removed, although these are generally used for system setup and not moving files to arbitrary locations.

软件包还可以包含在安装和删除软件包时运行的脚本,尽管这些脚本通常用于系统设置,而不是将文件移动到任意位置。

image

在Linux上安装软件 (Installing Software on Linux)

To install software on Linux, open your package manager, search for the software, and tell the package manager to install it. Your package manager will do the rest. Linux distributions often offer a variety of frontends to the package manager. For example, on Ubuntu, the Ubuntu Software Center, Update Manager, Synaptic application, and apt-get command all use apt-get and dpkg to download and install DEB packages. You can use any utility you like – they just provide different interfaces. You’ll generally find a simple, graphical package manager in your Linux distribution’s menus.

要在Linux上安装软件,请打开软件包管理器,搜索该软件,然后告诉软件包管理器进行安装。 剩下的工作由您的包裹经理负责。 Linux发行版通常为软件包管理器提供各种前端。 例如,在Ubuntu上,Ubuntu软件中心,Update Manager,Synaptic应用程序和apt-get命令都使用apt-get和dpkg下载和安装DEB软件包。 您可以使用任何喜欢的实用程序-它们仅提供不同的接口。 通常,您可以在Linux发行版的菜单中找到一个简单的图形化软件包管理器。

image

更新延迟 (Update Delays)

One thing new Linux users often notice with package managers and repositories is a delay before new software versions reach their systems. For example, when a new version of Mozilla Firefox is released, Windows and Mac users will acquire it from Mozilla. On Linux, your Linux distribution must package the new version and push it out as an update. If you open Firefox’s preferences window on Linux, you’ll note that Firefox has no ability to automatically update itself (assuming you’re using the version of Firefox from your Linux distribution’s repositories).

新Linux用户在程序包管理器和存储库中经常注意到的一件事是新软件版本到达其系统之前的延迟。 例如,当发布新版本的Mozilla Firefox时,Windows和Mac用户将从Mozilla购买它。 在Linux上,您Linux发行版必须打包新版本并将其作为更新发布。 如果在Linux上打开Firefox的首选项窗口,您会注意到Firefox无法自动更新自身(假设您使用的是Linux发行版存储库中的Firefox版本)。

image

You can also download and install the application yourself – for example, downloading Firefox directly from Mozilla — but this may require compiling and installing the software from source and removes the benefits of package managers, such as automatic, centralized security updates.

您也可以自己下载和安装该应用程序-例如,直接从Mozilla下载Firefox-但这可能需要从源代码编译和安装该软件,并且消除了程序包管理器的好处,例如自动的集中式安全更新。

While new versions of Firefox are a priority because they contain security updates, other applications may not be delivered as quickly. For example, a major new version of the LibreOffice office suite may not ever be released as an update for the current version of your Linux distribution. To avoid potential instability and allow time for testing, this version may not be available until the next major release of your Linux distribution – for example, Ubuntu 12.10 – when it becomes the default version in the distribution’s software repositories.

尽管新版本的Firefox因为其中包含安全更新而被优先考虑,但是其他应用程序可能无法尽快交付。 例如,可能永远不会发布LibreOffice Office套件的主要新版本作为Linux发行版当前版本的更新。 为了避免潜在的不稳定并留出时间进行测试,该版本可能要等到Linux发行版的下一个主要发行版(例如,Ubuntu 12.10)才成为发行版软件存储库中的默认版本,然后才能发布。

To fix this problem, some Linux distributions, such as Arch Linux, offer “rolling release cycles,” where new versions of software are pushed into the main software repositories. This may cause problems – while you may want new versions of desktop applications, you probably don’t care about new versions of low-level system utilities, which could potentially introduce instability.

为了解决此问题,某些Linux发行版(例如Arch Linux)提供了“滚动发布周期”,其中新版本的软件被推送到主要软件存储库中。 这可能会导致问题–尽管您可能需要新版本的桌面应用程序,但您可能并不在乎新版本的低级系统实用程序,这可能会导致不稳定。

Ubuntu offers the backports repository to bring newer versions of significant packages to older distributions, although not all new versions make it into the backports repository.

Ubuntu提供了backports存储库,以将重要软件包的新版本引入较旧的发行版,尽管并非所有新版本都将其引入backports存储库。

其他资料库 (Other Repositories)

While Linux distributions ship with their own repositories pre-configured, you can also add other repositories to your system. Once you have, you can install software repositories from that repository and receive updates from it using your package manager. The repository you add must be designed for your Linux distribution and package manager.

尽管Linux发行版附带了预先配置的自己的存储库,但您也可以将其他存储库添加到系统中。 拥有之后,您可以从该存储库安装软件存储库,并使用程序包管理器接收更新。 您添加的存储库必须是针对Linux发行版和程序包管理器设计的。

For example, Ubuntu offers a wide variety of personal package archives (PPAs), which contain software compiled by individuals and teams. Ubuntu doesn’t vouch for the stability or security of the packages in these repositories, but you can add PPAs from trusted individuals to download packages not yet in Ubuntu’s repository – or download newer versions of existing packages.

例如,Ubuntu提供了各种各样的个人软件包档案(PPA) ,其中包含由个人和团队编译的软件。 Ubuntu不能保证这些存储库中软件包的稳定性或安全性,但是您可以从受信任的个人中添加PPA,以下载尚未在Ubuntu存储库中的软件包-或下载现有软件包的较新版本。

Some third-party applications also use their own software repositories. For example, when you install Google Chrome on Ubuntu, it adds its own apt repository to your system. This ensures you receive updates to Google Chrome through Ubuntu’s Update Manager and standard software installation tools.

一些第三方应用程序还使用其自己的软件存储库。 例如,当您在Ubuntu上安装Google Chrome时,它将自己的apt存储库添加到您的系统中。 这样可以确保您通过Ubuntu的更新管理器和标准软件安装工具收到Google Chrome的更新。

image

翻译自: https://www.howtogeek.com/117579/htg-explains-how-software-installation-package-managers-work-on-linux/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值