包含标签 Linux articles

7z

7z

拥有极高压缩比的开源压缩软件。

安装

在 Linux 中输入以下命令安装 7-Zip。

1
2
3
# Ubuntu 系统
apt-get update
apt-get install p7zip-full -y

实例

介绍几个常用场景:解压、压缩、查看(压缩包内容)。

1、将压缩文件 text.7z 在当前目录下解压缩。

1
7z x text.7z

2、将压缩文件 text.7z 在指定目录(/home/text)下解压缩。

1
2
# 注意 -o 用来指定解压缩文件存放目录,-o 后是没有空格的,直接接目录
7z x text.7z -r -o/home/text

3、将文件 /home/text 压缩成 text.7z。

……

Continue reading

ab

ab

Apache服务器的性能测试工具

补充说明

ab命令 是一个测试你 Apache http 服务器的工具,你可以通过这个工具,指定一个单位时间内向 apache 发出的请求数量来看看你的 Apache 和机器配合的性能如何。

语法

1
2
3
4
5
6
7
ab [ -A auth-username:password ] [ -c concurrency ] [ -C cookie-name=value
] [ -d ] [ -e csv-file ] [ -g gnuplot-file ] [ -h ] [ -H custom-header ] [
-i  ]  [  -k  ]  [  -n  requests  ] [ -p POST-file ] [ -P proxy-auth-user‐
name:password ] [ -q ] [ -s ] [ -S ] [ -t timelimit ] [ -T content-type  ]
[  -v verbosity] [ -V ] [ -w ] [ -x <table>-attributes ] [ -X proxy[:port]
]  [  -y  <tr>-attributes  ]  [  -z   <td>-attributes   ]   [http://]host‐
name[:port]/path

选项

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
-A auth-username:password
      #  支持基本的验证证书,用户名和密码之间使用"冒号"                    :
      # 分隔开,ab将以明文方式传送过去.不管服务器是不是需要
      # ,也就是说你的服务器需要支持401认证.

-c concurrency
      # 同时向服务器端发送的请求数目,默认状态下是一次 只执行一个http请求.

-C cookie-name=value
      # Add a Cookie: line to the request. The argument is typically in the
      # form of a name=value pair. This field is repeatable.

-d    #  Do not display  the  "percentage  served  within  XX  [ms]  table".
      # (legacy support).

-e csv-file
      # Write  a  Comma  separated value (CSV) file which contains for each
      # percentage (from 1% to 100%) the time (in milli seconds) it took to
      # serve  that percentage of the requests. This is usually more useful
      # than the 'gnuplot' file; as the results are already 'binned'.

-g gnuplot-file
      # Write all measured values out as a 'gnuplot' or TSV  (Tab  separate
      # values)  file.  This file can easily be imported into packages like
      # Gnuplot, IDL, Mathematica, Igor or even Excell. The labels  are  on
      # the first line of the file.
-h    # 显示使用说明
-H custom-header
      # 向请求包追加附加的标题字串.此参数应该是有效的标题         行(header
      # line)形式,通常使用冒号":"来分隔有效配对 (valid  pair)例如  'Accept-
      # Encoding: zip/zop;8 bit';

-i    # 使用一个 http 头(HEAD) 来替换 GET方法.不可以掺入POST 方法

-k    #  允许http      KeepAlive      ;也就是说执行多个请求在一个      http
      # 会话当中,默认是不允许的也就是no KeepAlive啦;)

-n requests
      # 执行一次测试会话的时候所发出的请求数目,默认是执行一个单一的请求
      # 当然了这样的测试结果也就没什么意义了

-p POST-file
      # 测试程序也就是ab,将向Apache server发送带有HTTP POST 的请求.

-P proxy-auth-username:password
      # 当需要通过代理测试一台 HTTP 服务器的时候而你的代理
      # 又需要用户名密码验证,这时你可以使用这个选项,同样
      # 用户名与密码之间使用冒号":"分隔开,ab将之以明文的方式
      # 发送出去,当然,前提是你的代理是处于407认证状态的

-q    #  When processing more than 150 requests, ab outputs a progress count
      # on  stderr  every  10% or 100 requests or so. The -q flag will sup‐
      # press these messages.

-s    #  When compiled in (ab -h will show you) use the SSL protected  https
      # rather  than  the  http  protocol. This feature is experimental and
      # very rudimentary. You probably do not want to use it.

-S    #  Do not display the median and standard deviation values,  nor  dis‐
      # play  the  warning/error  messages  when the average and median are
      # more than one or two times the standard deviation  apart.  And  de‐
      # fault to the min/avg/max values. (legacy support).

-t timelimit
      #  设置测试的时间的长短,使用这个选项ab将自动设置
      # 测试请求会话数目为50000,然后以你设置的时间为
      # 固定周期.默认状态下是没有时限的,也就是直到完成
      # 你所设置的请求数目为止.

-T content-type
      # 内容类型标头,使用在POST数据的时候.

-v verbosity
      # 设置冗余级别,4级打印出每个请求标头的详细信息,
      # 3级打印出回应代码(例如,404,200),2级打印出警告 信息和指示消息

-V    # 显示版本号并且退出
-w    # 打印输出结果到HTML表中. 默认的表是两列n行白底黑框

-x <table>-attributes
      # 使用字串来描述表的属性,该属性字串应该插入到<table 这里 >

-X proxy[:port]
      # Use a proxy server for the requests.

-y <tr>-attributes
      # 用于生成html表格每行的属性名 (<tr>)

-z <td>-attributes
      # 用于生成html表格每列的属性名 (<td>)

参数

主机:被测试主机。

……

Continue reading

accept

accept

指示打印系统接受发往指定目标打印机的打印任务

补充说明

accept命令 属于CUPS套件,用于指示打印系统接受发往指定目标打印机的打印任务。

语法

accept(选项)(参数)

选项

-E:当连接到服务器时强制加密;
-U:指定连接服务器时使用的用户名;
-h:指定连接服务器名和端口号。

参数

目标:指定目标打印机。

……

Continue reading

ack

ack

比grep好用的文本搜索工具

安装

1
2
3
4
# ubuntu下要安装ack-grep,因为在debian系中,ack这个名字被其他的软件占用了。
sudo apt-get install ack-grep
# alpine Linux-apk软件包管理器 安装 ack
apk install ack

参数

这些参数在linux上的适用频率是相当高的,尤其是你用vim做为IDE的话

……

Continue reading

ag

ag

ack 的升级版,C语言编写,更快更人性化

补充说明

ag命令 它比ack快一个数量级。它会忽略 .gitignore 和 .hgignore 中的文件模式。如果源代码库中有您不想搜索的文件,只需将它们的模式添加到 .ignore 文件即可。命令名称比 ack 短 33%,并且所有键都在 home 行! Github-参考链接

语法

1
2
ag [options] pattern [path ...]
ag [可选项] 匹配模式 [路径...]

选项

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
Output Options:
     --ackmate            以 AckMate-parseable 的格式显示结果
  -A --after [LINES]      显示匹配行之后的行(默认2行)
  -B --before [LINES]     显示匹配行之前的行(默认2行)
     --[no]break          不同文件中匹配到的内容新建一行显示(默认开启)
  -c --count              只显示每个文件中匹配到的数量
                          (This often differs from the number of matching lines)
     --[no]color          Print color codes in results (Enabled by default)
     --color-line-number  Color codes for line numbers (Default: 1;33)
     --color-match        Color codes for result match numbers (Default: 30;43)
     --color-path         Color codes for path names (Default: 1;32)
     --column             Print column numbers in results
     --[no]filename       Print file names (Enabled unless searching a single file)
  -H --[no]heading        在每个文件匹配前输出文件名(默认开启)
  -C --context [LINES]    显示匹配行上下两行(默认2行)
     --[no]group          Same as --[no]break --[no]heading
  -g --filename-pattern PATTERN
                          Print filenames matching PATTERN
  -l --files-with-matches 显示包含匹配的文件名(不显示匹配的行)
  -L --files-without-matches  只显示不包含匹配项的文件名
     --print-all-files    Print headings for all files searched, even those that
                          don\'t contain matches
     --[no]numbers        Print line numbers. Default is to omit line numbers
                          when searching streams
  -o --only-matching      只输出每行匹配的部分
     --print-long-lines   Print matches on very long lines (Default: >2k characters)
     --passthrough        When searching a stream, print all lines even if they
                          don\'t match
     --silent             Suppress all log messages, including errors
     --stats              Print stats (files scanned, time taken, etc.)
     --stats-only         Print stats and nothing else.
                          (Same as --count when searching a single file)
     --vimgrep            Print results like vim\'s :vimgrep /pattern/g would
                          (it reports every match on the line)
  -0 --null --print0      Separate filenames with null (for 'xargs -0')

Search Options:
  -a --all-types          搜索所有文件(包括隐藏文件)
  -D --debug              Ridiculous debugging (probably not useful)
     --depth NUM          目录搜索最大深度(默认25)
  -f --follow             跟随链接进行搜索
  -F --fixed-strings      Alias for --literal for compatibility with grep
  -G --file-search-regex  根据正则匹配搜索指定类型的文件
     --hidden             Search hidden files (obeys .*ignore files)
  -i --ignore-case        Match case insensitively
     --ignore PATTERN     Ignore files/directories matching PATTERN
                          (literal file/directory names also allowed)
     --ignore-dir NAME    Alias for --ignore for compatibility with ack.
  -m --max-count NUM      在一个文件中最大匹配的数量(默认: 10,000)
     --one-device         不跟随其他设备的链接搜索
  -p --path-to-ignore STRING
                          Use .ignore file at STRING
  -Q --literal            Don\'t parse PATTERN as a regular expression
  -s --case-sensitive     Match case sensitively
  -S --smart-case         Match case insensitively unless PATTERN contains
                          uppercase characters (Enabled by default)
     --search-binary      搜索二进制文件
  -t --all-text           搜索所有文本文件(不包括隐藏文件)
  -u --unrestricted       搜索所有文件 (忽略 .ignore, .gitignore, etc.;
                          搜索二进制和隐藏文件)
  -U --skip-vcs-ignores   Ignore VCS ignore files
                          (.gitignore, .hgignore; still obey .ignore)
  -v --invert-match       反向匹配
  -w --word-regexp        只匹配整个单词
  -W --width NUM          Truncate match lines after NUM characters
  -z --search-zip         搜索压缩文件中的内容

File Types:
The search can be restricted to certain types of files. Example:
  ag --html needle   结果输出到指定类型文件
  - Searches for 'needle' in files with suffix .htm, .html, .shtml or .xhtml.

For a list of supported file types run:
  ag --list-file-types  列出支持的文件类型

实例

列出当前目录下包含 npm 的文件

……

Continue reading

alias

alias

定义或显示别名。

概要

1
alias [-p] [name[=value] ...]

主要用途

  • 简化较长的命令。
  • 定义一个或多个别名。
  • 修改一个或多个已定义别名的值。
  • 显示一个或多个已定义别名。
  • 显示全部已定义的别名。

选项

1
2
3
-p:显示全部已定义的别名。
name(可选):指定要(定义、修改、显示)的别名。
value(可选):别名的值。

返回值

alias 返回 true 除非您要显示的别名未定义。

例子

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# 显示全部已定义的别名
alias
alias -p

# 显示已定义的别名(假设当前环境存在以下别名)
alias ls
alias ls grep

# 定义或修改别名的值
alias ls='ls --color=auto'
alias ls='ls --color=never' grep='grep --color=never'

知识点

直接在shell里设定的命令别名,在终端关闭或者系统重新启动后都会失效,如何才能永久有效呢?

……

Continue reading

apachectl

apachectl

Apache服务器前端控制工具

补充说明

apachectl命令 是Apache的Web服务器前端控制工具,用以启动、关闭和重新启动Web服务器进程。

语法

apachectl(参数)

参数

  • configtest:检查设置文件中的语法是否正确;
  • fullstatus:显示服务器完整的状态信息;
  • graceful:重新启动Apache服务器,但不会中断原有的连接;
  • help:显示帮助信息;
  • restart:重新启动Apache服务器;
  • start:启动Apache服务器;
  • status:显示服务器摘要的状态信息;
  • stop:停止Apache服务器。
……

Continue reading

apk

apk

Alpine Linux 下的包管理工具

使用实例

1
2
3
4
5
6
apk install xxx
apk search xxx # 支持正则
apk info xxx # 查看包的详细信息
apk show # list local package
# 卸载并删除 包
apk del openssh openntp vim

升级

upgrade命令升级系统已安装的所以软件包(一般包括内核),当然也可指定仅升级部分软件包(通过-u或–upgrade选择指定)。

1
2
3
apk update # 更新最新本地镜像源
apk upgrade # 升级软件
apk add --upgrade busybox # 指定升级部分软件包

搜索

1
2
3
4
apk search # 查找所以可用软件包
apk search -v # 查找所以可用软件包及其描述内容
apk search -v 'acf*' # 通过软件包名称查找软件包
apk search -v -d 'docker' # 通过描述文件查找特定的软件包

查看包信息

info命令用于显示软件包的信息。

……

Continue reading

apropos

apropos

在 whatis 数据库中查找字符串

补充说明

apropos命令 在一些特定的包含系统命令的简短描述的数据库文件里查找关键字,然后把结果送到标准输出。 

如果你不知道完成某个特定任务所需要命令的名称,可以使用一个关键字通过Linux apropos实用程序来搜索它。该实用程序可以搜索关键字并且显示所有包含匹配项的man页面的简短描述。另外,使用man实用程序和-k(关键字)选项,可以得到和用Linux apropos实用程序相同的结果(实际上是相同的命令)。

……

Continue reading

apt-get

apt-get

Debian Linux发行版中的APT软件包管理工具

补充说明

apt-get命令 是Debian Linux发行版中的APT软件包管理工具。所有基于Debian的发行都使用这个包管理系统。deb包可以把一个应用的文件包在一起,大体就如同Windows上的安装文件。

语法

1
apt-get [OPTION] PACKAGE

选项

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
apt-get install  # 安装新包
apt-get remove   # 卸载已安装的包(保留配置文件)
apt-get purge    # 卸载已安装的包(删除配置文件)
apt-get update   # 更新软件包列表
apt-get upgrade  # 更新所有已安装的包
apt-get autoremove   # 卸载已不需要的包依赖
apt-get dist-upgrade # 自动处理依赖包升级
apt-get autoclean    # 将已经删除了的软件包的.deb安装文件从硬盘中删除掉
apt-get clean        # 删除软件包的安装包

-c:指定配置文件。

参数

  • 管理指令:对APT软件包的管理操作;
  • 软件包:指定要操纵的软件包。

实例

使用apt-get命令的第一步就是引入必需的软件库,Debian的软件库也就是所有Debian软件包的集合,它们存在互联网上的一些公共站点上。把它们的地址加入,apt-get就能搜索到我们想要的软件。/etc/apt/sources.list是存放这些地址列表的配置文件,其格式如下:

……

Continue reading