grep 第四天
grep 第四天
1 使用grep 取 passwd 显示行数
grep -c '' /etc/passwd
[root@master ~]# grep -c '' /etc/passwd
135
2 使用grep 取passwd 显示行号
grep -n '' /etc/passwd
[root@master ~]# grep -n '' /etc/passwd
1:root:x:0:0:root:/root:/bin/bash
2:bin:x:1:1:bin:/bin:/sbin/nologin
3:daemon:x:2:2:daemon:/sbin:/sbin/nologin
4:adm:x:3:4:adm:/var/adm:/sbin/nologin
5:lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
6:sync:x:5:0:sync:/sbin:/bin/sync
7:shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
8:halt:x:7:0:halt:/sbin:/sbin/halt
9:mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
10:operator:x:11:0:operator:/root:/sbin/nologin
11:games:x:12:100:games:/usr/games:/sbin/nologin
12:ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
13:nobody:x:99:99:Nobody:/:/sbin/nologin
14:avahi-autoipd:x:170:170:Avahi IPv4LL Stack:/var/lib/avahi-autoipd:/sbin/nologin
15:dbus:x:81:81:System message bus:/:/sbin/nologin
16:polkitd:x:999:998:User for polkitd:/:/sbin/nologin
17:tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
18:postfix:x:89:89::/var/spool/postfix:/sbin/nologin
19:sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
20:wang:x:1000:1000:wang:/home/wang:/bin/bash
21:systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
22:it101:x:1001:1001::/home/it101:/bin/bash
23:it1:x:1002:1002::/home/it1:/bin/bash
24:it2:x:1003:1003::/home/it2:/bin/bash
25:it3:x:1004:1004::/home/it3:/bin/bash
26:it4:x:1005:1005::/home/it4:/bin/bash
27:it5:x:1006:1006::/home/it5:/bin/bash
28:it6:x:1007:1007::/home/it6:/bin/bash
29:it7:x:1008:1008::/home/it7:/bin/bash
30:it8:x:1009:1009::/home/it8:/bin/bash
31:it9:x:1010:1010::/home/it9:/bin/bash
32:it10:x:1011:1011::/home/it10:/bin/bash
33:it11:x:1012:1012::/home/it11:/bin/bash
34:it12:x:1013:1013::/home/it12:/bin/bash
35:it13:x:1014:1014::/home/it13:/bin/bash
36:it14:x:1015:1015::/home/it14:/bin/bash
37:it15:x:1016:1016::/home/it15:/bin/bash
38:it16:x:1017:1017::/home/it16:/bin/bash
39:it17:x:1018:1018::/home/it17:/bin/bash
40:it18:x:1019:1019::/home/it18:/bin/bash
41:it19:x:1020:1020::/home/it19:/bin/bash
42:it20:x:1021:1021::/home/it20:/bin/bash
43:it21:x:1022:1022::/home/it21:/bin/bash
44:it22:x:1023:1023::/home/it22:/bin/bash
45:it23:x:1024:1024::/home/it23:/bin/bash
46:it24:x:1025:1025::/home/it24:/bin/bash
47:it25:x:1026:1026::/home/it25:/bin/bash
48:it26:x:1027:1027::/home/it26:/bin/bash
49:it27:x:1028:1028::/home/it27:/bin/bash
50:it28:x:1029:1029::/home/it28:/bin/bash
51:it29:x:1030:1030::/home/it29:/bin/bash
52:it30:x:1031:1031::/home/it30:/bin/bash
53:it31:x:1032:1032::/home/it31:/bin/bash
54:it32:x:1033:1033::/home/it32:/bin/bash
55:it33:x:1034:1034::/home/it33:/bin/bash
56:it34:x:1035:1035::/home/it34:/bin/bash
57:it35:x:1036:1036::/home/it35:/bin/bash
58:it36:x:1037:1037::/home/it36:/bin/bash
59:it37:x:1038:1038::/home/it37:/bin/bash
60:it38:x:1039:1039::/home/it38:/bin/bash
61:it39:x:1040:1040::/home/it39:/bin/bash
62:it40:x:1041:1041::/home/it40:/bin/bash
63:it41:x:1042:1042::/home/it41:/bin/bash
64:it42:x:1043:1043::/home/it42:/bin/bash
65:it43:x:1044:1044::/home/it43:/bin/bash
66:it44:x:1045:1045::/home/it44:/bin/bash
67:it45:x:1046:1046::/home/it45:/bin/bash
68:it46:x:1047:1047::/home/it46:/bin/bash
69:it47:x:1048:1048::/home/it47:/bin/bash
70:it48:x:1049:1049::/home/it48:/bin/bash
71:it49:x:1050:1050::/home/it49:/bin/bash
72:it50:x:1051:1051::/home/it50:/bin/bash
73:it51:x:1052:1052::/home/it51:/bin/bash
74:it52:x:1053:1053::/home/it52:/bin/bash
75:it53:x:1054:1054::/home/it53:/bin/bash
76:it54:x:1055:1055::/home/it54:/bin/bash
77:it55:x:1056:1056::/home/it55:/bin/bash
78:it56:x:1057:1057::/home/it56:/bin/bash
79:it57:x:1058:1058::/home/it57:/bin/bash
80:it58:x:1059:1059::/home/it58:/bin/bash
81:it59:x:1060:1060::/home/it59:/bin/bash
82:it60:x:1061:1061::/home/it60:/bin/bash
83:it61:x:1062:1062::/home/it61:/bin/bash
84:it62:x:1063:1063::/home/it62:/bin/bash
85:it63:x:1064:1064::/home/it63:/bin/bash
86:it64:x:1065:1065::/home/it64:/bin/bash
87:it65:x:1066:1066::/home/it65:/bin/bash
88:it66:x:1067:1067::/home/it66:/bin/bash
89:it67:x:1068:1068::/home/it67:/bin/bash
90:it68:x:1069:1069::/home/it68:/bin/bash
91:it69:x:1070:1070::/home/it69:/bin/bash
92:it70:x:1071:1071::/home/it70:/bin/bash
93:it71:x:1072:1072::/home/it71:/bin/bash
94:it72:x:1073:1073::/home/it72:/bin/bash
95:it73:x:1074:1074::/home/it73:/bin/bash
96:it74:x:1075:1075::/home/it74:/bin/bash
97:it75:x:1076:1076::/home/it75:/bin/bash
98:it76:x:1077:1077::/home/it76:/bin/bash
99:it77:x:1078:1078::/home/it77:/bin/bash
100:it78:x:1079:1079::/home/it78:/bin/bash
101:it79:x:1080:1080::/home/it79:/bin/bash
102:it80:x:1081:1081::/home/it80:/bin/bash
103:it81:x:1082:1082::/home/it81:/bin/bash
104:it82:x:1083:1083::/home/it82:/bin/bash
105:it83:x:1084:1084::/home/it83:/bin/bash
106:it84:x:1085:1085::/home/it84:/bin/bash
107:it85:x:1086:1086::/home/it85:/bin/bash
108:it86:x:1087:1087::/home/it86:/bin/bash
109:it87:x:1088:1088::/home/it87:/bin/bash
110:it88:x:1089:1089::/home/it88:/bin/bash
111:it89:x:1090:1090::/home/it89:/bin/bash
112:it90:x:1091:1091::/home/it90:/bin/bash
113:it91:x:1092:1092::/home/it91:/bin/bash
114:it92:x:1093:1093::/home/it92:/bin/bash
115:it93:x:1094:1094::/home/it93:/bin/bash
116:it94:x:1095:1095::/home/it94:/bin/bash
117:it95:x:1096:1096::/home/it95:/bin/bash
118:it96:x:1097:1097::/home/it96:/bin/bash
119:it97:x:1098:1098::/home/it97:/bin/bash
120:it98:x:1099:1099::/home/it98:/bin/bash
121:it99:x:1100:1100::/home/it99:/bin/bash
122:it100:x:1101:1101::/home/it100:/bin/bash
123:apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
124:oldboy01:x:1102:1103::/home/oldboy01:/bin/bash
125:oldboy02:x:1103:1104::/home/oldboy02:/bin/bash
126:oldboy03:x:1104:1105::/home/oldboy03:/bin/bash
127:oldboy04:x:1105:1106::/home/oldboy04:/bin/bash
128:oldboy05:x:1106:1107::/home/oldboy05:/bin/bash
129:oldboy06:x:1107:1108::/home/oldboy06:/bin/bash
130:oldboy07:x:1108:1109::/home/oldboy07:/bin/bash
131:oldboy08:x:1109:1110::/home/oldboy08:/bin/bash
132:oldboy09:x:1110:1111::/home/oldboy09:/bin/bash
133:oldboy10:x:1111:1112::/home/oldboy10:/bin/bash
134:mailuser:x:1112:1113::/home/mailuser:/bin/bash
135:oldboy:x:1113:1114::/home/oldboy:/bin/bash
3 统计test信息在文件中出现了几次
grep -c 'test' file
[root@master ~]# grep -c 'test' file
0
4 显示/etc/inittab中包含了:一个数字:(即两个冒号中间一个数字)的行
egrep ':[0-9]+' /etc/inittab
grep ':[0-9]' /etc/inittab
5 显示/etc/passwd中以nologin结尾的行
grep 'nologin$' /etc/passwd
[root@master ~]# grep 'nologin$' /etc/passwd
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
avahi-autoipd:x:170:170:Avahi IPv4LL Stack:/var/lib/avahi-autoipd:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
6 显示 /etc/httpd/httpd.conf 注释的行取出来
grep '^#' /etc/httpd/httpd.conf
经查实centos7.4的httpd目录有变化
find / -name 'httpd.conf'
/etc/httpd/conf/httpd.conf
[root@master ~]# grep '^#' /etc/httpd/conf/httpd.conf
#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do. They're here only as hints or reminders. If you are unsure
# consult the online docs. You have been warned.
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path. If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so 'log/access_log'
# with ServerRoot set to '/www' will be interpreted by the
# server as '/www/log/access_log', where as '/log/access_log' will be
# interpreted as '/log/access_log'.
#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path. If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on the
# Mutex directive, if file-based mutexes are used. If you wish to share the
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition. These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#
#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed. This address appears on some server-generated pages, such
# as error documents. e.g. admin@your-domain.com
#
#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
#
# Relax access to content within /var/www.
#
# Further relax access to the default document root:
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here. If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
#
# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
#
# Specify a default charset for all content served; this enables
# interpretation of all content as UTF-8 by default. To use the
# default browser choice (ISO-8859-1), or to allow the META tags
# in HTML content to override this choice, comment out this
# directive:
#
#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
#
#
# EnableMMAP and EnableSendfile: On systems that support it,
# memory-mapping or the sendfile syscall may be used to deliver
# files. This usually improves server performance, but must
# be turned off when serving from networked-mounted
# filesystems or if support for these functions is otherwise
# broken on your system.
# Defaults if commented: EnableMMAP On, EnableSendfile Off
#
#EnableMMAP off
# Supplemental configuration
#
# Load config files in the "/etc/httpd/conf.d" directory, if any.
7 .统计/etc/services文件中有井号开头的行
grep -c '^#' /etc/services
[root@master ~]# grep -c '^#' /etc/services
102
grep 第四天的更多相关文章
- TCP/IP三次握手与四次挥手
三次握手: TCP(Transmission Control Protocol) 传输控制协议 TCP是主机对主机层的传输控制协议,提供可靠的连接服务,采用三次握手确认建立一个连接 位码即tcp标志位 ...
- 31.TCP/IP 三次握手与四次挥手
TCP/IP三次握手 TCP建立连接为什么是三次握手,而不是两次或四次? TCP,名为传输控制协议,是一种可靠的传输层协议,IP协议号为6. 顺便说一句,原则上任何数据传输都无法确保绝对可靠,三次握手 ...
- Linux的文件搜索命令(locate ,find,grep,find命令和)
刚开始学Linux,这是关于Linux文件搜索命令,就目前,尽我所能把他写全一点,后期随时补充 文件搜索命令 一.locate命令 二.find命令 三.grep命令 四.find命令和grep命令的 ...
- 真的懂了:TCP协议中的三次握手和四次挥手(关闭连接时, 当收到对方的FIN报文时, 仅仅表示对方不在发送数据了, 但是还能接收数据, 己方也未必全部数据都发送对方了。相当于一开始还没接上话不要紧,后来接上话以后得让人把话讲完)
一.TCP报文格式 下面是TCP报文格式图: (1) 序号, Seq(Sequence number), 占32位,用来标识从TCP源端向目的端发送的字节流,发起方发送数据时对此进行标记. (2) 确 ...
- 学习MFS(四)
一.搭建Master Server 1.安装相关编译器.工具包 [root@master ~]# yum -y install gcc gcc-c++ zlib-devel 2.创建进程用户 [roo ...
- FastDFS+Nginx(单点部署)事例
FastDFS是由淘宝的余庆先生所开发,是一个轻量级.高性能的开源分布式文件系统,用纯C语言开发,包括文件存储.文件同步.文件访问(上传.下载).存取负载均衡.在线扩容.相同内容只存储一份等功能,适合 ...
- Web服务之LNMMP架构及动静分离实现
原文链接:http://hoolee.blog.51cto.com/7934938/1413346 讲的非常详细,尽管我只看动静分离,可是看了一下其他的部署,也是非常不错,适合新手 一.LNMMP ...
- linux---mysql安装
一.查询本机是否有mysql service mysql status 二.检查已安装的mysql版本 mysql –uroot -p status 三.查看已安装的mysql的组件 dpkg --g ...
- centos 命令大全
文件操作: ls ####查看目录中的文件#### ls -F ####查看目录中的文件#### ls -l ####显示文件和目录的详细资料#### ls -a ...
- nginx配置负载
一.系统优化 1.修改/etc/sysctl.conf,优化tcp连接数 net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_keepalive_time = 120 ...
随机推荐
- 超简单实用的4个PPT操作技巧
作为我们IT岗位的兄弟姐妹们,一定少不了各种PPT的展示,很多IT大佬总是不屑于PPT的美观,认为只要演讲有干货,格式无所谓,甚至都不需要PPT. 话是这样说,但其实无非就是觉得调整美化实在是浪费时间 ...
- 《ASP.NET Core 与 RESTful API 开发实战》-- (第7章)-- 读书笔记(上)
第 7 章 高级主题 7.1 缓存 缓存是一种通过存储资源的备份,在请求时返回资源备份的技术.ASP.NET Core 支持多种形式的缓存,既支持基于 HTTP 的缓存,也支持内存缓存和分布式缓存,还 ...
- C# 二十年语法变迁之 C# 8参考
C# 二十年语法变迁之 C# 8参考 自从 C# 于 2000 年推出以来,该语言的规模已经大大增加,我不确定任何人是否有可能在任何时候都对每一种语言特性都有深入的了解.因此,我想写一系列快速参考文章 ...
- CF1010C Border 题解
题目传送门 前置知识 最大公约数 | 裴蜀定理 简化题意 给定一个长度为 \(n\) 的序列 \(a\),求 \((\sum\limits_{i=1}^{n}d_ia_i) \bmod k\) 一共会 ...
- JS leetcode 移除元素 题解分析
壹 ❀ 引 又到了每日一道算法题的环节,今天做的题同样非常简单,题目来源leetcode27. 移除元素,题目描述如下: 给你一个数组 nums 和一个值 val,你需要 原地 移除所有数值等于 va ...
- NC20272 [SCOI2009]生日快乐
题目链接 题目 题目描述 windy的生日到了,为了庆祝生日,他的朋友们帮他买了一个边长分别为 X 和 Y 的矩形蛋糕.现在包括windy ,一共有 N 个人来分这块大蛋糕,要求每个人必须获得相同面积 ...
- CSS实现展开动画
CSS实现展开动画 展开收起效果是比较常见的一种交互方式,通常的做法是控制display属性值在none和其它值之间切换,虽说功能可以实现,但是效果略显生硬,所以会有这样的需求--希望元素展开收起能具 ...
- Swoole从入门到入土(3)——TCP服务器[基本配置项]
在这一节的开篇,让我们先解决上一节的"配置"话题.对于server对象,有很多配置项决定了服务端的行为,可以用set的函数进行配置的设置. 1.函数set:用于设置运行时的各项参数 ...
- java 打包jar文件实战
本文只介绍实用步骤,预备知识请自查阅: 参考资料: http://docs.oracle.com/javase/tutorial/deployment/jar/appman.html http://w ...
- 链表--insert
分别是使用了二级指针和一级指针的两种方法,最后会按插入的顺序依次打印1,2,3,4 主要区别在于,使用二级指针,可以在main函数里直接用一个空的Node指针,而一级指针是在main函数里面先添加了一 ...