1 生產環境發現一臺服務器系統時間產生偏差,造成服務異常,請幫忙校正。
1、使用ntpdate對時間進行同步,然后hwclock -w;并再建立Crontab每小時進行一次時間同步。
2 生產有一個數據同步腳本需要執行很長時間,怎樣做到無人值守,在管理工具退出的情況下,腳本依然能正常運行。
1、載光盤
2、進入/mnt/Packages 安裝共享screen軟件
3、創建會話:screen -S name
4、其他機器登入此服務器后加入會話:screen -x name
5、剝離當前會話 Ctl+a;d
6、重新進入會話screen -r (detached)剝離狀態的進程號
3 Linux系統中命令共分為內建命令和外部命令,請分別闡述定義并舉例。內建命令、外部命令,別名的優先級是什么?如何定義命令別名以及在執行命令的時候不使用別名?
內建命令:shell自帶的程序,在開機后直接加載至系統內存,隨時可用,可采用enable -n進行禁用,enable進行啟用;
外部命令:echo $PATH 和安裝軟件所生成的命令;
優先級:別名>內建命令>外部命令
別名定義別名采用alias NAME="VALUE"
執行命令是不使用別名可使用:\COMMAND 'COMMAND' /PATH/TO/COMMADN
4 hash的作用是什么?請列舉出常見的使用方式。
hash:緩存表,在執行命令是會將該執行命令的路徑記錄至hash,當再次執該命令是直接從改hash表取得該命令的路徑進行執行程序,提高速度和執行效率;
hash :查看當前的hash列表;
Hash :顯示hash緩存表;
hash -l:顯示hash緩存,可作為輸入使用;
hash -p:path name
hash -d:name:清除name的緩存
hash -l:清除緩存;
5 創建一個文件,文件名格式為 liangchen-當前時間(年-月-日).log
>liangchen-`date +%F`.doc
6 history的作用,總結使用各種調用歷史命令的快捷方式。
history作用:用于顯示指定數目的歷史命令;
history :顯示當前的history列表;
-c :清空歷史列表
-d : 刪除歷史中指定的命令的序號
# :顯示最近的#條歷史
-a :
append追加本次會話新執行的命令歷史列表到歷史文件~/.bash_history
-n :讀取歷史文件中未讀過的行到歷史列表;
-r : 讀歷史文件附加到歷史列表
-w : 保存歷史列表到指定的歷史文件
-p :
前綴history -p執行命令,所執行命令不存在歷史列表中; history -p cd arguments
-s :
前綴history -s執行命令,所執行命令不執行但講命令記錄至歷史列表
HISTSIZE:歷史命令記錄的條數;
HISTFILE:指定歷史文件,默認為~/.bash_history
HISTFILESIZE:命令歷史文件記錄歷史的條目;
HISTTIMEFORMAT="%F %T"
HISTIGNORE="str1:str2…." : 忽略str1.str2….
HISCRONTROL:HIS控制:
ignoredups:默認,忽略重復命令
ignorespace:忽略空白開頭
erasedups:刪除重復命令
export 變量名="值"
以上變量長久有效需要添加變量值至/etc/profile 或者~/.bash_history
思考
生產服務器web服務日志中會記錄訪問IP,請統計出每個IP的訪問次數,并且按照訪問次數從高到低排列。日志格式如下:
cut -d- -f1 1018|uniq -c|sort -k1 -rt' '
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 –
原創文章,作者:guo_ruillin,如若轉載,請注明出處:http://www.www58058.com/52650