app开发者平台在数字化时代的重要性与发展趋势解析
532
2022-09-21
UNIX/Linux 系统管理技术手册阅读(九)
2016.8.31 10:00-10:30
1.12 WAYS TO FIND AND INSTALL SOFTWARE
Chapter 12, Software Installation and Management, addresses software provisioning in detail. But for the impatient, here’s a quick primer on how to find out what’s installed on your system and how to obtain and install new software.
1.12 查找和安装软件的途径
第12章详细讲述了软件方面的知识。但是对于没有耐性的读者来说,这一节是个初级速成教材,教给读者怎样知道自己系统上已经安装好的软件有哪些,以及怎样获得和安装新软件。
Modern operating systems divide their contents into packages that can be installed independently of one another. The default installation includes a range of starter packages that you can expand according to your needs.
现代操作系统把自己分成多个软件包,软件包可以逐个独立安装。默认安装的只包括一定范围的起步软件包,用户可以根据需要再扩充。
Add-on software is often provided in the form of precompiled packages as well, although the degree to which this is a mainstream approach varies widely among systems. Most software is developed by independent groups that release the software in the form of source code. Package repositories then pick up the source code, compile it appropriately for the conventions in use on the systems they serve, and package the resulting binaries. It’s usually easier to install a systemspecific binary package than to fetch and compile the original source code. However, packagers are sometimes a release or two behind the current version.
附加软件常常也以预先编译好的软件包形式提供,这是一种主流的方式,各个系统间的区别仅仅在于程序不同。大多数软件都是由独立的小组开发,且以源代码的形式发布出来。接下来,软件库收集这些源代码,然后根据软件库为之服务的系统上的使用习惯,对其进行编译,再把编译结果打成软件包。安装针对特定系统的二进制软件包通常要比取得并编译原来的源代码更容易。不过,打包软件有时候要比当前版本落后一两个版本号。
The fact that two systems use the same package format doesn’t necessarily mean that packages for the two systems are interchangeable. Red Hat and SUSE both use RPM, for example, but their filesystem layouts are somewhat different. It’s best to use packages designed for your particular system if they are available.
两种系统使用相同的软件打包系统不一定意味着两个系统的软件包能互换使用。例如,Red Hat和SUSE都使用RPM,但是它们的文件系统布局却稍有不同。如果能找到专为自己系统做的软件包,那就用它们,这是最好的做法。
Major Linux distributions provide excellent package management systems that include tools for accessing and searching Internet software repositories. Distributors aggressively maintain these repositories on behalf of the community, so there is rarely a need for Linux administrators to step outside the bounds of their systems’ default package manager. Life is good.
主流的Linux发行版本都提供优异的软件包管理体系,里面包括能够访问和搜索Internet上软件库的工具。发行商替社区积极维护这些软件库,所以Linux系统管理员很少需要跳出自己系统上的默认软件包管理器。生活真美好。
UNIX systems show more ambivalence about package management. Solaris, HPUX, and AIX all provide packaging software that works at the level of individual machines. However, the vendors of these systems don’t maintain repositories of open source software, so the user communities are mostly left to fend for themselves.9 Unfortunately, one of the main pieces of glue that holds a packaging universe together is a way for packages to reliably refer to other packages in order to express dependency or compatibility information. Without some central coordination, the whole ecosystem can quickly fall apart.
UNIX系统在软件包管理方面显得畏手畏尾。Solaris、HP-UX和AIX都提供打包软件,在单机的层次上使用没问题。但是,这些系统的厂商却没有维护开源软件库,而让用户群大多进行自我维护。遗憾的是,维系一个打包软件环境所依赖的纽带之一,是有一条途径可以让软件包可靠地检索其他软件包,从而掌握依赖性和兼容性方面的信息。没有某种中心作为协调,整个体系就会很快分崩离析。
2016.9.21 14:00-14:30
In the real world, results have varied. Solaris has an add-on system (pkgutil from blastwave.org) that provides for easy software installation from an Internet repository, much like the native systems found on Linux distributions. HP-UX has a nice Internet repository in the form of the HP-UX Porting and Archiving Centre at hpux.connect.org.uk, but packages must be manually and individually downloaded. At the more dismal end of the spectrum, the availability of prepackaged software for AIX is somewhat scattershot.
在现实世界里,情形各不相同。Solaris有一套附加系统(blastwave.org的pkgutil),可以方便地从Internet软件库安装软件,这和Linux发行版本上自带的系统很像。HP-UX有一个不错的Internet软件库,它采用了HP-UX移值和存档中心的形式,地址为hpux.connect.org.uk,但是必须手工逐个-软件包。在这个领域内做得较差的典型,就是AIX,给它预先打包好的软件找起来很分散。
Administrators without access to prepackaged binaries must install software the old-fashioned way: by downloading a tar archive of the source code and manually configuring, compiling, and installing it. Depending on the software and the operating system, this process can range from trivial to nightmarish.
系统管理员没找到打好包的二进制软件,就必须采用老办法安装软件:-一个tar源代码包,手工配置、编译和安装它。这个过程可长可短,取决于具体软件和操作系统。
In this book, we generally assume that optional software is already installed rather than torturing you with boilerplate instructions for installing every package. If there’s a potential for confusion, we sometimes mention the exact names of the packages needed to complete a particular project. For the most part, however, we don’t repeat installation instructions since they tend to be similar from one package to the next.
在本书里,我们一般认为可选软件都已经装好了,并不折磨读者按生搬硬套的步骤去安装每个软件包。如果有可能发生混淆,我们有时候也会给出完成某个特定项目所需软件包的确切名称。但是,对于大部分内容来说,我们都不会重复讲述安装步骤,因为前后软件包的安装都很类似。
1.12.1 Determining whether software has already been installed
For a variety of reasons, it can be a bit tricky to determine which software package contains the component you actually need. Rather than starting at the package level, it’s easier to use the shell’s which command to find out if a relevant binary is already in your search path. For example, the following command reveals that the GNU C compiler has already been installed on this machine:
aix$ which gcc
/opt/pware/bin/gcc
1.12.1 判断软件是否已经安装
出于各种原因,要判断实际需要的东西在哪个软件包里,需要有点儿小技巧。除了在软件包的级别上查找之外,更简单的做法是使用shell的which命令找出相关的二进制程序是否已经在搜索路径中。例如,下面的命令就提示出已经在机器上安装了GNU的C编辑器。
aix$ which gcc
/opt/pware/bin/gcc
If which can’t find the command you’re looking for, try whereis; it searches a broader range of system directories and is independent of your shell’s search path.
如果which没有找到要找的命令,那么试试whereis;该命令搜索更大范围的系统目录,与shell的搜索路径无关。
Another alternative is the incredibly useful locate command, which consults a precompiled index of the filesystem to locate filenames that match a particular pattern. locate is part of the GNU findutils package, which is included by default on most Linux systems but must be installed by hand on UNIX.
另一种方法是采取作用非凡的locate命令,它参照预先编译好的一个文件系统索引,以此确定与特定模式相匹配的文件名。locate命令是GNU的findutils软件包里一个程序,这个软件包在大多数Linuxtxyh都是默认包含的,但在UNIX系统上必须手动安装。
locate is not specific to commands or packages but can find any type of file. For example, if you weren’t sure where to find the signal.h include file, you could try
ubuntu$ locate signal.h
/usr/include/signal.h
/usr/include/asm/signal.h
/usr/include/asm-generic/signal.h
/usr/include/linux/signal.h
…
locate的搜索并不针对命令或软件包,而是能够找到任何类型的文件。例如,如果读者不能确定在哪儿能找到头文件signal.h,可以试试:
ubuntu$ locate signal.h
/usr/include/signal.h
/usr/include/asm/signal.h
/usr/include/asm-generic/signal.h
/usr/include/linux/signal.h
…
locate’s database is updated periodically by the updatedb command, which runs out of cron. Therefore, the results of a locate don’t always reflect recent changes to the filesystem.
locate的数据库通常由updated命令定期更新,这条命令由cron来运行。因此,执行一次locate的结果不是总能够反映出文件系统新近的变化。
If you know the name of the package you’re looking for, you can also use your system’s packaging utilities to check directly for the package’s presence. For example, on a Red Hat or SUSE system, the following command checks for the presence (and installed version) of the Python scripting language:
redhat$ rpm -q python
python-2.4.3-21.el5
如果用户知道正在查找的软件包的名字。那么也可以使用系统上的软件包工具来直接检查是否有该软件包出现(以及已装软件的版本)。例如,在Red Hat或者SUSE系统上,下面的命令可以检查是否有Python脚本语言:
redhat$ rpm -q python
python-2.4.3-21.el5
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~