测试员必备:Linux下安装JDK 1.8你必须知道的那些事
connygpt 2024-10-04 15:44 7 浏览
1.简介
在Oracle收购Sun后,Java的一系列产品就被整合到Oracle官网中,打开官网乍眼一看也不知道去哪里下载,还得一个一个的摸索尝试,而且网上大多数都是一些Oracle收购Sun前,或者就是一些老的资料文章,为了避免这些坑,宏哥才决定写着一篇文章。
JDK是 JAVA 的软件开发工具包,如果要使用JAVA来进行开发,或者部署基于其开发的应用,那么就需要安装JDK。本次将在Linux下安装JDK及配置环境。在以前宏哥也在Linux下安装过JDK,安装过程溜得飞起来。结果这次安装过程中却是十分的不顺,所以才有了这篇文章用来记录和分享安装 过程中遇到的问题和心得体会,希望对各位有所帮忙,避免做更多的无用功。
宏哥的环境:
查看Linux环境输入命令:lsb_release -a
[admin@oftpclient201 ~]$ lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.9.2009 (Core)
Release: 7.9.2009
2.下载JDK
在安装之前,检查是否存在Linux下自带的OpenJDK,命令:rpm -qa | grep java。若存在,则需要进行卸载,命令:rpm -e --nodeps 卸载的软件名。
其他方法:
java -version
echo $PATH 看环境变量bai是否配du置了java路径
find / -name java 查找zhijava文件
JDK历史版本链接:https://www.oracle.com/technetwork/java/javase/archive-139210.html
接着,我们可以通过 wget 命令下载JDK安装包,或者下载后传到Linux。我这里下载的安装包版本是 jdk-8u281-linux-x64.tar.gz 。
2.1使用wget下载JDK8
每次去官网下载JDK有点烦 但是直接使用wget 又得同意协议所以 使用如下的wget就好了(注意是64位的哦)
1.先去官网看一下地址变化 没有如下 :修改后面的下载地址即可 注意哦~现在和以前变化挺大的,所以宏哥在这里赘述一下具体步骤:
(1)在浏览器的地址栏输入JDK官网,如下图所示:
(2)鼠标放在product上在下拉菜单中点击Java,如下图所示:
(3)然后再点击“Download Java”,如下图所示:
(4)下滑页面找到Java SE8,然后点击“JDK Download”,如下图所示:
(5)找到Linux系统的64位的JDK,选中安装包右键,点击“复制链接地址”,如下图所示:
(6)在xshell上输入命令wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie"后面加上你刚才复制的下载链接
2.然后使用下面的wget下载就好了~(注意文件的后缀,有时候不可以直接解压需要重命名后缀名哦)
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz
3.解压安装包
创建一个文件夹,用于存放JDK安装包,然后解压到该目录下。
创建文件夹:mkdir /usr/JDK
进入文件夹:cd /usr/JDK
将下载好的压缩文件剪贴到创建好的文件夹下:mv jdk-8u281-linux-x64.tar.gz /usr/JDK/
解压:tar -zxvf jdk-8u281-linux-x64.tar.gz
可以看到,本次解压到了当前目录 /usr/JDK/jdk1.8.0_281下。
4.配置环境
解压完成之后,我们要配置下环境变量,通过 vim 命令修改配置文件 /etc/profile 来设置环境变量。
vim /etc/profile
在文件最后一行,输入 i 进入编辑模式,添加以下内容,然后按 Esc 退出编辑模式,再输入 :wq 保存并退出。
export JAVA_HOME=/usr/JDK/jdk1.8.0_281
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
设置完之后,如果要使环境变量立即生效,需要通过命令:source /etc/profile,重新加载配置文件。
5.验证是否安装成功
所有都配置好了,我们需要验证下是否安装成功。
依次输入 java -version、java、javac,不会出现报错并且显示出 jdk版本号及 java/javac相关命令参数说明界面。
[admin@oftpclient201 ~]$ java -version
java version "1.8.0_281"
Java(TM) SE Runtime Environment (build 1.8.0_281-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode)
[admin@oftpclient201 ~]$ java
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-server to select the "server" VM
The default VM is server.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose:[class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
Warning: this feature is deprecated and will be removed
in a future release.
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
Warning: this feature is deprecated and will be removed
in a future release.
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
[admin@oftpclient201 ~]$ javac
Usage: javac <options> <source files>where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are used
-classpath <path> Specify where to find user class files and annotation processors
-cp <path> Specify where to find user class files and annotation processors
-sourcepath <path> Specify where to find input source files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <dirs> Override location of installed extensions
-endorseddirs <dirs> Override location of endorsed standards path
-proc:{none,only} Control whether annotation processing and/or compilation is done.
-processor <class1>[,<class2>,<class3>...] Names of the annotation processors to run; bypasses default discovery process
-processorpath <path> Specify where to find annotation processors
-parameters Generate metadata for reflection on method parameters
-d <directory> Specify where to place generated class files
-s <directory> Specify where to place generated source files
-h <directory> Specify where to place generated native header files
-implicit:{none,class} Specify whether or not to generate class files for implicitly referenced files
-encoding <encoding> Specify character encoding used by source files
-source <release> Provide source compatibility with specified release
-target <release> Generate class files for specific VM version
-profile <profile> Check that API used is available in the specified profile
-version Version information
-help Print a synopsis of standard options
-Akey[=value] Options to pass to annotation processors
-X Print a synopsis of nonstandard options
-J<flag> Pass <flag> directly to the runtime system
-Werror Terminate compilation if warnings occur
@<filename> Read options and filenames from file
[admin@oftpclient201 ~]$
6.小结
安装过程中宏哥为了避免麻烦不是在Windows上直接安装好然后再上传到Linux上,而是直接用weget命令直接安装的,结果遇到如下一系列的问题:
(1)wget+复制好的下载地址
[admin@oftpclient201 ~]$ wget https://download.oracle.com/otn/java/jdk/8u281-b09/89d678f2be164786b292527658ca1605/jdk-8u281-linux-x64.tar.gz--2021-02-25 15:25:47-- https://download.oracle.com/otn/java/jdk/8u281-b09/89d678f2be164786b292527658ca1605/jdk-8u281-linux-x64.tar.gzResolving download.oracle.com (download.oracle.com)... 184.50.93.194Connecting to download.oracle.com (download.oracle.com)|184.50.93.194|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/akam/otn/java/jdk/8u281-b09/89d678f2be164786b292527658ca1605/jdk-8u281-linux-x64.tar.gz [following]
--2021-02-25 15:25:48-- https://edelivery.oracle.com/akam/otn/java/jdk/8u281-b09/89d678f2be164786b292527658ca1605/jdk-8u281-linux-x64.tar.gz
Resolving edelivery.oracle.com (edelivery.oracle.com)... 184.30.17.110, 2600:1400:c000:482::366, 2600:1400:c000:488::366
Connecting to edelivery.oracle.com (edelivery.oracle.com)|184.30.17.110|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://login.oracle.com:443/oam/server/obrareq.cgi?encquery%3D4PIlzUXFrmsJOQa3pTVPbD8FleZqJX%2Bqm5A%2BmXnkil9RBAqGW%2Bd5Z3FgcL03OH1P%2FL%2FPpBosJhXNi%2BaNvJ5gWRCWlkmsTghONwL1Ixk8tJ66nMfQItxzYLYEA6Ae%2F4xxJtk3wvyzw4EzT%2B88B%2BHNgKJs6w67VGaR6kHqcVem1SIW%2Fxxps6xSH%2Bqe9li%2BI0FMXUw2Dptss7A0VEtYvTTpUHnLteqH9Wt2TJiK%2F8%2BVmtRUTs5Y2YaOxZqrr6VcBsyAi83RSY1PKFiJChmpxiao1%2Bomcz9PKzc04xMlEg2hVJFAoTxUkyPKCWWEmipcbGPfcQOJYVrfjGqqmAGIDBfUfmpAGcQf21ceJqkm739Jf%2Bue68iM7YPcI7WOdFjxWLG9Ykj2NVjTwjmCDzZUsBFzMiT8SeXRqH7dTevRYZuzg0b%2F8PZNqeTjzZ5LHzG6WA1%2FlWsXpwgBuB3OklWgZs5HBg25Mx5Uqdu%2BHzc6qzaGNlWKrQj5pWUvGpz1rVPB23SywqnzFy9iUm4I%2FlXYeJDzJQ%3D%3D%20agentid%3Dedelivery-extprod%20ver%3D1%20crmethod%3D2&ECID-Context=1.005j2GF_XvzFo2KimTctkJ00023d00wI1l%3BkXjE [following]
--2021-02-25 15:25:50-- https://login.oracle.com/oam/server/obrareq.cgi?encquery%3D4PIlzUXFrmsJOQa3pTVPbD8FleZqJX%2Bqm5A%2BmXnkil9RBAqGW%2Bd5Z3FgcL03OH1P%2FL%2FPpBosJhXNi%2BaNvJ5gWRCWlkmsTghONwL1Ixk8tJ66nMfQItxzYLYEA6Ae%2F4xxJtk3wvyzw4EzT%2B88B%2BHNgKJs6w67VGaR6kHqcVem1SIW%2Fxxps6xSH%2Bqe9li%2BI0FMXUw2Dptss7A0VEtYvTTpUHnLteqH9Wt2TJiK%2F8%2BVmtRUTs5Y2YaOxZqrr6VcBsyAi83RSY1PKFiJChmpxiao1%2Bomcz9PKzc04xMlEg2hVJFAoTxUkyPKCWWEmipcbGPfcQOJYVrfjGqqmAGIDBfUfmpAGcQf21ceJqkm739Jf%2Bue68iM7YPcI7WOdFjxWLG9Ykj2NVjTwjmCDzZUsBFzMiT8SeXRqH7dTevRYZuzg0b%2F8PZNqeTjzZ5LHzG6WA1%2FlWsXpwgBuB3OklWgZs5HBg25Mx5Uqdu%2BHzc6qzaGNlWKrQj5pWUvGpz1rVPB23SywqnzFy9iUm4I%2FlXYeJDzJQ%3D%3D%20agentid%3Dedelivery-extprod%20ver%3D1%20crmethod%3D2&ECID-Context=1.005j2GF_XvzFo2KimTctkJ00023d00wI1l%3BkXjE
Resolving login.oracle.com (login.oracle.com)... 209.17.4.8
Connecting to login.oracle.com (login.oracle.com)|209.17.4.8|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4103 (4.0K) [text/html]
Saving to: ‘jdk-8u281-linux-x64.tar.gz.1’
100%[==============================================================================================================================================================================>] 4,103 17.6KB/s in 0.2s
2021-02-25 15:25:51 (17.6 KB/s) - ‘jdk-8u281-linux-x64.tar.gz.1’ saved [4103/4103]
[admin@oftpclient201 ~]$
从上图看着好像是下载成功了,但是宏哥在解压的时候有报错了,报错如下:
[admin@oftpclient201 ~]$ tar -zxvf jdk-8u281-linux-x64.tar.gz
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
[admin@oftpclient201 ~]$
从上图的报错可以发现说是压缩包不完整,宏哥好奇既然下载成功怎么会是不完整的了,于是宏哥看了一下压缩包的大小,如下所示才4.1K,
[admin@oftpclient201 ~]$ ll -lh
total 16K-rw-rw-r--. 1 admin admin 0 Feb 25 15:25 ]-rw-rw-r--. 1 admin admin 4.1K Feb 25 15:24 jdk-8u281-linux-x64.tar.gz-rw-rw-r--. 1 admin admin 39 Feb 2 16:20 test.txt-rw-rw-r--. 1 admin admin 78 Feb 2 16:21 t.zip
[admin@oftpclient201 ~]$
这个与Oracle官网显示的大小100多M差太多了,所以确定是下载不成功而且回过头来看一下下载时间几乎零点几秒就下载完成了,更加确定下载的压缩包是不完整的。
查了资料说是由于Oracle需要accept license、cookie,所以需要给wget带如下参数即可,于是就有了第二种方法的尝试
(2)wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie"+复制好的下载地址
[admin@oftpclient201 ~]$ wget --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie;" https://download.oracle.com/otn/java/jdk/8u281-b09/89d678f2be164786b292527658ca1605/jdk-8u281-linux-x64.tar.gz
--2021-02-25 15:56:55-- https://download.oracle.com/otn/java/jdk/8u281-b09/89d678f2be164786b292527658ca1605/jdk-8u281-linux-x64.tar.gz
Resolving download.oracle.com (download.oracle.com)... 92.123.228.99
Connecting to download.oracle.com (download.oracle.com)|92.123.228.99|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/akam/otn/java/jdk/8u281-b09/89d678f2be164786b292527658ca1605/jdk-8u281-linux-x64.tar.gz [following]
--2021-02-25 15:56:56-- https://edelivery.oracle.com/akam/otn/java/jdk/8u281-b09/89d678f2be164786b292527658ca1605/jdk-8u281-linux-x64.tar.gz
Resolving edelivery.oracle.com (edelivery.oracle.com)... 23.76.64.181, 2a02:26f0:a00:3be::366, 2a02:26f0:a00:385::366
Connecting to edelivery.oracle.com (edelivery.oracle.com)|23.76.64.181|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://login.oracle.com:443/oam/server/obrareq.cgi?encquery%3DSyDVndLEpx6WpSyvf2If6hV7vdEN%2BIvCiOpWhz5xUgWJKCBA4mYVvksWHq4vohW6kyMvXAjWfJyda2XrAkGPdxyVK9FcqsRYhvs1DZDEbVLAtEnG5a2Zw2R07iGjm1v79FPjjXyDKSR%2B52%2F0qdEhmP6pPdLPEjhEHVNXr1usKyMmhI0FeYrjn7YcQLjvVOGbZsVR6%2Bu0hqU8jZPxDtXpo8zANJoPdEGxwOiThOVkCWm2cvpOC3Y0QBICZ1yvcWtvTOSHUwZMZgeEp2EdCqlHwH0nm0JWFAKHf6qL9RI1Qs0ZRNth%2FkzjYDLrlY%2B9D1%2BESsQHCAUa2kRHwKXf89u%2BbIUMT2o0xqFtzvJLgQjlG9pUZ7JIxHYVZXzRc1lQwiJove8sjHWNOaujjaryNEGMH5WfiqCp8Y6ogcgd%2B4qNoBLOz7oCOsZkYrzAyfq7481ei7PPvESoBRw6ezsmB06LZt1YHnpf%2BGwf2q33TckhLOVb8C6Bs3bwkmhBfwhDNMnGd%2BonHh%2Fg7kcNscjuTkbwFw%3D%3D%20agentid%3Dedelivery-extprod%20ver%3D1%20crmethod%3D2&ECID-Context=1.005j2HyusRcFo2KimTXvWJ0002ZZ00IcIc%3BkXjE [following]
--2021-02-25 15:56:57-- https://login.oracle.com/oam/server/obrareq.cgi?encquery%3DSyDVndLEpx6WpSyvf2If6hV7vdEN%2BIvCiOpWhz5xUgWJKCBA4mYVvksWHq4vohW6kyMvXAjWfJyda2XrAkGPdxyVK9FcqsRYhvs1DZDEbVLAtEnG5a2Zw2R07iGjm1v79FPjjXyDKSR%2B52%2F0qdEhmP6pPdLPEjhEHVNXr1usKyMmhI0FeYrjn7YcQLjvVOGbZsVR6%2Bu0hqU8jZPxDtXpo8zANJoPdEGxwOiThOVkCWm2cvpOC3Y0QBICZ1yvcWtvTOSHUwZMZgeEp2EdCqlHwH0nm0JWFAKHf6qL9RI1Qs0ZRNth%2FkzjYDLrlY%2B9D1%2BESsQHCAUa2kRHwKXf89u%2BbIUMT2o0xqFtzvJLgQjlG9pUZ7JIxHYVZXzRc1lQwiJove8sjHWNOaujjaryNEGMH5WfiqCp8Y6ogcgd%2B4qNoBLOz7oCOsZkYrzAyfq7481ei7PPvESoBRw6ezsmB06LZt1YHnpf%2BGwf2q33TckhLOVb8C6Bs3bwkmhBfwhDNMnGd%2BonHh%2Fg7kcNscjuTkbwFw%3D%3D%20agentid%3Dedelivery-extprod%20ver%3D1%20crmethod%3D2&ECID-Context=1.005j2HyusRcFo2KimTXvWJ0002ZZ00IcIc%3BkXjE
Resolving login.oracle.com (login.oracle.com)... 209.17.4.8
Connecting to login.oracle.com (login.oracle.com)|209.17.4.8|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4149 (4.1K) [text/html]
Saving to: ‘jdk-8u281-linux-x64.tar.gz’
100%[==============================================================================================================================================================================>] 4,149 --.-K/s in 0s
2021-02-25 15:56:59 (24.7 MB/s) - ‘jdk-8u281-linux-x64.tar.gz’ saved [4149/4149]
[admin@oftpclient201 ~]$
按方法一确认以后发现下载的压缩包还是不完整,查了资料说是按这种方法就可以,也有的说是这种方法已经过时了。还有的说是wget命令有缺陷不会重定向,但是抓包是发现网页中点击下载会有重定向的请求,...等等各种各样的说法,第二天宏哥正要老老实实的在Oracle注册、登录账号(太麻烦)据说注册、登录账号后,复制的下载链接中会自带cookie、协议和安全认证,然后用wget命令+上此下载链接可以下载成功,但是宏哥觉得有点麻烦,这种方法就没尝试,你如果有兴趣的话,童鞋们或者小伙伴自己可以尝试一下按宏哥说的是否可以成功下载压缩包。,然后下载Linux的JDK安装包,然后再上传到Linux系统中。但是宏哥这个人比较懒吧,也比较不甘心,所以再次决定再查查资料。结果百度查询了半天左右,经过反复的摸索终于找到一个靠谱的答案。网上那些太多的都是复制来复制去,都不能解决实质性问题。
(3)在方法二的基础上将下载地址中的otn修改成otn-pub
[admin@oftpclient201 ~]$ wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/8u281-b09/89d678f2be164786b292527658ca1605/jdk-8u281-linux-x64.tar.gz
--2021-02-25 16:10:40-- https://download.oracle.com/otn-pub/java/jdk/8u281-b09/89d678f2be164786b292527658ca1605/jdk-8u281-linux-x64.tar.gz
Resolving download.oracle.com (download.oracle.com)... 184.86.92.87
Connecting to download.oracle.com (download.oracle.com)|184.86.92.87|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/otn-pub/java/jdk/8u281-b09/89d678f2be164786b292527658ca1605/jdk-8u281-linux-x64.tar.gz [following]
--2021-02-25 16:10:41-- https://edelivery.oracle.com/otn-pub/java/jdk/8u281-b09/89d678f2be164786b292527658ca1605/jdk-8u281-linux-x64.tar.gz
Resolving edelivery.oracle.com (edelivery.oracle.com)... 23.76.87.214, 2600:1400:c000:482::366, 2600:1400:c000:488::366
Connecting to edelivery.oracle.com (edelivery.oracle.com)|23.76.87.214|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://download.oracle.com/otn-pub/java/jdk/8u281-b09/89d678f2be164786b292527658ca1605/jdk-8u281-linux-x64.tar.gz?AuthParam=1614240762_cf401250c965e2946ab43486aa6c2db3 [following]
--2021-02-25 16:10:42-- https://download.oracle.com/otn-pub/java/jdk/8u281-b09/89d678f2be164786b292527658ca1605/jdk-8u281-linux-x64.tar.gz?AuthParam=1614240762_cf401250c965e2946ab43486aa6c2db3
Connecting to download.oracle.com (download.oracle.com)|184.86.92.87|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 143722924 (137M) [application/x-gzip]
Saving to: ‘jdk-8u281-linux-x64.tar.gz’
100%[==============================================================================================================================================================================>] 143,722,924 2.67MB/s in 57s
2021-02-25 16:11:40 (2.41 MB/s) - ‘jdk-8u281-linux-x64.tar.gz’ saved [143722924/143722924]
[admin@oftpclient201 ~]$ ll -h
从上图可以看出下载时间是57s,虽然这个时间与网速有关系,但是大致感觉时间也差不多了。因此宏哥判断这次是真的解决了,安装包下载成功了。
和宏哥来再次看一下压缩的安装包的大小是138M,和官网展示的大小也差不多,预示着下载成功,问题解决
[admin@oftpclient201 ~]$ ll -h
total 138M-rw-rw-r--. 1 admin admin 0 Feb 25 16:09 ]-rw-rw-r--. 1 admin admin 138M Dec 11 03:12 jdk-8u281-linux-x64.tar.gz-rw-rw-r--. 1 admin admin 39 Feb 2 16:20 test.txt-rw-rw-r--. 1 admin admin 78 Feb 2 16:21 t.zip
[admin@oftpclient201 ~]$
7.拓展
7.1linux下如何查看已安装的centos版本信息
1.Linux查看当前操作系统版本信息 cat /proc/version
[admin@oftpclient201 ~]$ cat /proc/version
Linux version 3.10.0-1160.11.1.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Fri Dec 18 16:34:56 UTC 2020
[admin@oftpclient201 ~]$
2.Linux查看版本当前操作系统内核信息 uname -a
[admin@oftpclient201 ~]$ uname -a
Linux oftpclient201.test.cedex.cn 3.10.0-1160.11.1.el7.x86_64 #1 SMP Fri Dec 18 16:34:56 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
3.linux查看版本当前操作系统发行信息 cat /etc/issue 或 cat /etc/centos-release
[admin@oftpclient201 ~]$ cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)
4.Linux查看cpu相关信息,包括型号、主频、内核信息等 cat /etc/cpuinfo
[admin@oftpclient201 ~]$ cat /proc/cpuinfo
processor : 0 #数值为0表示第1颗cpu
vendor_id : GenuineIntel
cpu family : 6
model : 58
model name : Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz
stepping : 9
microcode : 0x15
cpu MHz : 2594.170
cache size : 3072 KB
physical id : 0
siblings : 1
core id : 0
cpu cores : 1
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm epb fsgsbase tsc_adjust smep dtherm ida arat pln pts
bogomips : 5188.34
clflush size : 64
cache_alignment : 64
address sizes : 42 bits physical, 48 bits virtual
power management:
processor : 1 #数值为1表示第2颗cpu
vendor_id : GenuineIntel
cpu family : 6
model : 58
model name : Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz
stepping : 9
microcode : 0x15
cpu MHz : 2594.170
cache size : 3072 KB
physical id : 2
siblings : 1
core id : 0
cpu cores : 1
apicid : 2
initial apicid : 2
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm epb fsgsbase tsc_adjust smep dtherm ida arat pln pts
bogomips : 5188.34
clflush size : 64
cache_alignment : 64
address sizes : 42 bits physical, 48 bits virtual
power management:
processor :系统中逻辑处理核的编号。对于单核处理器,则课认为是其CPU编号,对于多核处理器则可以是物理核、或者使用超线程技术虚拟的逻辑核
vendor_id :CPU制造商
cpu family :CPU产品系列代号
model :CPU属于其系列中的哪一代的代号
model name:CPU属于的名字及其编号、标称主频
stepping :CPU属于制作更新版本
cpu MHz :CPU的实际使用主频
cache size :CPU二级缓存大小
physical id :单个CPU的标号
siblings :单个CPU逻辑物理核数
core id :当前物理核在其所处CPU中的编号,这个编号不一定连续
cpu cores :该逻辑核所处CPU的物理核数
apicid :用来区分不同逻辑核的编号,系统中每个逻辑核的此编号必然不同,此编号不一定连续
fpu :是否具有浮点运算单元(Floating Point Unit)
fpu_exception :是否支持浮点计算异常
cpuid level :执行cpuid指令前,eax寄存器中的值,根据不同的值cpuid指令会返回不同的内容
wp :表明当前CPU是否在内核态支持对用户空间的写保护(Write Protection)
flags :当前CPU支持的功能
bogomips :在系统内核启动时粗略测算的CPU速度(Million Instructions Per Second)
clflush size :每次刷新缓存的大小单位
cache_alignment :缓存地址对齐单位
address sizes :可访问地址空间位数
5.Linux查看版本说明当前CPU运行在32bit模式下(但不代表CPU不支持64bit)
[admin@oftpclient201 etc]$ getconf LONG_BIT64
7.2uname的使用
uname命令用于打印当前系统相关信息(内核版本号、硬件架构、主机名称和操作系统类型等)。
uname -a显示全部信息-m或--machine:显示电脑类型;-r或--release:显示操作系统的发行编号;-s或--sysname:显示操作系统名称;-v:显示操作系统的版本;-p或--processor:输出处理器类型或"unknown";-i或--hardware-platform:输出硬件平台或"unknown";-o或--operating-system:输出操作系统名称;--help:显示帮助;--version:显示版本信息。
7.3查看Linux版本
1.查看系统版本信息的命令 lsb_release -a
(使用命令时提示command not found,需要安装yum install redhat-lsb -y)
[admin@oftpclient201 etc]$
[admin@oftpclient201 etc]$ lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.9.2009 (Core)
Release: 7.9.2009
Codename: Core
注:这个命令适用于所有的linux,包括RedHat、SUSE、Debian等发行版。
2.查看centos版本号 cat /etc/issue
[admin@oftpclient201 etc]$ cat /etc/issue
\S
Kernel \r on an \m
[admin@oftpclient201 etc]$
3.使用 file /bin/ls
[admin@oftpclient201 etc]$ file /bin/ls/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=c8ada1f7095f6b2bb7ddc848e088c2d615c3743e, stripped
[admin@oftpclient201 etc]$
原文链接:Linux下安装JDK 1.8你必须知道的那些糟心事!
请关注+私信回复:“测试”就可以免费拿到软件测试学习资料,同时进入群学习交流~~
相关推荐
- 3分钟让你的项目支持AI问答模块,完全开源!
-
hello,大家好,我是徐小夕。之前和大家分享了很多可视化,零代码和前端工程化的最佳实践,今天继续分享一下最近开源的Next-Admin的最新更新。最近对这个项目做了一些优化,并集成了大家比较关注...
- 干货|程序员的副业挂,12个平台分享
-
1、D2adminD2Admin是一个完全开源免费的企业中后台产品前端集成方案,使用最新的前端技术栈,小于60kb的本地首屏js加载,已经做好大部分项目前期准备工作,并且带有大量示例代码,助...
- Github标星超200K,这10个可视化面板你知道几个
-
在Github上有很多开源免费的后台控制面板可以选择,但是哪些才是最好、最受欢迎的可视化控制面板呢?今天就和大家推荐Github上10个好看又流行的可视化面板:1.AdminLTEAdminLTE是...
- 开箱即用的炫酷中后台前端开源框架第二篇
-
#头条创作挑战赛#1、SoybeanAdmin(1)介绍:SoybeanAdmin是一个基于Vue3、Vite3、TypeScript、NaiveUI、Pinia和UnoCSS的清新优...
- 搭建React+AntDeign的开发环境和框架
-
搭建React+AntDeign的开发环境和框架随着前端技术的不断发展,React和AntDesign已经成为越来越多Web应用程序的首选开发框架。React是一个用于构建用户界面的JavaScrip...
- 基于.NET 5实现的开源通用权限管理平台
-
??大家好,我是为广大程序员兄弟操碎了心的小编,每天推荐一个小工具/源码,装满你的收藏夹,每天分享一个小技巧,让你轻松节省开发效率,实现不加班不熬夜不掉头发,是我的目标!??今天小编推荐一款基于.NE...
- StreamPark - 大数据流计算引擎
-
使用Docker完成StreamPark的部署??1.基于h2和docker-compose进行StreamPark部署wgethttps://raw.githubusercontent.com/a...
- 教你使用UmiJS框架开发React
-
1、什么是Umi.js?umi,中文可发音为乌米,是一个可插拔的企业级react应用框架。你可以将它简单地理解为一个专注性能的类next.js前端框架,并通过约定、自动生成和解析代码等方式来辅助...
- 简单在线流程图工具在用例设计中的运用
-
敏捷模式下,测试团队的用例逐渐简化以适应快速的发版节奏,大家很早就开始运用思维导图工具比如xmind来编写测试方法、测试点。如今不少已经不少利用开源的思维导图组件(如百度脑图...)来构建测试测试...
- 【开源分享】神奇的大数据实时平台框架,让Flink&Spark开发更简单
-
这是一个神奇的框架,让Flink|Spark开发更简单,一站式大数据实时平台!他就是StreamX!什么是StreamX大数据技术如今发展的如火如荼,已经呈现百花齐放欣欣向荣的景象,实时处理流域...
- 聊聊规则引擎的调研及实现全过程
-
摘要本期主要以规则引擎业务实现为例,陈述在陌生业务前如何进行业务深入、调研、技术选型、设计及实现全过程分析,如果你对规则引擎不感冒、也可以从中了解一些抽象实现过程。诉求从硬件采集到的数据提供的形式多种...
- 【开源推荐】Diboot 2.0.5 发布,自动化开发助理
-
一、前言Diboot2.0.5版本已于近日发布,在此次发布中,我们新增了file-starter组件,完善了iam-starter组件,对core核心进行了相关优化,让devtools也支持对IAM...
- 微软推出Copilot Actions,使用人工智能自动执行重复性任务
-
IT之家11月19日消息,微软在今天举办的Ignite大会上宣布了一系列新功能,旨在进一步提升Microsoft365Copilot的智能化水平。其中最引人注目的是Copilot...
- Electron 使用Selenium和WebDriver
-
本节我们来学习如何在Electron下使用Selenium和WebDriver。SeleniumSelenium是ThoughtWorks提供的一个强大的基于浏览器的开源自动化测试工具...
- Quick 'n Easy Web Builder 11.1.0设计和构建功能齐全的网页的工具
-
一个实用而有效的应用程序,能够让您轻松构建、创建和设计个人的HTML网站。Quick'nEasyWebBuilder是一款全面且轻巧的软件,为用户提供了一种简单的方式来创建、编辑...
- 一周热门
- 最近发表
- 标签列表
-
- kubectlsetimage (56)
- mysqlinsertoverwrite (53)
- addcolumn (54)
- helmpackage (54)
- varchar最长多少 (61)
- 类型断言 (53)
- protoc安装 (56)
- jdk20安装教程 (60)
- rpm2cpio (52)
- 控制台打印 (63)
- 401unauthorized (51)
- vuexstore (68)
- druiddatasource (60)
- 企业微信开发文档 (51)
- rendertexture (51)
- speedphp (52)
- gitcommit-am (68)
- bashecho (64)
- str_to_date函数 (58)
- yum下载包及依赖到本地 (72)
- jstree中文api文档 (59)
- mvnw文件 (58)
- rancher安装 (63)
- nginx开机自启 (53)
- .netcore教程 (53)