Linux distribution family and release version and software installation method

Under the Linux platform, the types of software packages can be divided into two categories: source package and binary package ;
a software must be a binary file to be executed on Linux;
source package: the source code of the program software (generally called Tarball, which will soon The source code of the software is packaged with tar and then compressed; the source code package is the author directly publishes the source program on the Internet, we directly download the source file and compile it into a binary program for use; binary package: such as the .rpm of the Red Hat
distribution package, the .deb package of the Debian distribution;

Binary package installation:

There are two main factions of linux:

RedHat series : Redhat, Centos, Fedora, etc.
The common installation package format is rpm package . The command to install rpm package is "rpm - parameter"
package management tool yum .

Debian series : Debian, Ubuntu, etc.
The common installation package format is deb package . The command to install deb package is "dpkg -parameter"
package management tool apt-get.
The difference between the two is that dpkg bypasses the apt package management database to operate the package. So the software package you have installed with dpkg can be installed again with apt. The system does not know that it has been installed before, and it will overwrite the previous dpkg installation.
1. dpkg is used to install .deb files, but it will not resolve the dependencies of modules, and will not care about the software in the ubuntu software warehouse. It can be used to install local deb files.
2. Apt will solve and install module dependencies, and will consult software warehouses, but will not install local deb files. Apt is a software management tool built on top of dpkg.

The difference between rmp, yum, deb, and apt-get :

rmp package

Rmp  is  a software executable program under LINUX , you just need to install it. This kind of software installation package is usually an RPM package (Redhat Linux Packet Manager, which is Redhat's package manager), and the suffix is .rpm​​.

Rmp is a package manager launched by Red Hat with Redhat Linux, through which software installation can be realized more easily.

Order:

 rpm -ivh rpm包名    	#安装软件,下面是参数说明
 						##-i :install ,安装
    					##-v : --verbose ,显示详细信息
    					##-h:–hash,进度条
    					##–nodeps :安装前不需要检查依赖
 rpm -Uvh rpm包名 		#升级软件
 rpm -e rpm包名          #卸载软件,其中如果在加上选项–nodeps ,表示卸载软件时,不检查依赖。这样会使那些使用软件包的软件在此之后可能会不能正常工作
 rpm -qpi rpm包名        #查询软件包的详细信息:执行
 						###由于软件包比较多,一般会采取过滤。类如: rpm -qa | grep rpm软件包 
 rpm -qf rpm包名         #查询某个文件是属于那个rpm包的
 rpm -qpl rpm包名        #查该软件包会向系统里面写入哪些文件 

deb package

deb is an installation package under the Unix system (in fact, mainly Linux), based on the tar package, so it will record the file permissions (read/write/executable) and owner/user group. Since Unix systems have strict requirements on permissions, owners, and groups, and deb format installation packages often involve lower-level operations of the system, the settings of permissions are particularly important .

The deb package itself consists of three parts: the data package , which contains the actual installed program data, and the file name is data.tar.XXX; the installation information and control script package , which contains deb installation instructions, logos, scripts, etc., and the file name is control.tar .gz; the last one is  some binary data of the deb file , including the file header and other information, which is generally invisible, but can be seen when opened in some software.

deb itself can use different compression methods. The tar format is not a compression format, but directly collects scattered files and directories, and records data information such as their permissions. The data.tar.XXX mentioned before, where XXX is the compressed suffix. The default compression format used by deb is gzip format, so the most common one is data.tar.gz. Common compression formats include bzip2 and lzma, among which lzma has the highest compression rate, but the CPU resources and time required for compression are relatively long.

data.tar.gz contains the actual installed program data, and during the installation process, the data in the package will be directly decompressed to the root directory (ie / ), so you need to set the corresponding file/ directory tree .

The control.tar.gz contains   the control information needed for a deb installation. Generally, there are 5 files: control, which is used to record data such as software identification, version number, platform, and dependency information; preinst, the script to run before unpacking data.tar.gz; postinst, the script to run after unpacking the data; prerm, the script to run before deleting the file when uninstalling; postrm, the script to run after deleting the file; in the Cydia system, Saurik, the author of Cydia, added another script, extrast_, which is similar to postinst.

Order:

sudo dpkg -i xxx.deb     # 安装软件包xxx.deb
sudo dpkg -R xxx         # 安装目录xxx下所有的软件包
sudo dpkg -r xxx.deb     # 卸载软件包xxx.deb,但是保留软件配置信息。有些软件会有个人设置的一些配置
sudo dpkg -P xxx.deb     # 卸载软件包xxx.deb,且删除软件配置信息。
sudo dpkg -I xxx         # 搜索软件包
sudo dpkg -l             # 列出所有已安装的deb包,同时显示版本号以及简短说明
sudo dkpg -p xxx         # 查看包的具体信息
sudo dkpg -L xxx         # 查看一个软件包安装到系统里面的文件目录信息。很多人抱怨用了Ubuntu或者Debian以后,不知道自己的软件给安装到什么地方了,其实就可以用这个命令来查找

yum


YUM (full name Yellow dog Updater, Modified) is a Shell front-end package manager in Fedora, RedHat and CentOS .
Based on RPM package management, it can automatically download and install RPM packages from a specified server , automatically handle dependencies , and install all dependent software packages at one time without tedious
downloading and installation again and again.

Order

[root@localhost opt]# yum --help
已加载插件:fastestmirror, langpacks
Usage: yum [options] COMMAND

List of Commands:

check          检查 RPM 数据库问题
check-update   检查是否有可用的软件包更新
clean          删除缓存数据
deplist        列出软件包的依赖关系
distribution-synchronization 已同步软件包到最新可用版本
downgrade      降级软件包
erase          从系统中移除一个或多个软件包
fs             Acts on the filesystem data of the host, mainly for removing docs/lanuages for minimal hosts.
fssnapshot     Creates filesystem snapshots, or lists/deletes current snapshots.
groups         显示或使用、组信息
help           显示用法提示
history        显示或使用事务历史
info           显示关于软件包或组的详细信息
install        向系统中安装一个或多个软件包
langavailable  Check available languages
langinfo       List languages information
langinstall    Install appropriate language packs for a language
langlist       List installed languages
langremove     Remove installed language packs for a language
list           列出一个或一组软件包
load-transaction 从文件名中加载一个已存事务
makecache      创建元数据缓存
provides       查找提供指定内容的软件包
reinstall      覆盖安装软件包
repo-pkgs      将一个源当作一个软件包组,这样我们就可以一次性安装/移除全部软件包。
repolist       显示已配置的源
search         在软件包详细信息中搜索指定字符串
shell          运行交互式的 yum shell
swap           Simple way to swap packages, instead of using shell
update         更新系统中的一个或多个软件包
update-minimal Works like upgrade, but goes to the 'newest' package match which fixes a problem that affects your system
updateinfo     Acts on repository update information
upgrade        更新软件包同时考虑软件包取代关系
version        显示机器和/或可用的源版本。


Options:
  -h, --help            显示此帮助消息并退出
  -t, --tolerant        忽略错误
  -C, --cacheonly       完全从系统缓存运行,不升级缓存
  -c [config file], --config=[config file]
                        配置文件路径
  -R [minutes], --randomwait=[minutes]
                        命令最长等待时间
  -d [debug level], --debuglevel=[debug level]
                        调试输出级别
  --showduplicates      在 list/search 命令下,显示源里重复的条目
  -e [error level], --errorlevel=[error level]
                        错误输出级别
  --rpmverbosity=[debug level name]
                        RPM 调试输出级别
  -q, --quiet           静默执行
  -v, --verbose         详尽的操作过程
  -y, --assumeyes       回答全部问题为是
  --assumeno            回答全部问题为否
  --version             显示 Yum 版本然后退出
  --installroot=[path]  设置安装根目录
  --enablerepo=[repo]   启用一个或多个软件源(支持通配符)
  --disablerepo=[repo]  禁用一个或多个软件源(支持通配符)
  -x [package], --exclude=[package]
                        采用全名或通配符排除软件包
  --disableexcludes=[repo]
                        禁止从主配置,从源或者从任何位置排除
  --disableincludes=[repo]
                        disable includepkgs for a repo or for everything
  --obsoletes           更新时处理软件包取代关系
  --noplugins           禁用 Yum 插件
  --nogpgcheck          禁用 GPG 签名检查
  --disableplugin=[plugin]
                        禁用指定名称的插件
  --enableplugin=[plugin]
                        启用指定名称的插件
  --skip-broken         忽略存在依赖关系问题的软件包
  --color=COLOR         配置是否使用颜色
  --releasever=RELEASEVER
                        在 yum 配置和 repo 文件里设置 $releasever 的值
  --downloadonly        仅下载而不更新
  --downloaddir=DLDIR   指定一个其他文件夹用于保存软件包
  --setopt=SETOPTS      设置任意配置和源选项
  --bugfix              Include bugfix relevant packages, in updates
  --security            Include security relevant packages, in updates
  --advisory=ADVS, --advisories=ADVS
                        Include packages needed to fix the given advisory, in
                        updates
  --bzs=BZS             Include packages needed to fix the given BZ, in
                        updates
  --cves=CVES           Include packages needed to fix the given CVE, in
                        updates
  --sec-severity=SEVS, --secseverity=SEVS
                        Include security relevant packages matching the
                        severity, in updates

Common commands

install:安装rpm软件包
update:更新rpm软件包
check-update :检查是否有可用的更新rpm软件包
remove :删除指定的rpm软件包
list :显示软件包信息
clean :清理yum过期的缓存
deplist:显示yum软件包的所有依赖关系

Modify the network yum source

The default system YUM source needs to be connected to foreign apache websites, and the network speed is relatively slow. You can modify the associated network
YUM source to a domestic mirror website, such as Netease 163, aliyun, etc.

1. Install wget first, wget is used to download files from the specified URL

[root@hadoop101 ~] yum install wget

2. In the /etc/yum.repos.d/ directory, back up the default repos file.

[root@hadoop101 yum.repos.d] pwd
/etc/yum.repos.d
[root@hadoop101 yum.repos.d] cp CentOS-Base.repo CentOS-Base
.repo.backup

3. Download the repos file of NetEase 163 or Aliyun, choose one

[root@hadoop101 yum.repos.d] wget http://mirrors.aliyun.com/repo/Centos-7.repo //阿里云
[root@hadoop101 yum.repos.d] wget http://mirrors.163.com/.help/CentOS7-Base-163.repo //网易 163

4. Use the downloaded repos file to replace the default repos file

For example: replace CentOS-Base.repo with CentOS7-Base-163.repo

[root@hadoop101 yum.repos.d]# mv CentOS7-Base-163.repo CentOS-Base.repo

5. Clean up old cache data and cache new data

[root@hadoop101 yum.repos.d]#yum clean all
[root@hadoop101 yum.repos.d]#yum makecache
yum makecache 就是把服务器的包信息下载到本地电脑缓存起来

6. Test verification

[root@hadoop101 yum.repos.d]# yum list | grep firefox
[root@hadoop101 ~]#yum 

apt

apt is a Linux package management tool.
apt is a command line utility for installing, updating, removing and managing deb packages on Ubuntu, Debian and related Linux distributions.
apt is designed for interactive use. It is better to use apt-get and apt-cache in shell scripts because they are backward compatible between different versions and have more options and features.
Most apt commands must be run as a user with sudo privileges.

apt update
#从软件源服务器获取最新的软件信息并缓存到本地。
#因为很多apt的其他命令都是要通过比对版本信息来进行操作的,如果每次都去对比线上的版本信息效率肯定不理想,也没必要,所以做了一个缓存的机制。

apt upgrade
# 从本地仓库中对比系统中所有已安装的软件,如果有新版本的话则进行升级

apt list
#列出本地仓库中所有的软件包名

apt list [package]
#从本地仓库中查找指定的包名,支持通配符,比如"apt list zlib*“就能列出以zlib开头的所有包名

apt list --installed
#列出系统中所有已安装的包名

apt search [key]
#与list类似,通过给出的关键字进行搜索,列出所有的包和其描述

apt show [package]
#列出指定包的详细情况,包名要填写完整。

apt install [package]
#安装指定的包,并同时安装其依赖的其他包。

apt remove [package]
#卸载包,但不删除相关配置文件。包名支持通配符

apt autoremove
#卸载因安装软件自动安装的依赖,而现在又不需要的依赖包

apt purge [package]
#卸载包,同时删除相关配置文件。包名支持通配符

apt clean
#删除所有已下载的软件包

apt autoclean
#类似clean,但删除的是过期的包(即已不能下载或者是无用的包)

Precautions:

  • The difference between apt and apt-get

The introduction of the apt command is to solve the problem that the commands are too scattered. It includes the most widely used function options since the appearance of the apt-get command, as well as the rarely used functions in the apt-cache and apt-config commands.
When using the apt command, users no longer have to go from apt-get to apt-cache or apt-config, and apt is more structured and provides users with the necessary options to manage packages.

  • /etc/apt/sources.list

- is a configuration file used by the package management tool apt to record the location of the package repository.

Source package installation

General steps for source code installation:

1、下载源码包并解压到指定目录;           //一般将源码包解压至目录/user/local/src下
 
2、预编译(配置)./configure;            //设置安装目录,安装模块等选项
 
3、编译 make;                         //生成可执行二进制文件
 
4、安装make install;                  //复制二进制文件到系统,配置应用环境
 
Configure是一个可执行脚本,它有很多选项,在待安装的源码路径下使用命令./configure–help输出详细的选项列表; 配置这一步骤:把系统环境的检测结果和定义好的功能选项写入Makefile文件中,为了后续的编译和安装做铺垫
 
其中./configure --prefix==安装路径,来指定安装路径,一般情况下默认的安装路径为/usr/local--prefix选项是配置安装的路径,如果不配置该选项,安装后可执行文件默认放在/usr/local/bin,库文件默认放在/usr/local/lib,配置文件默认放在/usr/local/etc,其它的资源文件放在/usr/local/share,比较凌乱;
 
如果配置--prefix,如:./configure --prefix=/usr/local/test
 
可以把所有资源文件放在/usr/local/test的路径中,不会杂乱;
 
用了—prefix选项的另一个好处是卸载软件或移植软件。当某个安装的软件不再需要时,只须简单的删除该安装目录,就可以把软件卸载得干干净净;移植软件只需拷贝整个目录到另外一个机器即可(相同的操作系统);
 
make会调用gcc编译器,读取makefile文件中的信息进行系统软件编译。将源码程序转化为可以被linux系统所识别的可执行文件
 
如果在./configure或者make编译中报错,那么我们在重新执行前一定要执行make clean命令,系统清空Makefile文件或编译产生的.o开头的文件;
 
make install是用来安装的,它从Makefile中读取指令,安装到指定的位置。只有在执行install的时候才会向指定的安装目录写入文件。
 
当然要卸载程序,也可以在原来的make目录下用一次make uninstall,但前提是make文件指定过uninstall;

Guess you like

Origin blog.csdn.net/juanxiaseng0838/article/details/130643771