linux命令格式,linux命令行usage格式解释

点击量:3979

经常要在Linux下面敲指令,但指令太多很多是忘了记,记了又忘。其实这些指令不用一个一个去记,每一个命令都会有帮助和提示。之前我一看到这些提示就头大,什么方括号,尖括号,省略号,杠之类的,今天静下心来专门学习这个东西,了解完之后发现还是比较简单的,这样遇到新的命令自己学习一下就知道如何使用了,不用再去一个一个查询和记忆了。

帮助的格式一般分以下几种:

方括号[]:表示可选参数,也就是说可以忽略,使用时没有方括号。

尖括号<>:表示必选参数,不能忽略,且尖括号里的输入只能是指定的option,使用时没有尖括号。

省略号…:表示重复多次的参数。

接下来我们以jstat为例,学习如何通过以上几个格式的含义一步步来学习使用一个新的指令。jstat是JDK下面一个用于监控JVM内存使用情况的轻量级工具,我们在命令行下面输入jstat时会输出以下信息,我们一行一行看。

[astd@VM_139_5_tlinux ~]$ jstat

invalid argument count【1】

Usage: jstat -help|-options【2】

jstat - [-t] [-h] [ []]【3】

Definitions:【4】

An option reported by the -options option【5】

Virtual Machine Identifier. A vmid takes the following form:[@[:]] Where is the local vm identifier for the target Java virtual machine, typically a process id; is the name of the host running the target Java virtual machine;and is the port number for the rmiregistry on the target host. See the jvmstat documentation for a more complete description of the Virtual Machine Identifier.【6】

Number of samples between header lines.【7】

Sampling interval. The following forms are allowed:[“ms”|”s”]【8】

Where is an integer and the suffix specifies the units as milliseconds(“ms”) or seconds(“s”). The default units are “ms”.【9】

Number of samples to take before terminating.【10】

-J Pass directly to the runtime system.【11】

【1】:告诉你count这个参数不合法

【2】:使用方法是jstat -help 或者jstat-options。

【3】:这个就是这个指令具体的格式了,jstat - [-t] [-h] [ []]。首先必须有参数-,这里的option的值在【5】中有了说明,即通过jstat -options获得。接下来是一个可选参数-t,没有说明,试了一下发现是在输出的头部显示时间戳。然后是可选参数-h,【7】对这个有解释:字面很难翻译准确,等会儿用例子解释下就明白了。接下来是一个必选参数虚拟机的id,最常见的是进程号也就是pid。然后是可选参数[ []],interval是监控刷新的时间间隔,该参数后还可以接m/ms,表示时间的单位是秒或者毫秒,count则是显示的数量。一个看似很复杂的指令就这样解析完了,挺简单的吧。

我们用几个组合试试吧。

jstat -options

jstat -gcutil  18064 1000 10000

jstat -gcutil  -h2 18064 1000 10000

jstat -gcutil -t -h2 18064 1000 10000

$ jstat -options

-class

-compiler

-gc

-gccapacity

-gccause

-gcnew

-gcnewcapacity

-gcold

-gcoldcapacity

-gcpermcapacity

-gcutil

-printcompilation

$ jstat -gcutil 18064 1000 10000

S0 S1 E O P YGC YGCT FGC FGCT GCT

1.08 0.00 69.12 92.86 55.28 88136 827.589 11692 1777.799 2605.388

1.08 0.00 71.55 92.86 55.28 88136 827.589 11692 1777.799 2605.388

1.08 0.00 72.24 92.86 55.28 88136 827.589 11692 1777.799 2605.388

$ jstat -gcutil -h2 18064 1000 10000

S0 S1 E O P YGC YGCT FGC FGCT GCT

0.85 0.00 41.33 92.86 55.28 88138 827.610 11710 1780.803 2608.412

0.85 0.00 43.97 92.86 55.28 88138 827.610 11710 1780.803 2608.412

S0 S1 E O P YGC YGCT FGC FGCT GCT

0.85 0.00 44.60 92.86 55.28 88138 827.610 11710 1780.803 2608.412

0.85 0.00 47.03 92.86 55.28 88138 827.610 11710 1780.803 2608.412

$ jstat -gcutil -t -h2 18064 1000 10000

Timestamp S0 S1 E O P YGC YGCT FGC FGCT GCT

1982902.1 0.00 1.12 65.73 92.86 55.28 88137 827.601 11702 1779.541 2607.141

1982903.1 0.00 1.12 67.50 92.86 55.28 88137 827.601 11702 1779.541 2607.141

Timestamp S0 S1 E O P YGC YGCT FGC FGCT GCT

1982904.1 0.00 1.12 68.95 92.86 55.28 88137 827.601 11702 1779.541 2607.141

1982905.1 0.00 1.12 70.66 92.86 55.28 88137 827.601 11702 1779.541 2607.141

Timestamp S0 S1 E O P YGC YGCT FGC FGCT GCT

1982906.1 0.00 1.12 72.14 92.86 55.28 88137 827.601 11702 1779.541 2607.141

1982907.1 0.00 1.12 73.99 92.86 55.28 88137 827.601 11702 1779.541 2607.141

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值