作业——2016-10-17

1 生产环境发现一台服务器系统时间产生偏差,造成服务异常,请帮忙校正。

    将系统时间同步到硬件时间的命令是hwclock -s

2 生产有一个数据同步脚本需要执行很长时间,怎样做到无人值守,在管理工具退出的情况下,脚本依然能正常运行。

    screen -S work  进去后开始做工作,暂时离开时可使用 ctrl+a,d 剥离当前会话。

3 Linux系统中命令共分为内建命令和外部命令,请分别阐述定义并举例。内建命令、外部命令,别名的优先级是什么?如何定义命令别名以及在执行命令的时候不使用别名?

   内部命令:通常在linux系统加载运行时shell就被加载并驻留在系统内存中,

   比如:exit,history,cd,echo等

   外部命令:在系统加载时并不随系统一起被加载到内存中,而是在需要时才将其调用内存。

   比如:ls、vi等

   别名的优先级高于内部命令,内部命令的优先级高于外部命令。

   命令别名通常是其他命令的缩写,用来减少键盘输入。

   命令格式为:

   alias [alias-name=’original-command’]

   执行命令时不使用别名的方法:\命令。例如 : \pwd

4 hash的作用是什么?请列举出常见的使用方式。

   利用hash缓存表可大大提高命令的调用速率。

   系统初始hash 表为空 ,当外部命令执行时,默认会 从

   PATH 路径下寻找该 命令,找到后会将这 条命令的 路径记录到

   hash 表中,当再次 使用该命令时,shell 解释器首先会查看hash

   表 ,存在将执行之,如果不存在,将会去 去PATH 路径下寻找 。

   Hash 常见用法:

   hash -l 显示哈希表

   hash -r 清除哈希表

   hash -d<COMMAND> 清除哈希表

   hash -p<PATH> 向哈希表中增加内容

   hash -t<COMMAND> 显示命令的完整路径

5 创建一个文件,文件名格式为 liangchen-当前时间(年-月-日).log

   touch liangchen-`date +%F`.log

6 history的作用,总结使用各种调用历史命令的快捷方式。

   History命令主要用于显示历史指令记录内容, 下达历史纪录中的指令 。

   1>History命令语法:

   [test@linux]# history [n]

   [test@linux]# history [-c]

   [test@linux]# history [-raw] histfiles

   参数:

   -n   :数字,要列出最近的 n 笔命令列表

   -c  :将目前的shell中的所有 history 内容全部消除

   -a  :将目前新增的history 指令新增入 histfiles 中,若没有加 histfiles ,

   则预设写入 ~/.bash_history

   -r  :将 histfiles 的内容读到目前这个 shell 的 history 记忆中

   -w  :将目前的 history 记忆内容写入 histfiles

   Linux系统当你在shell(控制台)中输入并执行命令时,shell会自动把你的命令记录到历史   列表  中,一般保存在用户目录下的.bash_history文件中。默认保存1000条,你也可以更   改这个值。

   !#执行编号为#的命令

   !$调用上一条命令的参数

   !-#执行倒数第#条命令

   !!执行上一条命令

思考

    生产服务器web服务日志中会记录访问IP,请统计出每个IP的访问次数,并且按照访问次数从高到低排列。日志格式如下:

80.95.39.126 17/Oct/2016:05:41:57 -0400 POST /wp-login.php HTTP/1.1 0.028 0.028 200 3279 http://magedu.com/wp-login.php Mozilla/5.0 (Windows NT 6.0; rv:34.0) Gecko/20100101 Firefox/34.0 www.magedu.com CustomName1 CustomName4 CustomName5 CustomName6 CustomName7 CustomName8

1.162.234.78 17/Oct/2016:05:41:59 -0400 CONNECT mx-tw.mail.gm0.yahoodns.net:25 HTTP/1.0 0.161 400 166  www.magedu.com CustomName1 CustomName4 CustomName5 CustomName6 CustomName7  CustomName8

212.164.214.245 17/Oct/2016:05:43:53 -0400 GET /wp-login.php HTTP/1.1 0.023 0.023 200 2991 Mozilla/5.0 (Windows NT 6.0; rv:34.0) Gecko/20100101 Firefox/34.0 magedu.com CustomName1 –    CustomName4 CustomName5 CustomName6 CustomName7 CustomName8

212.164.214.245 17/Oct/2016:05:43:53 -0400 POST /wp-login.php HTTP/1.1 0.024 0.024 200 3279 http://magedu.com/wp-login.php Mozilla/5.0 (Windows NT 6.0; rv:34.0) Gecko/20100101 Firefox/34.0 www.magedu.com CustomName1 CustomName4 CustomName5 CustomName6 CustomName7 CustomName8

178.210.12.71 17/Oct/2016:05:45:57 -0400 GET /wp-login.php HTTP/1.1 0.028 0.028 200 2991 Mozilla/5.0 (Windows NT 6.0; rv:34.0) Gecko/20100101 Firefox/34.0 magedu.com CustomName1 –    CustomName4 CustomName5 CustomName6 CustomName7 CustomName8

178.210.12.71 17/Oct/2016:05:45:57 -0400 POST /wp-login.php HTTP/1.1 0.025 0.025 200 3279 http://magedu.com/wp-login.php Mozilla/5.0 (Windows NT 6.0; rv:34.0) Gecko/20100101 Firefox/34.0 www.magedu.com CustomName1 CustomName4 CustomName5 CustomName6 CustomName7 CustomName8

84.42.28.170 17/Oct/2016:05:46:47 -0400 GET /wp-login.php HTTP/1.1 0.027 0.027 200 2991 Mozilla/5.0 (Windows NT 6.0; rv:34.0) Gecko/20100101 Firefox/34.0 magedu.com CustomName1 –    CustomName4 CustomName5 CustomName6 CustomName7 CustomName8

84.42.28.170 17/Oct/2016:05:46:47 -0400 POST /wp-login.php HTTP/1.1 0.042 0.042 200 3279 http://magedu.com/wp-login.php Mozilla/5.0 (Windows NT 6.0; rv:34.0) Gecko/20100101 Firefox/34.0 www.magedu.com CustomName1 CustomName4 CustomName5 CustomName6 CustomName7 CustomName8

217.12.33.106 17/Oct/2016:05:48:34 -0400 GET /wp-login.php HTTP/1.1 0.027 0.027 200 2991 Mozilla/5.0 (Windows NT 6.0; rv:34.0) Gecko/20100101 Firefox/34.0 magedu.com CustomName1 –    CustomName4 CustomName5 CustomName6 CustomName7 CustomName8

217.12.33.106 17/Oct/2016:05:48:34 -0400 POST /wp-login.php HTTP/1.1 0.027 0.027 200 3279 http://magedu.com/wp-login.php Mozilla/5.0 (Windows NT 6.0; rv:34.0) Gecko/20100101 Firefox/34.0 www.magedu.com CustomName1 CustomName4 CustomName5 CustomName6 CustomName7 CustomName8

    将日志文本先保存到test中

    其中两种方法:

awk '{print$1}' test | uniq -c | sort -rn

cut -d '-' -f 1 test | uniq -c | sort -rn

      

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

(0)
mutumutu
上一篇 2016-10-18
下一篇 2016-10-18

相关推荐

  • 用户管理、三种权限、三种特殊权限的使用

    用户管理、三种权限、三种特殊权限的使用 一、用户管理 1、软链接:ln  -s  相对于软链接的路径/绝对路径   软链接文件    硬链接:ln  相对路径原文件   硬链接文件 2、getent的使用    gentent p…

    系统运维 2016-08-05
  • 系统管理之系统安装及自动化安装

    概述:     上篇我们讨论了下关于Linux系统的启动流程和grub相关的内容,本篇将介绍一下Linux的系统安装相关的内容,具体分为:     1、系统安装程序anaconda的介绍     2、kickstart文件的介绍 &nbsp…

    Linux干货 2016-09-16
  • linux文件管理类命令学习总结练习

    1、常用文件管理类命令:cp, mv, rm   cp: copy命令       单元复制 cp [OPTION]… [-T] SOURCE DEST                     DEST不存在…

    Linux干货 2016-11-06
  • Net25-第13周作业

    1、建立samba共享,共享目录为/data,要求:(描述完整的过程) 1)共享名为shared,工作组为magedu; 2)添加组develop,添加用户gentoo,centos和ubuntu,其中gentoo和centos以develop为附加组,ubuntu不属于develop组;密码均为用户名; 3)添加samba用户gentoo,centos和u…

    Linux干货 2017-05-15
  • Nginx配置进阶

    目录 ngx_http_rewrite_module模块 ngx_http_gzip_module模块 ngx_http_fastcgi_module模块 ngx_http_ssl_module模块 ngx_http_referer_module模块 ngx_http_rewrite_module模块 将用户某一次请求的URI当中的字符串是不是能够被我们给出…

    Linux干货 2016-11-05
  • 磁盘管理

    CHS cylinder-head-sector cylinder柱面=track*head=512*63*256=8M  磁盘分区 为什么是分区? • 优化I/O 性能 • 实现磁盘空间配额限制 • 提高修复速度 • 隔离系统和程序 • 安装多个OS • 采用不同文件系统   MBR:使用32位表示扇区数量,按每扇区512字节计算,每个…

    Linux干货 2016-08-29