51Testing软件测试论坛

标题: Linux下安装JDK1.8你必须知道的糟心事 [打印本页]

作者: lsekfe    时间: 2021-4-28 11:41
标题: Linux下安装JDK1.8你必须知道的糟心事
一、简介
Oracle收购Sun后,Java的一系列产品就被整合到Oracle官网中,打开官网乍眼一看也不知道去哪里下载,还的一个一个的摸索尝试,而且网上大多数都是一些Oracle收购Sun前,或者就是一些老的资料文章,为了避免这些坑,宏哥才决定写着一篇文章。
JDK是 JAVA 的软件开发工具包,如果要使用JAVA来进行开发,或者部署基于其开发的应用,那么就需要安装JDK。本次将在Linux下安装JDK及配置环境。在以前宏哥也在Linux下安装过JDK,安装过程溜得飞起来。结果这次安装过程中却是十分的不顺,所以才有了这篇文章用来记录和分享安装 过程中遇到的问题和心得体会,希望对各位有所帮忙,避免做更多的无用功。
宏哥的环境:
查看Linux环境输入命令:lsb_release -a
  1. [admin@oftpclient201 ~]$ lsb_release -a
  2. 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
  3. Distributor ID: CentOS
  4. Description:    CentOS Linux release 7.9.2009 (Core)
  5. Release:        7.9.2009
复制代码
二、下载JDK
在安装之前,检查是否存在Linux下自带的OpenJDK,命令:rpm -qa | grep java。若存在,则需要进行卸载,命令:rpm -e --nodeps 卸载的软件名
其他方法:
  1. java -version
  2. echo $PATH 看环境变量bai是否配du置了java路径
  3. 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官网地址:https://www.oracle.com/  ,如下图所示:
[attach]132645[/attach]
2)鼠标放在product上在下拉菜单中点击Java,如下图所示:
[attach]132646[/attach]
3)然后再点击“Download Java”,如下图所示:
[attach]132647[/attach]
(4)下滑页面找到Java SE8,然后点击“JDK Download”,如下图所示:
[attach]132648[/attach]
5)找到Linux系统的64位的JDK,选中安装包右键,点击“复制链接地址”,如下图所示:
[attach]132649[/attach]
6)在xshell上输入命令wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie"后面加上你刚才复制的下载链接
2.然后使用下面的wget下载就好了~(注意文件的后缀,有时候不可以直接解压需要重命名后缀名哦)
  1. 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
[attach]132650[/attach]
可以看到,本次解压到了当前目录 /usr/JDK/jdk1.8.0_281下。
4.配置环境
解压完成之后,我们要配置下环境变量,通过 vim 命令修改配置文件 /etc/profile 来设置环境变量。
  1. vim /etc/profile
复制代码
在文件最后一行,输入 i 进入编辑模式,添加以下内容,然后按 Esc 退出编辑模式,再输入 :wq 保存并退出。
  1. export JAVA_HOME=/usr/JDK/jdk1.8.0_281  
  2. export JRE_HOME=${JAVA_HOME}/jre  
  3. export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib  
  4. export PATH=${JAVA_HOME}/bin:$PATH
复制代码
设置完之后,如果要使环境变量立即生效,需要通过命令:source /etc/profile,重新加载配置文件。
5.验证是否安装成功
所有都配置好了,我们需要验证下是否安装成功。
依次输入 java -versionjavajavac,不会出现报错并且显示出 jdk版本号及 java/javac相关命令参数说明界面。
  1. [admin@oftpclient201 ~]$ java -version
  2. java version "1.8.0_281"
  3. Java(TM) SE Runtime Environment (build 1.8.0_281-b09)
  4. Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode)
  5. [admin@oftpclient201 ~]$ java
  6. Usage: java [-options] class [args...]
  7.            (to execute a class)
  8.    or  java [-options] -jar jarfile [args...]
  9.            (to execute a jar file)where options include:
  10.     -d32          use a 32-bit data model if available
  11.     -d64          use a 64-bit data model if available
  12.     -server       to select the "server" VM
  13.                   The default VM is server.

  14.     -cp <class search path of directories and zip/jar files>
  15.     -classpath <class search path of directories and zip/jar files>
  16.                   A : separated list of directories, JAR archives,
  17.                   and ZIP archives to search for class files.
  18.     -D<name>=<value>
  19.                   set a system property
  20.     -verbose:[class|gc|jni]
  21.                   enable verbose output
  22.     -version      print product version and exit
  23.     -version:<value>
  24.                   Warning: this feature is deprecated and will be removed
  25.                   in a future release.
  26.                   require the specified version to run
  27.     -showversion  print product version and continue
  28.     -jre-restrict-search | -no-jre-restrict-search
  29.                   Warning: this feature is deprecated and will be removed
  30.                   in a future release.
  31.                   include/exclude user private JREs in the version search
  32.     -? -help      print this help message
  33.     -X            print help on non-standard options
  34.     -ea[:<packagename>...|:<classname>]
  35.     -enableassertions[:<packagename>...|:<classname>]
  36.                   enable assertions with specified granularity
  37.     -da[:<packagename>...|:<classname>]
  38.     -disableassertions[:<packagename>...|:<classname>]
  39.                   disable assertions with specified granularity
  40.     -esa | -enablesystemassertions
  41.                   enable system assertions
  42.     -dsa | -disablesystemassertions
  43.                   disable system assertions
  44.     -agentlib:<libname>[=<options>]
  45.                   load native agent library <libname>, e.g. -agentlib:hprof
  46.                   see also, -agentlib:jdwp=help and -agentlib:hprof=help
  47.     -agentpath:<pathname>[=<options>]
  48.                   load native agent library by full pathname
  49.     -javaagent:<jarpath>[=<options>]
  50.                   load Java programming language agent, see java.lang.instrument
  51.     -splash:<imagepath>
  52.                   show splash screen with specified image
  53. See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
  54. [admin@oftpclient201 ~]$ javac
  55. Usage: javac <options> <source files>where possible options include:
  56.   -g                         Generate all debugging info
  57.   -g:none                    Generate no debugging info
  58.   -g:{lines,vars,source}     Generate only some debugging info
  59.   -nowarn                    Generate no warnings
  60.   -verbose                   Output messages about what the compiler is doing
  61.   -deprecation               Output source locations where deprecated APIs are used
  62.   -classpath <path>          Specify where to find user class files and annotation processors
  63.   -cp <path>                 Specify where to find user class files and annotation processors
  64.   -sourcepath <path>         Specify where to find input source files
  65.   -bootclasspath <path>      Override location of bootstrap class files
  66.   -extdirs <dirs>            Override location of installed extensions
  67.   -endorseddirs <dirs>       Override location of endorsed standards path
  68.   -proc:{none,only}          Control whether annotation processing and/or compilation is done.
  69.   -processor <class1>[,<class2>,<class3>...] Names of the annotation processors to run; bypasses default discovery process
  70.   -processorpath <path>      Specify where to find annotation processors
  71.   -parameters                Generate metadata for reflection on method parameters
  72.   -d <directory>             Specify where to place generated class files
  73.   -s <directory>             Specify where to place generated source files
  74.   -h <directory>             Specify where to place generated native header files
  75.   -implicit:{none,class}     Specify whether or not to generate class files for implicitly referenced files
  76.   -encoding <encoding>       Specify character encoding used by source files
  77.   -source <release>          Provide source compatibility with specified release
  78.   -target <release>          Generate class files for specific VM version
  79.   -profile <profile>         Check that API used is available in the specified profile
  80.   -version                   Version information
  81.   -help                      Print a synopsis of standard options
  82.   -Akey[=value]              Options to pass to annotation processors
  83.   -X                         Print a synopsis of nonstandard options
  84.   -J<flag>                   Pass <flag> directly to the runtime system
  85.   -Werror                    Terminate compilation if warnings occur
  86.   @<filename>                Read options and filenames from file

  87. [admin@oftpclient201 ~]$
复制代码
6.小结
安装过程中宏哥为了避免麻烦不是在Windows上直接安装好然后再上传到Linux上,而是直接用weget命令直接安装的,结果遇到如下一系列的问题:
1)wget+复制好的下载地址
  1. [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.
  2. HTTP request sent, awaiting response... 302 Moved Temporarily
  3. Location: https://edelivery.oracle.com/akam/otn/java/jdk/8u281-b09/89d678f2be164786b292527658ca1605/jdk-8u281-linux-x64.tar.gz [following]
  4. --2021-02-25 15:25:48--  https://edelivery.oracle.com/akam/otn/java/jdk/8u281-b09/89d678f2be164786b292527658ca1605/jdk-8u281-linux-x64.tar.gz
  5. Resolving edelivery.oracle.com (edelivery.oracle.com)... 184.30.17.110, 2600:1400:c000:482::366, 2600:1400:c000:488::366
  6. Connecting to edelivery.oracle.com (edelivery.oracle.com)|184.30.17.110|:443... connected.
  7. HTTP request sent, awaiting response... 302 Moved Temporarily
  8. 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]
  9. --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
  10. Resolving login.oracle.com (login.oracle.com)... 209.17.4.8
  11. Connecting to login.oracle.com (login.oracle.com)|209.17.4.8|:443... connected.
  12. HTTP request sent, awaiting response... 200 OK
  13. Length: 4103 (4.0K) [text/html]
  14. Saving to: ‘jdk-8u281-linux-x64.tar.gz.1’
  15. 100%[==============================================================================================================================================================================>] 4,103       17.6KB/s   in 0.2s
  16. 2021-02-25 15:25:51 (17.6 KB/s) - ‘jdk-8u281-linux-x64.tar.gz.1’ saved [4103/4103]

  17. [admin@oftpclient201 ~]$
复制代码
从上图看着好像是下载成功了,但是宏哥在解压的时候有报错了,报错如下:
  1. [admin@oftpclient201 ~]$ tar -zxvf jdk-8u281-linux-x64.tar.gz

  2. gzip: stdin: not in gzip format
  3. tar: Child returned status 1
  4. tar: Error is not recoverable: exiting now
  5. [admin@oftpclient201 ~]$
复制代码
从上图的报错可以发现说是压缩包不完整,宏哥好奇既然下载成功怎么会是不完整的了,于是宏哥看了一下压缩包的大小,如下所示才4.1K,
  1. [admin@oftpclient201 ~]$ ll -lh
  2. 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
  3. [admin@oftpclient201 ~]$
复制代码
这个与Oracle官网显示的大小100多M差太多了,所以确定是下载不成功而且回过头来看一下下载时间几乎零点几秒就下载完成了,更加确定下载的压缩包是不完整的。
查了资料说是由于Oracle需要accept license、cookie,所以需要给wget带如下参数即可,于是就有了第二种方法的尝试
2)wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie"+复制好的下载地址
  1. [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
  2. --2021-02-25 15:56:55--  https://download.oracle.com/otn/java/jdk/8u281-b09/89d678f2be164786b292527658ca1605/jdk-8u281-linux-x64.tar.gz
  3. Resolving download.oracle.com (download.oracle.com)... 92.123.228.99
  4. Connecting to download.oracle.com (download.oracle.com)|92.123.228.99|:443... connected.
  5. HTTP request sent, awaiting response... 302 Moved Temporarily
  6. Location: https://edelivery.oracle.com/akam/otn/java/jdk/8u281-b09/89d678f2be164786b292527658ca1605/jdk-8u281-linux-x64.tar.gz [following]
  7. --2021-02-25 15:56:56--  https://edelivery.oracle.com/akam/otn/java/jdk/8u281-b09/89d678f2be164786b292527658ca1605/jdk-8u281-linux-x64.tar.gz
  8. Resolving edelivery.oracle.com (edelivery.oracle.com)... 23.76.64.181, 2a02:26f0:a00:3be::366, 2a02:26f0:a00:385::366
  9. Connecting to edelivery.oracle.com (edelivery.oracle.com)|23.76.64.181|:443... connected.
  10. HTTP request sent, awaiting response... 302 Moved Temporarily
  11. 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]
  12. --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
  13. Resolving login.oracle.com (login.oracle.com)... 209.17.4.8
  14. Connecting to login.oracle.com (login.oracle.com)|209.17.4.8|:443... connected.
  15. HTTP request sent, awaiting response... 200 OK
  16. Length: 4149 (4.1K) [text/html]
  17. Saving to: ‘jdk-8u281-linux-x64.tar.gz’
  18. 100%[==============================================================================================================================================================================>] 4,149       --.-K/s   in 0s
  19. 2021-02-25 15:56:59 (24.7 MB/s) - ‘jdk-8u281-linux-x64.tar.gz’ saved [4149/4149]

  20. [admin@oftpclient201 ~]$
复制代码
按方法一确认以后发现下载的压缩包还是不完整,查了资料说是按这种方法就可以,也有的说是这种方法已经过时了。还有的说是wget命令有缺陷不会重定向,但是抓包是发现网页中点击下载会有重定向的请求,...等等各种各样的说法,第二天宏哥正要老老实实的在Oracle注册、登录账号(太麻烦)据说注册、登录账号后,复制的下载链接中会自带cookie、协议和安全认证,然后用wget命令+上此下载链接可以下载成功,但是宏哥觉得有点麻烦,这种方法就没尝试,你如果有兴趣的话,童鞋们或者小伙伴自己可以尝试一下按宏哥说的是否可以成功下载压缩包。,然后下载Linux的JDK安装包,然后再上传到Linux系统中。但是宏哥这个人比较懒吧,也比较不甘心,所以再次决定再查查资料。结果百度查询了半天左右,经过反复的摸索终于找到一个靠谱的答案。网上那些太多的都是复制来复制去,都不能解决实质性问题。
3)在方法二的基础上将下载地址中的otn修改成otn-pub
  1. [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
  2. --2021-02-25 16:10:40--  https://download.oracle.com/otn-pub/java/jdk/8u281-b09/89d678f2be164786b292527658ca1605/jdk-8u281-linux-x64.tar.gz
  3. Resolving download.oracle.com (download.oracle.com)... 184.86.92.87
  4. Connecting to download.oracle.com (download.oracle.com)|184.86.92.87|:443... connected.
  5. HTTP request sent, awaiting response... 302 Moved Temporarily
  6. Location: https://edelivery.oracle.com/otn-pub/java/jdk/8u281-b09/89d678f2be164786b292527658ca1605/jdk-8u281-linux-x64.tar.gz [following]
  7. --2021-02-25 16:10:41--  https://edelivery.oracle.com/otn-pub/java/jdk/8u281-b09/89d678f2be164786b292527658ca1605/jdk-8u281-linux-x64.tar.gz
  8. Resolving edelivery.oracle.com (edelivery.oracle.com)... 23.76.87.214, 2600:1400:c000:482::366, 2600:1400:c000:488::366
  9. Connecting to edelivery.oracle.com (edelivery.oracle.com)|23.76.87.214|:443... connected.
  10. HTTP request sent, awaiting response... 302 Moved Temporarily
  11. Location: https://download.oracle.com/otn-pub/java/jdk/8u281-b09/89d678f2be164786b292527658ca1605/jdk-8u281-linux-x64.tar.gz?AuthParam=1614240762_cf401250c965e2946ab43486aa6c2db3 [following]
  12. --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
  13. Connecting to download.oracle.com (download.oracle.com)|184.86.92.87|:443... connected.
  14. HTTP request sent, awaiting response... 200 OK
  15. Length: 143722924 (137M) [application/x-gzip]
  16. Saving to: ‘jdk-8u281-linux-x64.tar.gz’
  17. 100%[==============================================================================================================================================================================>] 143,722,924 2.67MB/s   in 57s
  18. 2021-02-25 16:11:40 (2.41 MB/s) - ‘jdk-8u281-linux-x64.tar.gz’ saved [143722924/143722924]

  19. [admin@oftpclient201 ~]$ ll -h
复制代码
从上图可以看出下载时间是57s,虽然这个时间与网速有关系,但是大致感觉时间也差不多了。因此宏哥判断这次是真的解决了,安装包下载成功了。
和宏哥来再次看一下压缩的安装包的大小是138M,和官网展示的大小也差不多,预示着下载成功,问题解决
  1. [admin@oftpclient201 ~]$ ll -h
  2. 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
  3. [admin@oftpclient201 ~]$
复制代码
7、拓展
7.1linux下如何查看已安装的centos版本信息
1.Linux查看当前操作系统版本信息 cat /proc/version
  1. [admin@oftpclient201 ~]$ cat /proc/version
  2. 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
  3. [admin@oftpclient201 ~]$
复制代码
2.Linux查看版本当前操作系统内核信息 uname -a
  1. [admin@oftpclient201 ~]$ uname -a
  2. 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
  1. [admin@oftpclient201 ~]$ cat /etc/centos-release
  2. CentOS Linux release 7.9.2009 (Core)
复制代码
4.Linux查看cpu相关信息,包括型号、主频、内核信息等 cat /etc/cpuinfo
  1. [admin@oftpclient201 ~]$ cat /proc/cpuinfo
  2. processor    : 0 #数值为0表示第1颗cpu
  3. vendor_id    : GenuineIntel
  4. cpu family    : 6
  5. model        : 58
  6. model name    : Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz
  7. stepping    : 9
  8. microcode    : 0x15
  9. cpu MHz        : 2594.170
  10. cache size    : 3072 KB
  11. physical id    : 0
  12. siblings    : 1
  13. core id        : 0
  14. cpu cores    : 1
  15. apicid        : 0
  16. initial apicid    : 0
  17. fpu        : yes
  18. fpu_exception    : yes
  19. cpuid level    : 13
  20. wp        : yes
  21. 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
  22. bogomips    : 5188.34
  23. clflush size    : 64
  24. cache_alignment    : 64
  25. address sizes    : 42 bits physical, 48 bits virtual
  26. power management:

  27. processor    : 1 #数值为1表示第2颗cpu
  28. vendor_id    : GenuineIntel
  29. cpu family    : 6
  30. model        : 58
  31. model name    : Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz
  32. stepping    : 9
  33. microcode    : 0x15
  34. cpu MHz        : 2594.170
  35. cache size    : 3072 KB
  36. physical id    : 2
  37. siblings    : 1
  38. core id        : 0
  39. cpu cores    : 1
  40. apicid        : 2
  41. initial apicid    : 2
  42. fpu        : yes
  43. fpu_exception    : yes
  44. cpuid level    : 13
  45. wp        : yes
  46. 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
  47. bogomips    : 5188.34
  48. clflush size    : 64
  49. cache_alignment    : 64
  50. address sizes    : 42 bits physical, 48 bits virtual
  51. 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)
  1. [admin@oftpclient201 etc]$ getconf LONG_BIT64
复制代码
7.2uname的使用
uname命令用于打印当前系统相关信息(内核版本号、硬件架构、主机名称和操作系统类型等)。
  1. 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)
  1. [admin@oftpclient201 etc]$
  2. [admin@oftpclient201 etc]$ lsb_release -a
  3. 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
  4. Distributor ID: CentOS
  5. Description:    CentOS Linux release 7.9.2009 (Core)
  6. Release:        7.9.2009
  7. Codename:       Core
复制代码
:这个命令适用于所有的linux,包括RedHat、SUSE、Debian等发行版。
2.查看centos版本号 cat /etc/issue
  1. [admin@oftpclient201 etc]$ cat /etc/issue
  2. \S
  3. Kernel \r on an \m

  4. [admin@oftpclient201 etc]$
复制代码
3.使用 file /bin/ls
  1. [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
  2. [admin@oftpclient201 etc]$
复制代码







欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2