1 生產環境發現一臺服務器系統時間產生偏差,造成服務異常,請幫忙校正
##先分析硬件時間不對還是系統時間不對,如果是系統時間不對: [root@localhost ~]# hwclock -w [root@localhost ~]# ##如果是硬件時間不對: [root@localhost ~]# hwclock -s [root@localhost ~]#
也可以使用ntp來同步:
[root@localhost ~]# /usr/sbin/ntpdate time.nist.gov
2.生產有一個數據同步腳本需要執行很長時間,怎樣做到無人值守,在管理工具退出的情況下,腳本依然能正常運行。
讓腳本在后臺執行,斷網或是其他情況仍能夠在服務器上執行,即:
[root@localhost ~]# mysqlRsync.sh &
或者使用screen:
[root@localhost ~]# screen -S test 在另一個機器上ssh登陸,使用screen -x test連接上面的會話。之后執行腳本: [root@localhost ~]# mysqlRsync.sh ctrl+a,d 剝離會話 screen -r test恢復會話,發現腳本還在運行
3 Linux系統中命令共分為內建命令和外部命令,請分別闡述定義并舉例。內建命令、外部命令,別名的優先級是什么?如何定義命令別名以及在執行命令的時候不使用別名?
Linux的命令分為內部命令和外部命令:1.內部命令在系統啟動時就調入內存,是常駐內存的,所以執行效率高。2.外部命令是系統的軟件功能,用戶需要時才從硬盤中讀入內存。 關于內置命令(內置命令都寫入到了bash當中): [root@localhost ~]# ll /bin/bash -rwxr-xr-x. 1 root root 868692 Jul 18 2013 /bin/bash kill是一個內置命令: [root@localhost ~]# type kill kill is a shell builtin 外部命令是存放在這些目錄下的命令: [root@localhost ~]# echo $PATH/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/script ssh是一個外部命令: [root@localhost ~]# type ssh ssh is /usr/bin/ssh
優先級別排序:別名命令>內置命令>外部命令
不使用別名:
方法1:寫命令全路徑 /bin/ls test.log 方法2:命令前面加\ [root@localhost ~]# \grep root /etc/passwd root:x:0:0:root:/root:/bin/bash operator:x:11:0:operator:/root:/sbin/nologin 方法3:命令加' '[root@localhost ~]# 'grep' root /etc/passwd root:x:0:0:root:/root:/bin/bash operator:x:11:0:operator:/root:/sbin/nologin
4 hash的作用是什么?請列舉出常見的使用方式。
Hash:
系統初始hash表為空,當外部命令執行時,默認會從PATH路徑下尋找該命令,找到后會將這條命令的路徑記錄到hash表中,當再次使用該命令時,shell解釋器首先會查看hash表,存在將執行,如果不存在,將會去PATH路徑下尋找。利用hash緩存表可大大提高命令的調用速率
Hash常見用法:
hash 顯示hash緩存
hash -l 顯示hash緩存,可作為輸入使用
hash -p path name 將命令全路徑path起別名為name
hash -t name 打印緩存中name的路徑
hash -d name 清除name緩存
hash -r 清空緩存
5 創建一個文件,文件名格式為 liangchen-當前時間(年-月-日).log
[root@localhost ~]# touch liangcheng-`date +%F`.log
6.history命令總結
對于history已經在我的有道筆記有了詳細總結(實在太長,筆記格式復制不上去,看我的筆記也行)
http://note.youdao.com/noteshare?id=ab9ad95d093455fb6bfd9513570e724d
原創文章,作者:21期王逸凡,如若轉載,請注明出處:http://www.www58058.com/52832