天天看點

ubuntu-基本指令篇-15-系統管理-time指令中Real,User,Sys概念

15.系統管理

環境變量        env     linux運作過程過程中記憶體中需要一些特定到參數,environment

系統日期        date    日期

運作時間        time    測試指令執行到時間。比如 time ls 會記錄ls執行時間。

曆史指令     history  檢視之前都執行過哪些指令

系統資訊        dmesg      顯示系統資訊

日志檔案        /var/log

系統運作時間    uptime  

系統使用者        w,who,whoami  

登入資訊        last    記錄最近多少條登入資訊

設定環境變量

export DISPLAY=localhost:0.0 就将DISPLAY這個環境變量到值設定為“localhost:0.0“了。

time gcalctool         打開計算機并計時

計時結果如下:

real    0m8.183s    真實運作時間為8.183秒,程式存活的時間,

user    0m0.684s    user占用,

sys    0m0.028s     系統占用   

Real,User和Sys具體解釋如下:

原文位址:

http://stackoverflow.com/questions/556405/what-do-real-user-and-sys-mean-in-the-output-of-time1

Real, User and Sys process time statistics

One of these things is not like the other. Real refers to actual elapsed time; User and Sys refer to CPU time used only by the process.

    *Real is wall clock time - time from start to finish of the call. This is all elapsed time including time slices used by other processes and time the process spends blocked (for example if it is waiting for I/O to complete).

    *User is the amount of CPU time spent in user-mode code (outside the kernel) within the process. This is only actual CPU time used in executing the process. Other processes and time the process spends blocked do not count towards this figure.

    *Sys is the amount of CPU time spent in the kernel within the process. This means executing CPU time spent in system calls within the kernel, as opposed to library code, which is still running in user-space. Like 'user', this is only CPU time used by the process. See below for a brief description of kernel mode (also known as 'supervisor' mode) and the system call mechanism.

      User+Sys will tell you how much actual CPU time your process used.

翻譯如下:

    * Real 是時鐘時間-程式從開始至結束的總時間。他包括期間其他程序所占用的時間片和程序被阻塞的時間(如IO等待的時間)

    * User 被測試程式在使用者模式下所花的CPU時間。他是程序執行的正真的CPU時間。其他程序排程的時間片以及阻塞(如IO)的時間不包含在内。

    * Sys 是程序在核心中所花費的CPU時間。他表示程序在核心調用中所花的CPU時間,而程式的庫調用仍然運作在使用者空間下。

      User+Sys表示程式所執行的CPU時間(不包括IO以及其他程序的CPU時間).

history 列出最近使用的指令。

history -c 清除曆史指令到記錄 ,-c表示clear

dmesg = cat /var/log/dmesg

cat /var/log/messages  系統資訊。比如如果你在messages中找到有許多登入失敗到資訊,就表示有人在猜你到root密碼,企圖登入你到電腦。

last 顯示系統登入成功到資訊

messages中顯示一些登入失敗到資訊。

本文轉自xwdreamer部落格園部落格,原文連結:http://www.cnblogs.com/xwdreamer/archive/2010/08/12/2297109.html,如需轉載請自行聯系原作者

繼續閱讀