"Linux软件安装:四种方法一览" Linux系统安装软件四种方式

"Linux软件安装:四种方法一览",Linux系统安装软件四种方式 。小编来告诉你更多相关信息 。
Linux系统安装软件四种方式一个电脑小知识,为大家介绍Linux系统安装软件四种方式方面的知识,如有不对的地方欢迎指正!
Linux系统安装软件四种方式:

  • 绿色安装
  • yum安装
  • rpm安装
  • 源码安装

"Linux软件安装:四种方法一览" Linux系统安装软件四种方式

文章插图
1. 绿色安装这种方式最简便,一般提供Compressed Archive压缩文档包,如Java软件的压缩文档包,只需要解压、设置环境变量即可直接使用 。
# 下载软件https://www.oracle.com/java/technologies/downloads/# 新建java软件存放路径mkdir /opt/java# 解压tar -xvf jdk-21_linux-x64_bin.tar.gz -C /opt/java# 设置环境变量vim /etc/profile.d/java.shJAVA_HOME=/opt/java/jdk-21.0.1/CLASSPATH=.:$JAVA_HOME/libPATH=JAVA_HOME/bin:$PATHexport JAVA_HOME CLASSPATH PATH# 加载环境变量source /etc/profile.d/java.sh# 检验java环境是否配置好java2. yum安装
  • 前提条件是有网络
  • 需要安装的软件及版本 , yum源里刚好有 。
# 搜索redis源yum search redis# 查看redis详细信息yum info redis# 安装redis软件yum -y install redis# 查看redis状态systemctl status redis# 设置开机自启systemctl enable redis# 启动redis服务systemctl start redis3. rpm安装需要的软件及版本,只提供了rpm包
3.1 rpm常用命令# 安装一个包rpm -ivh 包名# 升级一个包rpm -Uvh 包名# 查询包是否安装rpm -q 包名# 查询安装包详情信息rpm -qi 包名# 列出服务器上的一个文件属于哪个rpm包rpm -qf 文件名# 列出所有安装的rpm包rpm -qa# 卸载包rpm -e 包名[root@centos ~]# rpm --helpUsage: rpm [OPTION...]Query/Verify package selection options:-a, --allquery/verify all packages-f, --filequery/verify package(s) owning file-g, --groupquery/verify package(s) in group-p, --packagequery/verify a package file--pkgidquery/verify package(s) with package identifier--hdridquery/verify package(s) with header identifier--triggeredbyquery the package(s) triggered by the package--whatrequiresquery/verify the package(s) which require a dependency--whatprovidesquery/verify the package(s) which provide a dependency--nomanifestdo not process non-package files as manifestsQuery options (with -q or --query):-c, --configfileslist all configuration files-d, --docfileslist all documentation files-L, --licensefileslist all license files--dumpdump basic file information-l, --listlist files in package--queryformat=QUERYFORMATuse the following query format-s, --statedisplay the states of the listed filesVerify options (with -V or --verify):--nofiledigestdon\'t verify digest of files--nofilesdon\'t verify files in package--nodepsdon\'t verify package dependencies--noscriptdon\'t execute verify script(s)Install/Upgrade/Erase options:--allfilesinstall all files, even configurations which might otherwise be skipped--allmatchesremove all packages which match(normally an error is generated ifspecified multiple packages)--badrelocrelocate files in non-relocatable package-e, --erase=+erase (uninstall) package--excludedocsdo not install documentation--excludepath=skip files with leading component--forceshort hand for --replacepkgs --replacefiles-F, --freshen=+upgrade package(s) if already installed-h, --hashprint hash marks as package installs (good with -v)--ignorearchdon\'t verify package architecture--ignoreosdon\'t verify package operating system--ignoresizedon\'t check disk space before installing-i, --installinstall package(s)--justdbupdate the database, but do not modify the filesystem--nodepsdo not verify package dependencies--nofiledigestdon\'t verify digest of files--nocontextsdon\'t install file security contexts--noorderdo not reorder package installation to satisfy dependencies--noscriptsdo not execute package scriptlet(s)--notriggersdo not execute any scriptlet(s) triggered by this package--nocollectionsdo not perform any collection actions--oldpackageupgrade to an old version of the package (--force on upgrades does thisautomatically)--percentprint percentages as package installs--prefix=relocate the package to , if relocatable--relocate==relocate files from pathto--replacefilesignore file conflicts between packages--replacepkgsreinstall if the package is already present--testdon\'t install, but tell if it would work or not-U, --upgrade=+upgrade package(s)--reinstall=+reinstall package(s)Common options for all rpm modes and executables:-D, --define=\'MACRO EXPR\'define MACRO with value EXPR--undefine=MACROundefine MACRO-E, --eval=\'EXPR\'print macro expansion of EXPR--macros=readinstead of default file(s)--nopluginsdon\'t enable any plugins--nodigestdon\'t verify package digest(s)--nosignaturedon\'t verify package signature(s)--rcfile=readinstead of default file(s)-r, --root=ROOTuse ROOT as top level directory (default: \"/\")--dbpath=DIRECTORYuse database in DIRECTORY--querytagsdisplay known query tags--showrcdisplay final rpmrc and macro configuration--quietprovide less detailed output-v, --verboseprovide more detailed output--versionprint the version of rpm being usedOptions implemented via popt alias/exec:--scriptslist install/erase scriptlets from package(s)--setpermsset permissions of files in a package--setugidsset user/group ownership of files in a package--setcapsset capabilities of files in a package--restorerestore file/directory permissions--conflictslist capabilities this package conflicts with--obsoleteslist other packages removed by installing this package--provideslist capabilities that this package provides--requireslist capabilities required by package(s)--infolist descriptive information from package(s)--changeloglist change logs for this package--xmllist metadata in xml--triggerslist trigger scriptlets from package(s)--lastlist package(s) by install time, most recent first--dupeslist duplicated packages--filesbypkglist all files from each package--fileclasslist file names with classes--filecolorlist file names with colors--fscontextlist file names with security context from file system--fileprovidelist file names with provides--filerequirelist file names with requires--filecapslist file names with POSIX1.e capabilitiesHelp options:-?, --helpShow this help message--usageDisplay brief usage message