第五周作业

1、显示当前系统上root,fedora或user1用户的默认shell。

[root@hostname ~]# grep -E '^(root|fedora|user1)' /etc/passwd   | cut -d: -f1,7
root:/bin/bash


2、找出/etc/rc.d/init.d/functions文件中某词后面跟一组小括号的行,形如:hello()。

[root@hostname ~]# grep -E  "[[:alpha:]]+\(\)+" /etc/rc.d/init.d/functions 
fstab_decode_str() {
checkpid() {
__readlink() {
__fgrep() {
__umount_loop() {
__umount_loopback_loop() {
__pids_var_run() {
__pids_pidof() {
daemon() {
killproc() {
pidfileofproc() {
pidofproc() {
status() {
echo_success() {
echo_failure() {
echo_passed() {
echo_warning() {
update_boot_stage() {
success() {
failure() {
passed() {
warning() {
action() {
strstr() {
confirm() {
get_numeric_dev() {
is_ignored_file() {
is_true() {
is_false() {
apply_sysctl() {
key_is_random() {
find_crypto_mount_point() {
init_crypto() {


3、使用echo命令输出一个绝对路径,使用grep取出其基名。

[root@hostname ~]# echo "/var/log/messages-20170802" | grep -E -o "[^/]+/?$" | cut -d/ -f1
messages-20170802


4、找出ifconfig命令结果中的1-255之间的数字。

[root@hostname ~]# ifconfig | grep -E -o  "[[:digit:]]{1,}" | grep -E -w  "(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9])"
29
6
15
7
192
168
19
129
192
168
19
255
255
255
255
6
80
20
29
6
15
7
64
1
185
9
148
7
127
1
255
6
1
128
1
100
100
5
2
5
2


5、写一个模式,能匹配出合理的IP地址。

[root@hostname ~]# grep -E "(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])"
192.168.0.2
192.168.0.2
192.168.8.7
192.168.8.7
192.169.0.0
192.169.0.0
127.0.0.0
127.0.0.0


6、能匹配出所有的邮件地址。

[root@hostname ~]# grep -E "[[:alnum:]]+@{1}(sohu|163|sina|qq|126|139|aliyun|yeah).(com|com.cn|cn)$"
350321284@qq.com
350321284@qq.com
13948488570@139.com
13948488570@139.com


7、查找/var目录下属主为root.且属组为mail的所有文件或目录。

[root@hostname ~]# find /var -user root -a -group mail
/var/spool/mail
/var/spool/mail/root

 

<

p>

8、查找当前系统没有属主或属组的文件,进一步查找当前系统上没有属主或属组,且最近3天内曾被访问过的文件或目录。

[root@hostname ~]# find / -nogroup -a -nouser
find: “/proc/1873/task/1873/fd/5”: 没有那个文件或目录
find: “/proc/1873/task/1873/fdinfo/5”: 没有那个文件或目录
find: “/proc/1873/fd/5”: 没有那个文件或目录
find: “/proc/1873/fdinfo/5”: 没有那个文件或目录
You have new mail in /var/spool/mail/root
[root@hostname ~]# find / -nouser -a -nogroup  -a -atime -3
find: “/proc/1883/task/1883/fd/5”: 没有那个文件或目录
find: “/proc/1883/task/1883/fdinfo/5”: 没有那个文件或目录
find: “/proc/1883/fd/5”: 没有那个文件或目录
find: “/proc/1883/fdinfo/5”: 没有那个文件或目录
<p>
    <br />

9、查找/etc/目录下所有用户都有写权限的文件。

[root@hostname ~]# find /etc -perm -222 | wc -l
235

10、查找/etc目录下大于1M。且类型为普通文件的所有文件。

[root@hostname ~]# find /etc -size  +1M -type f 
/etc/selinux/targeted/modules/active/policy.kern
/etc/selinux/targeted/policy/policy.24
    <p>
        &nbsp;
    </p>
    <p>
        <br />
    </p>
    <p>
        &nbsp;
    </p>

原创文章,作者:n27_wing,如若转载,请注明出处:http://www.178linux.com/83472

(0)
n27_wingn27_wing
上一篇 2017-08-04 21:33
下一篇 2017-08-04 21:56

相关推荐

  • vim编辑以及脚本编程练习

    vim编辑器的使用总结: vim在工作过程当中有三种模式:编辑模式、输入模式、末行模式。 1、编辑模式:即命令模式,键盘操作常被理解为编辑命令; 2、输入模式:在文本文件当中进行输入内容; 3、末行模式:vim内置的命令行接口,执行vim的内置命令。   vim的使用 打开文件 #vim[option]…[FILE] +#:打开文件后,直接让光标处…

    Linux干货 2017-10-29
  • Nginx反向代理的常用调度算法

    upstream 调度算法 1.rr 按客户端请求顺序把客户端的请求逐一分配到不同的后端的服务器,这相当于lvs中的rr算法。如果后端服务器岩机(默认情况下只检测80端口,如果后端报502,404,403,503,还是会直接返给用户),岩机服务器会被自动剔除,使用户访问不受影响,请求会分配给正常的服务器 2.weight(权重) 在轮询算法的基础上加上权重(…

    Linux干货 2016-06-01
  • shell脚本编程__bash的配置

    shell脚本编程__bash的配置   一、bash的配置文件:   按生效范围划分,存在两类:     全局配置: /etc/profile /etc/profile.d/*.sh /etc/bashrc    个人配置: ~/.bash_profile ~/.bashrc 二、she…

    Linux干货 2016-08-26
  • LVM-逻辑盘卷管理

    LVM   一、简介         LVM是逻辑盘卷管理(Logical Volume Manager)的简称,它是Linux环境下对磁盘分区进行管理的一种机制,LVM是建立在硬盘和分区之上的一个逻辑层,来提高磁盘分区管理的灵活性。   二、原理   &nb…

    Linux干货 2016-04-12
  • DNS以及bind使用

    DNS以及域名分发布式数据库相关知识      一、 DNS相关介绍           1. DNS(Domain Name Service):域名解析服务协议         &nbsp…

    2015-03-17
  • 日志收集工具EFK之fluent部署手稿

    Edit EFK fluent部署安装 1. 环境介绍 Centos 6.5 64bit 2. 安装 td-agent介绍 fluent 考虑到灵活可扩展性,使用Ruby编写,部分功能考虑性能使用C语言编写。普通用户安装操作Ruby daemon还是有一定难度的。考虑到flunt的上手难度, fluent专门发布了稳定发布包,就也是所谓的td-agent. …

    Linux干货 2016-03-24