查看目錄文件
ls 查看目錄中的文件
ls -l 顯示文件和目錄的詳細資料
cd .. 返回上一級目錄
cd ../.. 返回上兩級目錄
cd 進入個人的主目錄
cd - 返回上次所在的目錄
常用的命令一般是殺進程和查看日誌
1、查看進程
ps aux|grep 關鍵字
ps -ef|grep 關鍵字 兩個都行,執行ps可看到進程號
殺進程 kill -9 進程號
2、查日誌
一般就是固定格式tailf=tail -f
實時日誌:tailf /xxx/xxxx/xxx/xx.log|grep "關鍵字" -----------日誌有更新會實時展示
tail -200f xxxx.log 最後二百行
指定日誌:cat /xxx/xxxx/xxx/xx.log|grep"關鍵字" ---------只能查看當前之前的日誌
3、查詢日誌中含有某個關鍵字的信息
cat app.log |grep 'error'
4.使用more和less命令(分頁查看,使用空格翻頁)
cat -n app.log |grep "error" |more
5.查詢日誌中含有某個關鍵字的信息,顯示出行號(在1的基礎上修改)
cat -n app.log |grep 'error'
比如輸出stty rows 36 cols 160
6.根據日期時間段查詢(前提日誌總必須打印日期,先通過grep確定是否有該時間點)
sed -n '/2014-12-17 16:17:20/,/2014-12-17 16:17:36/p' app.log
7.把日誌保存到文件
cat -n app.log |grep "error" > temp.txt