六、head命令
作用:用來查看文本文檔
示例:顯示前10行
?。踨oot@template tmp]# head -n 10 /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
七、history
作用:查看歷史記錄命令
[root@tempate tmp]# history
1 ip a
2 shutdown -h now
3 ip addr
4 systemctl restart network
5 ip addr
清空歷史記錄
?。踨oot@template tmp]# history -c
八、sosreport
sosreport命令用于收集系統(tǒng)配置并診斷信息后輸出結(jié)論文檔,格式為:“sosreport”。
當咱們的Linux系統(tǒng)出現(xiàn)故障需要聯(lián)系紅帽廠商或其他技術(shù)支持時,大多數(shù)時候都要先使用這個SOS功能來簡單收集計算機的狀態(tài)和配置信息,以便讓技術(shù)支持公司能夠通過遠程就解決了一些小問題,又或者讓他們能對復雜問題能提前有些了解:
[root@template tmp]# sosreport
sosreport (version 3.2)
This command will collect diagnostic and configuration information from
this CentOS Linux system and installed applications.
An archive containing the collected information will be generated in
/var/tmp and may be provided to a CentOS support representative.
Any information provided to CentOS will be treated in accordance with
the published support policies at:
https://www.centos.org/
The generated archive may contain data considered sensitive and its
content should be reviewed by the originating organization before being
passed to any third party.
No changes will be made to system configuration.
Press ENTER to continue, or CTRL-C to quit. #此處敲擊回車來確認收集信息
Please enter your first initial and last name [template]: #此處敲擊回車,來確認主機名稱
Please enter the case id that you are generating this report for []: #此處敲擊回車,生成報告
Setting up archive 。。。
Setting up plugins 。。。
Running plugins. Please wait 。。。
Running 77/77: yum.。。
Creating compressed archive.。。
Your sosreport has been generated and saved in:
/var/tmp/sosreport-template-20170416043251.tar.xz
The checksum is: 9f5d08f6373e35985213ab8001f7a078
Please send this file to your support representative.
#此壓縮包文件和這段校驗值就是要發(fā)送給對方的內(nèi)容。
#查看生成的報告
?。踨oot@template tmp]# ll /var/tmp/
-rw-------。 1 root root 5543652 Apr 16 04:34 sosreport-template-20170416043251.tar.xz
九、free命令
作用:顯示當前系統(tǒng)中內(nèi)存的使用量信息
?。踨oot@linux~]# free -h
總計內(nèi)存量已用量可用量進程共享的內(nèi)存量磁盤緩存的內(nèi)存量緩存的內(nèi)存量
totalusedfreesharedbufferscached
Mem:1.8G1.3G542M9.8M1.6M413M
-/+ buffers/cache: 869M957M
Swap:2.0G0B2.0G
十、w和who命令
作用:查看當前登入主機的用戶信息
?。踨oot@template tmp]# w
04:40:12 up 1:04, 2 users, load average: 0.00, 0.12, 0.12
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty1 03:36 55:00 0.15s 0.15s -bash
root pts/0 192.168.30.1 03:46 4.00s 0.67s 0.02s w
[root@template tmp]# who
root tty1 2017-04-16 03:36
root pts/0 2017-04-16 03:46 (192.168.30.1)
十一、uptime命令
作用:用于查看系統(tǒng)的負載信息,
格式為:“uptime”。
這個命令真的很棒,它可以為您顯示當前系統(tǒng)時間、系統(tǒng)已運行時間、當前在線用戶以及平均負載值等信息數(shù)據(jù)。平均負載值指的是最近1分鐘、5分鐘、15分鐘的系統(tǒng)壓力情況,負載值越低越好,盡量不要長期超過1。另外您還可以結(jié)合搭配用“watch -n 1 uptime”命令來每秒刷新一次來獲得當前的系統(tǒng)負載情況。
?。踨oot@linux~]# uptime
22:49:55 up 10 min, 2 users, load average: 0.01, 0.19, 0.18
十二、查看系統(tǒng)詳細版本和內(nèi)核版本
?。踨oot@template tmp]# uname -a
Linux template 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@template tmp]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
十三、pidof命令
作用:查看指定服務的進程pid值
?。踨oot@template tmp]# pidof sshd
2956 1538
十四、top命令
作用:用于動態(tài)的監(jiān)視進程活動與系統(tǒng)負載等信息
功能類似于windows系統(tǒng)中的任務管理器
前面的五行為系統(tǒng)整體的統(tǒng)計信息,下面咱們來逐行的講解:
第1行:系統(tǒng)時間,運行時間,登錄用戶數(shù),系統(tǒng)負載(分別為1分鐘、5分鐘、15分鐘的平均值)。第2行:進程總數(shù),運行中的,睡眠中的,停止的,僵死的。第3行:用戶占用資源,系統(tǒng)內(nèi)核占用資源,改變過優(yōu)先級的進程,空閑的資源,等待輸入輸出的時間。此行數(shù)據(jù)均為CPU數(shù)據(jù)并以百分比格式顯示,例如“99.2 id”意味著有99.2%的CPU資源正在空閑中。第4行:物理內(nèi)存總量,使用量,空閑量,作為內(nèi)核緩存的內(nèi)存量。第5行:虛擬內(nèi)存總量,使用量,空閑量,已被提前加載的內(nèi)存數(shù)據(jù)。
十五、ps命令
作用:用于查看系統(tǒng)中的進程狀態(tài)
參數(shù)作用
-a顯示所有的進程(包括其他用戶的)
-u用戶以及其他詳細信息
-x顯示沒有控制終端的進程
Linux系統(tǒng)中時刻運行著許許多多的進程,如果能夠合理的管理它們,絕對有益于系統(tǒng)的性能優(yōu)化,Linux系統(tǒng)中進程最常見的5種不同的狀態(tài)是運行、中斷、不可中斷、僵死與停止,它們的特性分別是:
R(運行):正在運行或在運行隊列中等待。S(中斷):休眠中, 在等待某個條件的形成或接收到信號。D(不可中斷):收到信號不喚醒和不可運行, 進程必須等待直到有中斷發(fā)生。Z:(僵死):進程已終止, 但進程描述符存在, 直到父進程調(diào)用wait4()系統(tǒng)調(diào)用后釋放。T:(停止):進程收到SIGSTOP, SIGSTP, SIGTIN, SIGTOU信號后停止運行。
當執(zhí)行“ps aux”命令后通常會看到下面格式的進程狀態(tài),表格中只是列舉了部分輸出值,而且正常的輸出值中不包括中文注釋部分:
十六、date命令
date命令用于顯示及設置系統(tǒng)的時間或日期,格式為:“date [選項] [+指定的格式]”。
強大的date命令只需鍵入以“+”號開頭的參數(shù)即可按照指定格式來輸出系統(tǒng)的時間或日期,這樣日常工作時咱們便可以將打包數(shù)據(jù)的備份命令與指定格式輸出的時間信息結(jié)合到一起,使得咱們可以更加便捷的區(qū)分每個文件的備份時間啦,date命令常見的格式如下:
十七、dd命令
作用:用于指定大小的拷貝文件或指定轉(zhuǎn)換文件
dd命令:是個比較重要且具有特色的一個命令,它能夠讓用戶指定數(shù)據(jù)塊的大小和個數(shù)來復制一個文件的內(nèi)容,當然如果您愿意的話還可以在復制過程中轉(zhuǎn)換其中的數(shù)據(jù)。Linux系統(tǒng)中有一個叫做/dev/zero的設備文件,每次講課解釋起來都感覺有點哲學理論的色彩,因為它不會占用您的系統(tǒng)存儲空間,但里面卻可以保存有無窮無盡的數(shù)據(jù),一般用來搭配dd命令來生成出來一個指定大小的文件是再好不過的了。
參數(shù)作用
if輸入的文件名稱。
of輸出的文件名稱。
bs設置每個“塊”的大小。
count設置要拷貝“塊”的個數(shù)。
[root@linux ~]# dd if=/dev/zero of=560_file count=1 bs=560M
1+0 records in
1+0 records out
587202560 bytes (587 MB) copied, 27.1755 s, 21.6 MB/s
#從光驅(qū)中復制iso鏡像文件到服務器指定目錄(注意:光驅(qū)插入Centos7.2.iso文件)
#從/dev/cdrom 中復制鏡像文件到/opt目錄中
?。踨oot@template opt]# dd if=/dev/cdrom of=/opt/CentOS-7.2.iso
記錄了8456192+0 的讀入
記錄了8456192+0 的寫出
4329570304字節(jié)(4.3 GB)已復制,155.866 秒,27.8 MB/秒
評論