对 Linux 中级用户非常有用的 20 个命令(1)(2)
22. 命令: grep
‘grep‘命令搜索指定文件中包含给定字符串或者单词的行。举例搜索‘/etc/passwd‘文件中的‘tecmint'
- root@tecmint:~# grep tecmint /etc/passwd
- tecmint:x:1000:1000:Tecmint,,,:/home/tecmint:/bin/bash
使用’-i'选项将忽略大小写。
- root@tecmint:~# grep -i TECMINT /etc/passwd
- tecmint:x:1000:1000:Tecmint,,,:/home/tecmint:/bin/bash
使用’-r'选项递归搜索所有自目录下包含字符串 “127.0.0.1“.的行。
- root@tecmint:~# grep -r "127.0.0.1" /etc/
- /etc/vlc/lua/http/.hosts:127.0.0.1
- /etc/speech-dispatcher/modules/ivona.conf:#IvonaServerHost "127.0.0.1"
- /etc/mysql/my.cnf:bind-address = 127.0.0.1
- /etc/apache2/mods-available/status.conf: Allow from 127.0.0.1 ::1
- /etc/apache2/mods-available/ldap.conf: Allow from 127.0.0.1 ::1
- /etc/apache2/mods-available/info.conf: Allow from 127.0.0.1 ::1
- /etc/apache2/mods-available/proxy_balancer.conf:# Allow from 127.0.0.1 ::1
- /etc/security/access.conf:#+ : root : 127.0.0.1
- /etc/dhcp/dhclient.conf:#prepend domain-name-servers 127.0.0.1;
- /etc/dhcp/dhclient.conf:# option domain-name-servers 127.0.0.1;
- /etc/init/network-interface.conf: ifconfig lo 127.0.0.1 up || true
- /etc/java-6-openjdk/net.properties:# localhost & 127.0.0.1).
- /etc/java-6-openjdk/net.properties:# http.nonProxyHosts=localhost|127.0.0.1
- /etc/java-6-openjdk/net.properties:# localhost & 127.0.0.1).
- /etc/java-6-openjdk/net.properties:# ftp.nonProxyHosts=localhost|127.0.0.1
- /etc/hosts:127.0.0.1 localhost
注意:您还可以使用以下选项:
- -w 搜索单词 (egrep -w ‘word1|word2‘ /path/to/file).
- -c 用于统计满足要求的行 (i.e., total number of times the pattern matched) (grep -c ‘word‘ /path/to/file).
- –color 彩色输出 (grep –color server /etc/passwd).
23. 命令: man
‘man‘是系统帮助页。Man提供命令所有选项及用法的在线文档。几乎所有的命令都有它们的帮助页,例如:
- root@tecmint:~# man man
- MAN(1) Manual pager utils MAN(1)
- NAME
- man - an interface to the on-line reference manuals
- SYNOPSIS
- man [-C file] [-d] [-D] [--warnings[=warnings]] [-R encoding] [-L locale] [-m system[,...]] [-M path] [-S list] [-e extension] [-i|-I]
- [--regex|--wildcard] [--names-only] [-a] [-u] [--no-subpages] [-P pager] [-r prompt] [-7] [-E encoding] [--no-hyphenation] [--no-justification] [-p
- string] [-t] [-T[device]] [-H[browser]] [-X[dpi]] [-Z] [[section] page ...] ...
- man -k [apropos options] regexp ...
- man -K [-w|-W] [-S list] [-i|-I] [--regex] [section] term ...
- man -f [whatis options] page ...
- man -l [-C file] [-d] [-D] [--warnings[=warnings]] [-R encoding] [-L locale] [-P pager] [-r prompt] [-7] [-E encoding] [-p string] [-t] [-T[device]]
- [-H[browser]] [-X[dpi]] [-Z] file ...
- man -w|-W [-C file] [-d] [-D] page ...
- man -c [-C file] [-d] [-D] page ...
- man [-hV]
上面是man命令的系统帮助页,类似的有cat和ls的帮助页。
注意:系统帮助页是为了命令的使用和学习而设计的。
评论暂时关闭