ubuntu安装、查看已安装包的方法(转)

 ubuntu  ubuntu安装、查看已安装包的方法(转)已关闭评论
9月 162021
 

网上发现的一篇很好的关于ubuntu下查看或安装包的方法的文章,转载分享下,原文链接见文末。

 

说明:由于图形化界面方法(如Add/Remove… 和Synaptic Package Manageer)比较简单,所以这里主要总结在终端通过命令行方式进行的软件包安装、卸载和删除的方法。

一、Ubuntu中软件安装方法

1、APT方式

(1)普通安装:apt-get install softname1 softname2 …;

(2)修复安装:apt-get -f install softname1 softname2… ;(-f Atemp to correct broken dependencies)

(3)重新安装:apt-get –reinstall install softname1 softname2…;

2、Dpkg方式

(1)普通安装:dpkg -i package_name.deb

3、源码安装(.tar、tar.gz、tar.bz2、tar.Z)

首先解压缩源码压缩包然后通过tar命令来完成

a.解xx.tar.gz:tar zxf xx.tar.gz
b.解xx.tar.Z:tar zxf xx.tar.Z
c.解xx.tgz:tar zxf xx.tgz
d.解xx.bz2:bunzip2 xx.bz2
e.解xx.tar:tar xf xx.tar

然后进入到解压出的目录中,建议先读一下README之类的说明文件,因为此时不同源代码包或者预编译包可能存在差异,然后建议使用ls -F –color或者ls -F命令(实际上我的只需要 l 命令即可)查看一下可执行文件,可执行文件会以*号的尾部标志。

一般依次执行./configure

make

sudo make install

即可完成安装。

二、Ubuntu中软件包的卸载方法

1、APT方式

(1)移除式卸载:apt-get remove softname1 softname2 …;(移除软件包,当包尾部有+时,意为安装)

(2)清除式卸载 :apt-get –purge remove softname1 softname2…;(同时清除配置)

清除式卸载:apt-get purge sofname1 softname2…;(同上,也清除配置文件)

2、Dpkg方式

(1)移除式卸载:dpkg -r pkg1 pkg2 …;

(2)清除式卸载:dpkg -P pkg1 pkg2…;

 

三、Ubuntu中软件包的查询方法

Dpkg 使用文本文件来作为数据库.通称在 /var/lib/dpkg 目录下. 通称在 status 文件中存储软件状态,和控制信息. 在 info/ 目录下备份控制文件, 并在其下的 .list 文件中记录安装文件清单, 其下的 .mdasums 保存文件的 MD5 编码.

体验使用数据库的时刻到了:

$ dpkg -l Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed |/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad) ||/ Name Version Description +++-===========-================-======================================== ii aalib1 1.4p5-28 ascii art library - transitional package ii adduser 3.85 Add and remove users and groups ii alien .63 install non-native packages with dpkg ... ... 

每条记录对应一个软件包, 注意每条记录的第一, 二, 三个字符. 这就是软件包的状态标识, 后边依此是软件包名称, 版本号, 和简单描述.

  • 第一字符为期望值,它包括:
    • u 状态未知,这意味着软件包未安装,并且用户也未发出安装请求.
    • i 用户请求安装软件包.
    • r 用户请求卸载软件包.
    • p 用户请求清除软件包.
    • h 用户请求保持软件包版本锁定.
  • 第二列,是软件包的当前状态.此列包括软件包的六种状态.
    • n 软件包未安装.
    • i 软件包安装并完成配置.
    • c 软件包以前安装过,现在删除了,但是它的配置文件还留在系统中.
    • u 软件包被解包,但还未配置.
    • f 试图配置软件包,但是失败了.
    • h 软件包安装,但是但是没有成功.
  • 第三列标识错误状态,可以总结为四种状态. 第一种状态标识没有问题,为空. 其它三种符号则标识相应问题.
    • h 软件包被强制保持,因为有其它软件包依赖需求,无法升级.
    • r 软件包被破坏,可能需要重新安装才能正常使用(包括删除).
    • x 软包件被破坏,并且被强制保持.

也可以以统配符模式进行模糊查询, 比如我要查找以nano字符开始的所有软件包:

$ dpkg -l nano* Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed |/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad) ||/ Name Version Description +++-==============-==============-============================================ ii nano 1.3.10-2 free Pico clone with some new features pn nano-tiny <none> (no description available) un nanoblogger <none> (no description available) 

以上状态说明: 系统中安装了 nano 版本为 1.3.10-2 ;安装过 nano-tiny , 后来又清除了; 从未安装过nanoblogger .

如果觉得 dpkg 的参数过多, 不利于记忆的话, 完全可以使用 dpkg-query 进行 dpkg 数据库查询.

应用范例:

  • 查询系统中属于nano的文件:

    $ dpkg –listfiles nano

    or

    $ dpkg-query -L nano

  • 查看软件nano的详细信息:

    $ dpkg -s nano

    or

    $ dpkg-query -s nano

  • 查看系统中软件包状态, 支持模糊查询:

    $ dpkg -l

    or

    $dpkg-query -l

  • 查看某个文件的归属包:

    $ dpkg-query -S nano

    or

    $ dpkg -S nano

三、其他应用总结

apt-cache search # ——(package 搜索包)
apt-cache show #——(package 获取包的相关信息,如说明、大小、版本等)
apt-get install # ——(package 安装包)
apt-get install # —–(package –reinstall 重新安装包)
apt-get -f install # —–(强制安装, “-f = –fix-missing”当是修复安装吧…)
apt-get remove #—–(package 删除包)
apt-get remove –purge # ——(package 删除包,包括删除配置文件等)
apt-get autoremove –purge # —-(package 删除包及其依赖的软件包+配置文件等(只对6.10有效,强烈推荐))
apt-get update #——更新源
apt-get upgrade #——更新已安装的包
apt-get dist-upgrade # ———升级系统
apt-get dselect-upgrade #——使用 dselect 升级
apt-cache depends #——-(package 了解使用依赖)
apt-cache rdepends # ——(package 了解某个具体的依赖,当是查看该包被哪些包依赖吧…)
apt-get build-dep # ——(package 安装相关的编译环境)
apt-get source #——(package 下载该包的源代码)
apt-get clean && apt-get autoclean # ——–清理下载文件的存档 && 只清理过时的包
apt-get check #——-检查是否有损坏的依赖
dpkg -S filename —–查找filename属于哪个软件包
apt-file search filename —–查找filename属于哪个软件包
apt-file list packagename —–列出软件包的内容
apt-file update –更新apt-file的数据库

dpkg –info “软件包名” –列出软件包解包后的包名称.
dpkg -l –列出当前系统中所有的包.可以和参数less一起使用在分屏查看. (类似于rpm -qa)
dpkg -l |grep -i “软件包名” –查看系统中与”软件包名”相关联的包.
dpkg -s 查询已安装的包的详细信息.
dpkg -L 查询系统中已安装的软件包所安装的位置. (类似于rpm -ql)
dpkg -S 查询系统中某个文件属于哪个软件包. (类似于rpm -qf)
dpkg -I 查询deb包的详细信息,在一个软件包下载到本地之后看看用不用安装(看一下呗).
dpkg -i 手动安装软件包(这个命令并不能解决软件包之前的依赖性问题),如果在安装某一个软件包的时候遇到了软件依赖的问题,可以用apt-get -f install在解决信赖性这个问题.
dpkg -r 卸载软件包.不是完全的卸载,它的配置文件还存在.
dpkg -P 全部卸载(但是还是不能解决软件包的依赖性的问题)
dpkg -reconfigure 重新配置

apt-get install
下载软件包,以及所有依赖的包,同时进行包的安装或升级。如果某个包被设置了 hold (停止标志,就会被搁在一边(即不会被升级)。更多 hold 细节请看下面。
apt-get remove [–purge]
移除 以及任何依赖这个包的其它包。
–purge 指明这个包应该被完全清除 (purged) ,更多信息请看 dpkg -P。

apt-get update
升级来自 Debian 镜像的包列表,如果你想安装当天的任何软件,至少每天运行一次,而且每次修改了
/etc/apt/sources.list 後,必须执行。

apt-get upgrade [-u]
升 级所有已经安装的包为最新可用版本。不会安装新的或移除老的包。如果一个包改变了依赖关系而需要安装一个新的包,那么它将不会被升级,而是标志为 hold。apt-get update 不会升级被标志为 hold 的包 (这个也就是 hold 的意思)。请看下文如何手动设置包为 hold。我建议同时使用 ‘-u’ 选项,因为这样你就能看到哪些包将会被升级。

apt-get dist-upgrade [-u]
和 apt-get upgrade 类似,除了 dist-upgrade 会安装和移除包来满足依赖关系。因此具有一定的危险性。

apt-cache search
在软件包名称和描述中,搜索包含xxx的软件包。

apt-cache show
显示某个软件包的完整的描述。

apt-cache showpkg
显示软件包更多细节,以及和其它包的关系。

dselect
console-apt
aptitude
gnome-apt
APT 的几个图形前端(其中一些在使用前得先安装)。这里 dselect 无疑是最强大的,也是最古老,最难驾驭。

普通 Dpkg 用法
dpkg -i
安装一个 Debian 包文件,如你手动下载的文件。

dpkg -c
列出 的内容。

dpkg -I
从 中提取包信息。

dpkg -r
移除一个已安装的包。

dpkg -P
完全清除一个已安装的包。和 remove 不同的是,remove 只是删掉数据和可执行文件,purge 另外还删除所有的配制文件。

dpkg -L
列出 安装的所有文件清单。同时请看 dpkg -c 来检查一个 .deb 文件的内容。

dpkg -s
显示已安装包的信息。同时请看 apt-cache 显示 Debian 存档中的包信息,以及 dpkg -I 来显示从一个 .deb 文件中提取的包信息。

dpkg-reconfigure
重 新配制一个已经安装的包,如果它使用的是 debconf (debconf 为包安装提供了一个统一的配制界面)。你能够重新配制 debconf 它本身,如你想改变它的前端或提问的优先权。例如,重新配制 debconf,使用一个 dialog 前端,简单运行:

dpkg-reconfigure –frontend=dialog debconf (如果你安装时选错了,这里可以改回来哟:)

echo ” hold” | dpkg –set-selections
设置 的状态为 hlod (命令行方式)

dpkg –get-selections “”
取的 的当前状态 (命令行方式)

支持通配符,如:
Debian:~# dpkg –get-selections *wine*
libwine hold
libwine-alsa hold
libwine-arts hold
libwine-dev hold
libwine-nas hold
libwine-print hold
libwine-twain hold
wine hold
wine+ hold
wine-doc hold
wine-utils hold

例如:
大家现在用的都是 gaim-0.58 + QQ-plugin,为了防止 gaim 被升级,我们可以采用如下方法:

方法一:
Debian:~# echo “gaim hold” | dpkg –set-selections
然後用下面命令检查一下:
Debian:~# dpkg –get-selections “gaim”
gaim hold
现在的状态标志是 hold,就不能被升级了。

如果想恢复怎么办呢?
Debian:~# echo “gaim install” | dpkg –set-selections
Debian:~# dpkg –get-selections “gaim”
gaim install
这时状态标志又被重置为 install,可以继续升级了。

同志们会问,哪个这些状态标志都写在哪个文件中呢?
在 /var/lib/dpkg/status 里,你也可以通过修改这个文件实现 hold。

有时你会发现有的软件状态标志是 purge,不要奇怪。
如:事先已经安装了 amsn,然後把它卸了。
apt-get remove –purge amsn
那么状态标志就从 install 变成 purge。

方法二:
在/etc/apt 下手动建一个 preferences 文件
内容:
Package: gaim
Pin: version 0.58*
保存

dpkg -S
在包数据库中查找 ,并告诉你哪个包包含了这个文件。(注:查找的是事先已经安装的包)

——————————————–
Debian的软件包管理工具命令不完全列表
——————————————–
Debian系统中所有的包信息都在/var/lib/dpkg下.其中/var/lib/dpkg/info目录中保存了各个软件包的信息及管理文件.每个文件的作用如下:
以 “.conffiles”     结尾的文件记录软件包的配置列表.
以 “.list”          结尾的文件记录了软件包的文件列表,用户可在文件当中找到软件包文件的具体安装位置.
以 “.md5sums”       结尾的文件记录了md5信息,用来进行包的验证的.
以 “.config”        结尾的文件是软件包的安装配置角本.
以 “.postinst”      角本是完成Debian包解开之后的配置工作,通常用来执行所安装软件包相关的命令和服务的重新启动.
以 “.preinst”       角本在Debain解包之前运行,主要作用是是停止作用于即将升级的软件包服务直到软件包安装或和升级完成.
以 “.prerm”         脚本负责停止与软件包关联的daemon服务,在删除软件包关联文件之前执行.
以 “.postrm”        脚本负责修改软件包链接或文件关联,或删除由它创建的文件.

/var/lib/dpkg/available是软件包的描述信息.
包括当前系统中所有使用的Debian安装源中所有的软件包,还包括当前系统中已经安装和未安装的软件包.

1.dpkg包管理工具

dpkg -r 卸载软件包.不是完全的卸载,它的配置文件还存在.
dpkg –info “软件包名” –列出软件包解包后的包名称.
dpkg -l     –列出当前系统中所有的包.可以和参数less一起使用在分屏查看.
dpkg -l |grep -i “软件包名” –查看系统中与”软件包名”相关联的包.
dpkg -s   查询已安装的包的详细信息. dpkg -L   查询系统中已安装的软件包所安装的位置.
dpkg -S   查询系统中某个文件属于哪个软件包.
dpkg -I   查询deb包的详细信息,在一个软件包下载到本地之后看看用不用安装(看一下呗).
dpkg -i 手动安装软件包(这个命令并不能解决软件包之前的依赖性问题),如果在安装某一个软件包的时候遇到了软件依赖的问题,可以用apt-get -f install在解决信赖性这个问题.
dpkg -reconfigure 重新配置
dpkg -P 全部卸载(但是还是不能解决软件包的依赖性的问题)

 

2. apt高级包管理工具
(1)GTK图形的”synaptic”,这是APT的前端工具.
(2)”aptitude”,这也是APT的前端工具.
用APT管理工具进行包的管理,可以有以下几种方法做源:
(1)拿安装盘做源,方法如下:
apt-cdrom ident        扫描光盘的信息
apt-cdrom add          添加光盘源
(2)这也是最常用的方法就是把源添加到/etc/apt/source.list中,之后更新列apt-get update

APT管理工具常用命令
apt-cache 加上不同的子命令和参数的使用可以实现查找,显示软件,包信息及包信赖关系等功能.
apt-cache stats 显示当前系统所有使用的Debain数据源的统计信息.
apt-cache search +”包名”,可以查找相关的软件包.
apt-cache show   +”包名”,可以显示指定软件包的详细信息.
apt-cache depends +”包名”,可以查找软件包的依赖关系.
apt-get upgrade   更新系统中所有的包到最新版
apt-get install   安装软件包
apt-get –reindtall install 重新安装软件包
apt-get remove 卸载软件包
apt-get –purge remove 完全卸载软件包
apt-get clean 清除无用的软件包
在用命令apt-get install之前,是先将软件包下载到/var/cache/apt/archives中,之后再进行安装的.所以我们可以用apt-get clean清除/var/cache/apt/archives目录中的软件包.

源码包安装
apt-cache showsrc 查找看源码包的文件信息(在下载之前)
apt-get source 下载源码包.
apt-get build-dep +”包名” 构建源码包的编译环境.

 

清除处于rc状态的软件包

dpkg -l |grep ^rc|awk ‘{print $2}’ |tr [“\n”] [” “] | sudo xargs dpkg -P –

 

转自: http://www.cnblogs.com/forward/archive/2012/01/10/2318483.html

 

Linux下查看系统信息:CPU架构、位数、系统版本、内存信息等信息

 linux  Linux下查看系统信息:CPU架构、位数、系统版本、内存信息等信息已关闭评论
11月 192019
 

linux机器,网上下载软件时经常会看到软件包分成了32位/64位/x86/arm等不同的包,那自己的服务器适用哪个包?服务器具体的架构/位数可以通过什么命令查询呢?

 

#linux 操作系统的位数查看:

[ec2-user@ipxxx ~]$ getconf LONG_BIT
64

#查看cpu信息

[ec2-user@ipxxx ~]$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 79
model name : Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz
stepping : 1
microcode : 0xb000038
cpu MHz : 2300.141
cache size : 46080 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
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 mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm cpuid_fault invpcid_single pti fsgsbase bmi1 avx2 smep bmi2 erms invpcid xsaveopt
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs
bogomips : 4600.18
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:

processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 79
model name : Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz
stepping : 1
microcode : 0xb000038
cpu MHz : 2300.141
cache size : 46080 KB
physical id : 0
siblings : 2
core id : 1
cpu cores : 2
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 mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm cpuid_fault invpcid_single pti fsgsbase bmi1 avx2 smep bmi2 erms invpcid xsaveopt
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs
bogomips : 4600.18
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual

# 总核数 = 物理CPU个数 X 每颗物理CPU的核数
# 总逻辑CPU数 = 物理CPU个数 X 每颗物理CPU的核数 X 超线程数
# 查看物理CPU个数
cat /proc/cpuinfo| grep “physical id”| sort| uniq| wc -l
# 查看每个物理CPU中core的个数(即核数)
cat /proc/cpuinfo| grep “cpu cores”| uniq
# 查看逻辑CPU的个数
cat /proc/cpuinfo| grep “processor”| wc -l

 

#查看cpu硬件架构

在Linux中使用命令arch可以查看机器CPU类型,如”i386”, “i486″,”i586”, “alpha”, “sparc”, “arm”, “m68k”,”mips”, “ppc”,”ia64″,”x86_64″等;ia64和x86_64就说明这台机器是64位的;

[ec2-user@ipxxx ~]$ arch
x86_64

或者

[ec2-user@ipxxx ~]$ uname -m
x86_64

uname命令可以输出一组系统信息

[ec2-user@ipxxx ~]$ uname -a
Linux ip-xxx.ap-southeast-1.compute.internal 4.14.146-120.181.amzn2.x86_64 #1 SMP Fri Oct 18 17:01:06 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

 

#如何查看Linux操作系统版本?不同linux版本命令稍有不同,选择可以用的
[ec2-user@ipxxx ~] cat /proc/version
[ec2-user@ipxxx ~] uname -r
[ec2-user@ipxxx ~] lsb_release -a
[ec2-user@ipxxx ~] cat /etc/issue
[ec2-user@ipxxx ~] cat /etc/*release*
[ec2-user@ipxxx ~] less /etc/redhat-release

#linux查看内存信息
[ec2-user@ipxxx ~] cat /proc/meminfo

CentOS系统中常用查看系统信息和日志命令

 centos  CentOS系统中常用查看系统信息和日志命令已关闭评论
9月 042019
 

一、系统日志文件(可以通过cat或tail命令来查看)

/var/log/message # 系统启动后的信息和错误日志,是Red Hat Linux中最常用的日志之一

/var/log/secure # 与安全相关的日志信息

/var/log/maillog # 与邮件相关的日志信息

/var/log/cron # 与定时任务相关的日志信息

/var/log/spooler # 与UUCP和news设备相关的日志信息

/var/log/boot.log # 守护进程启动和停止相关的日志消息

二、系统信息

uname -a # 查看内核/操作系统/CPU信息

cat /etc/issue

cat /etc/redhat-release # 查看操作系统版本

cat /proc/cpuinfo  # 查看CPU信息

hostname # 查看计算机名

lspci -tv # 列出所有PCI设备

lsusb -tv # 列出所有USB设备

lsmod # 列出加载的内核模块

env # 查看环境变量

三、资源

free -m # 查看内存使用量和交换区使用量

df -h # 查看各分区使用情况

du -sh <目录名> # 查看指定目录的大小

grep MemTotal /proc/meminfo # 查看内存总量

grep MemFree /proc/meminfo # 查看空闲内存量

uptime # 查看系统运行时间、用户数、负载

cat /proc/loadavg # 查看系统负载

 

四、磁盘和分区

mount | column -t # 查看挂接的分区状态

fdisk -l # 查看所有分区

swapon -s # 查看所有交换分区

hdparm -i /dev/hda # 查看磁盘参数(仅适用于IDE设备)

dmesg | grep IDE # 查看启动时IDE设备检测状况

五、网络

ifconfig # 查看所有网络接口的属性

iptables -L # 查看防火墙设置

route -n # 查看路由表

netstat -lntp # 查看所有监听端口

netstat -antp # 查看所有已经建立的连接

netstat -s # 查看网络统计信息

六、进程

ps -ef # 查看所有进程

top # 实时显示进程状态(另一篇文章里面有详细的介绍)

七、用户 

w # 查看活动用户

id <用户名> # 查看指定用户信息

last # 查看用户登录日志

cut -d: -f1 /etc/passwd # 查看系统所有用户

cut -d: -f1 /etc/group # 查看系统所有组

crontab -l # 查看当前用户的计划任务

八、服务

chkconfig –list # 列出所有系统服务

chkconfig –list | grep on # 列出所有启动的系统服务

九、程序

rpm -qa # 查看所有安装的软件包

 

来自:https://blog.csdn.net/twc829/article/details/75284332

使用MYSQL命令查看MYSQL中数据库或表占用空间的大小

 mysql  使用MYSQL命令查看MYSQL中数据库或表占用空间的大小已关闭评论
3月 062019
 

知道每个数据库的大小,使用下面步骤:

1、进入information_schema 数据库

use information_schema;

 

2、根据表名汇总查询各表数据的大小:

select TABLE_SCHEMA as tablename, concat(round(sum(data_length/1024/1024/1024),3),’GB’) as data from tables group by TABLE_SCHEMA;

 

2、查看指定数据库的大小:

比如查看数据库mydb的大小

select concat(round(sum(data_length/1024/1024/1024),3),’GB’) as data from tables where table_schema=’mydb’;

 

4、查看指定数据库的某个表的大小

比如查看数据库mydb中 mytable 表的大小

select concat(round(sum(data_length/1024/1024),3),’MB’) as data from tables where table_schema=’mydb’ and table_name=’mytable’;

curl 查看某web页页面响应时间

 linux  curl 查看某web页页面响应时间已关闭评论
5月 232017
 

近日公司访问微信统一下单接口时间变长了, 通过下面的命令:

[o-u-u@vmhost ~]$   time curl -i -v -s \-o /dev/null \-w “\n\nhttp_code: %{http_code}s\nhttp_connect: %{http_connect}s\ncontent_type: %{content_type}s\ntime_namelookup: %{time_namelookup}s\ntime_redirect: %{time_redirect}s\ntime_pretransfer: %{time_pretransfer}s\ntime_connect: %{time_connect}s\ntime_starttransfer: %{time_starttransfer}s\ntime_total: %{time_total}s\nspeed_download: %{speed_download}KB/s\n” \https://api.mch.weixin.qq.com/pay/unifiedorder

返回结果:

* About to connect() to api.mch.weixin.qq.com port 443 (#0)
*   Trying 140.207.69.102… connected
* Connected to api.mch.weixin.qq.com (140.207.69.102) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* NSS: client certificate not found (nickname not specified)
* SSL connection using TLS_RSA_WITH_AES_256_CBC_SHA
* Server certificate:
*       subject: CN=payapp.weixin.qq.com,OU=R&D,O=Tencent Technology (Shenzhen) Company Limited,L=shenzhen,ST=guangdong,C=CN
*       start date: Mar 22 00:00:00 2017 GMT
*       expire date: Jun 21 23:59:59 2018 GMT
*       common name: payapp.weixin.qq.com
*       issuer: CN=GeoTrust SSL CA – G3,O=GeoTrust Inc.,C=US
> GET /pay/unifiedorder HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.16.2.3 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: api.mch.weixin.qq.com
> Accept: */*

< HTTP/1.1 200 OK
< Server: nginx
< Date: Tue, 23 May 2017 06:13:59 GMT
< Content-Type: text/plain
< Content-Length: 112
< Connection: keep-alive
< Keep-Alive: timeout=8

{ [data not shown]
* Connection #0 to host api.mch.weixin.qq.com left intact

http_code: 200s
http_connect: 000s
content_type: text/plains
time_namelookup: 15.015s
time_redirect: 0.000s
time_pretransfer: 15.180s
time_connect: 15.020s
time_starttransfer: 15.188s
time_total: 15.188s
speed_download: 7.000KB/s
* Closing connection #0

real    0m15.207s
user    0m0.076s
sys     0m0.091s

可以发现 time_namelookup: 15.015s  , 说明dns解析就花了15秒,问题找到。


******************************************************************************************************************

附:

关于curl  -w 参数下显示格式的参数有哪些(比如time_namelookup, time_pretransfer等),可参考这里:https://curl.haxx.se/docs/manpage.html


content_type The Content-Type of the requested document, if there was any.

filename_effective The ultimate filename that curl writes out to. This is only meaningful if curl is told to write to a file with the -O, –remote-name or -o, –output option. It’s most useful in combination with the -J, –remote-header-name option. (Added in 7.26.0)

ftp_entry_path The initial path curl ended up in when logging on to the remote FTP server. (Added in 7.15.4)

http_code The numerical response code that was found in the last retrieved HTTP(S) or FTP(s) transfer. In 7.18.2 the alias response_code was added to show the same info.

http_connect The numerical code that was found in the last response (from a proxy) to a curl CONNECT request. (Added in 7.12.4)

http_version The http version that was effectively used. (Added in 7.50.0)

local_ip The IP address of the local end of the most recently done connection – can be either IPv4 or IPv6 (Added in 7.29.0)

local_port The local port number of the most recently done connection (Added in 7.29.0)

num_connects Number of new connects made in the recent transfer. (Added in 7.12.3)

num_redirects Number of redirects that were followed in the request. (Added in 7.12.3)

proxy_ssl_verify_result The result of the HTTPS proxy’s SSL peer certificate verification that was requested. 0 means the verification was successful. (Added in 7.52.0)

redirect_url When an HTTP request was made without -L to follow redirects, this variable will show the actual URL a redirect would take you to. (Added in 7.18.2)

remote_ip The remote IP address of the most recently done connection – can be either IPv4 or IPv6 (Added in 7.29.0)

remote_port The remote port number of the most recently done connection (Added in 7.29.0)

scheme The URL scheme (sometimes called protocol) that was effectively used (Added in 7.52.0)

size_download The total amount of bytes that were downloaded.

size_header The total amount of bytes of the downloaded headers.

size_request The total amount of bytes that were sent in the HTTP request.

size_upload The total amount of bytes that were uploaded.

speed_download The average download speed that curl measured for the complete download. Bytes per second.

speed_upload The average upload speed that curl measured for the complete upload. Bytes per second.

ssl_verify_result The result of the SSL peer certificate verification that was requested. 0 means the verification was successful. (Added in 7.19.0)

time_appconnect The time, in seconds, it took from the start until the SSL/SSH/etc connect/handshake to the remote host was completed. (Added in 7.19.0)

time_connect The time, in seconds, it took from the start until the TCP connect to the remote host (or proxy) was completed.

time_namelookup The time, in seconds, it took from the start until the name resolving was completed.

time_pretransfer The time, in seconds, it took from the start until the file transfer was just about to begin. This includes all pre-transfer commands and negotiations that are specific to the particular protocol(s) involved.

time_redirect The time, in seconds, it took for all redirection steps include name lookup, connect, pretransfer and transfer before the final transaction was started. time_redirect shows the complete execution time for multiple redirections. (Added in 7.12.3)

time_starttransfer The time, in seconds, it took from the start until the first byte was just about to be transferred. This includes time_pretransfer and also the time the server needed to calculate the result.

time_total The total time, in seconds, that the full operation lasted.

url_effective The URL that was fetched last. This is most meaningful if you’ve told curl to follow location: headers.


查看Linux操作系统信息的相关命令

 linux  查看Linux操作系统信息的相关命令已关闭评论
12月 152016
 

记录下

# uname -a # 查看内核/操作系统/CPU信息 
# head  /etc/issue # 查看操作系统版本 
# cat /proc/cpuinfo # 查看CPU信息 
# hostname # 查看计算机名 
# lspci -tv # 列出所有PCI设备 
# lsusb -tv # 列出所有USB设备 
# lsmod # 列出加载的内核模块 
# env # 查看环境变量资源 
# free -m # 查看内存使用量和交换区使用量 
# df -h # 查看各分区使用情况 
# du -sh <目录名> # 查看指定目录的大小 
# grep MemTotal /proc/meminfo # 查看内存总量 
# grep MemFree /proc/meminfo # 查看空闲内存量 
# uptime # 查看系统运行时间、用户数、负载 
# cat /proc/loadavg # 查看系统负载磁盘和分区 
# mount | column -t # 查看挂接的分区状态 
# fdisk -l # 查看所有分区 
# swapon -s # 查看所有交换分区 
# hdparm -i /dev/hda # 查看磁盘参数(仅适用于IDE设备) 
# dmesg | grep IDE # 查看启动时IDE设备检测状况网络 
# ifconfig # 查看所有网络接口的属性 
# iptables -L # 查看防火墙设置 
# route -n # 查看路由表 
# netstat -lntp # 查看所有监听端口 
# netstat -antp # 查看所有已经建立的连接 
# netstat -s # 查看网络统计信息进程 
# ps -ef # 查看所有进程 
# top # 实时显示进程状态用户 
# w # 查看活动用户 
# id <用户名> # 查看指定用户信息 
# last # 查看用户登录日志 
# cut -d: -f1 /etc/passwd # 查看系统所有用户 
# cut -d: -f1 /etc/group # 查看系统所有组 
# crontab -l # 查看当前用户的计划任务服务 
# chkconfig –list # 列出所有系统服务 
# chkconfig –list | grep on # 列出所有启动的系统服务程序 
# rpm -qa # 查看所有安装的软件包

Linux下查看系统版本号信息的方法

 linux  Linux下查看系统版本号信息的方法已关闭评论
9月 142015
 

Linux下查看系统版本号信息的方法,记录下

一、查看Linux内核版本命令(两种方法):

1、cat /proc/version

[root@localhost ~]# cat /proc/version
Linux version 2.6.18-194.8.1.el5.centos.plus ([email protected]) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Wed Jul 7 11:50:45 EDT 2010

2、uname -a

[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.18-194.8.1.el5.centos.plus #1 SMP Wed Jul 7 11:50:45 EDT 2010 i686 i686 i386 GNU/Linux

二、查看Linux系统版本的命令(3种方法):

1、lsb_release -a,即可列出所有版本信息:

[root@localhost ~]# lsb_release -a
LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: CentOS
Description: CentOS release 5.5 (Final)
Release: 5.5
Codename: Final

这个命令适用于所有的Linux发行版,包括Redhat、SuSE、Debian…等发行版。

2、cat /etc/redhat-release,这种方法只适合Redhat系的Linux:

[root@localhost ~]# cat /etc/redhat-release
CentOS release 5.5 (Final)

3、cat /etc/issue,此命令也适用于所有的Linux发行版。

[root@localhost ~]# cat /etc/issue
CentOS release 5.5 (Final)
Kernel r on an m

转自http://www.ha97.com/2987.html