Linux常用命令列彙總
Linux常用命令有哪些?下面yjbys小編特為正在學習Linux的同學們分享十五個常用Linux命令列,歡迎閱讀!
1. 磁碟使用情況
du -h 檢視當前使用者每個檔案的大小,格式化顯示
df -h 磁碟使用情況
[root@localhost mysql5]# du -h
339M
[root@localhost mysql5]# ls
[root@localhost mysql5]# du -h
17M
[root@localhost mysql5]#
[root@localhost mysql5]# df -h
檔案系統 容量 已用 可用 已用% 掛載點
/dev/mapper/VolGroup00-LogVol00
14G 6.4G 6.5G 50% /
/dev/sda1 99M 12M 83M 13% /boot
tmpfs 506M 0 506M 0% /dev/shm
2、常用檔案操作命令
cat,顯示檔案內容。
cd,改變目錄路徑。
cp,複製檔案。
find,查詢檔案。
grep,搜尋、過濾資訊。
ls,列出目錄資訊。
more,分頁顯示。
rm,刪除檔案或目錄。
vi,呼叫vi文字編輯器
[root@localhost king]# cat |more
//查詢當前目錄下以a開頭的檔案
[root@localhost king]# ls
king001 kingtest new
[root@localhost king]# find -name "a*"
./
./
./
[root@localhost home]# find king -name "a*"
king/
king/
king/
grep查詢keyword的所在行的內容
[root@localhost king]# more |grep "1971"
Federal Election Campaign Act of 1971 to provide bipartisan campaign
ls統計檔案個數:原理是ls -l列出多少行 再利用管道作為wc -l輸入 以行來數的
[root@localhost king]# ls -l
總計 44
-rwxrw-rw- 1 root root 2395 2012-05-26
-rwxrw-rw- 1 root root 2397 2012-05-26
-rwxrw-rw- 1 root root 1020 2012-05-26
drwxrwxr-x 2 king king 4096 2012-02-02 king001
-rw-rw-r-- 1 king king 0 2012-02-02 kingtest
-rw-r--r-- 1 root root 714 09-30 22:52 new
[root@localhost king]# ls -l|wc -l
7
head 檢視檔案前20行 tail 檢視後面10行
[root@localhost king]# head -20
[Congressional Record Volume 148, Number 2 (Thursday, January 24, 2002)]
[Daily Digest]
[Page D12]
From the Congressional Record Online through the Government Printing Office []
House of Representatives
Chamber Action
Measures Introduced: 13 public bills, H.R. 3622-3634; 8 resolutions, H.
Con. Res. 302-308, and H. Res. 335 were introduced.
Page H78
Reports Filed: No reports were filed today.
Speaker Pro Tempore: Read a letter from the Speaker wherein he
appointed Representative Shimkus to act as Speaker pro tempore for
today.
[root@localhost king]# tail -10
Res. 203, providing for consideration of H.R. 2356, to amend the
Federal Election Campaign Act of 1971 to provide bipartisan campaign
reform, the motion was referred to the Calendar of Motions to Discharge
Committees.
Pages H76-77
Senate Message: Message received from the Senate appears on page H39.
Quorum Calls--Votes: One yea-and-nay vote developed during the
proceedings of the House today and appears on pages H47-48. There were
no quorum calls.
Adjournment: The House met at 10 a.m. and adjourned at 3:38 p.m.
Linux命令經典面試題:統計檔案中出現次數最多的前10個單詞
使用linux命令或者shell實現:檔案words存放英文單詞,格式為每行一個英文單詞(單詞可以重複),統計這個檔案中出現次數最多的前10個單詞。
cat | sort | uniq -c | sort -k1,1nr | head -10
主要考察對sort、uniq命令的'使用,相關解釋如下,命令及引數的詳細說明請自行通過man檢視,簡單介紹下以上指令各部分的功能:
sort: 對單詞進行排序
uniq -c: 顯示唯一的行,並在每行行首加上本行在檔案中出現的次數
sort -k1,1nr: 按照第一個欄位,數值排序,且為逆序
head -10: 取前10行資料
[root@localhost king]# uniq -c |sort -k1
1 bye
1 good
1 see
1 tim
1 tim
1 you
2 jack
2 king
[root@localhost king]# uniq -c |sort -r|head -2
2 king
2 jack
-
關於ocp認證考試試題
inux承襲的是開放式原始碼(OpenSource)的精神,所有LinuxSourceCode(原始碼)均可免費取得,這使得它相對其它的作業系統(尤其是昂貴的WindowsNT)而言價格極其便宜。下面是小編整理的關於ocp認證考試試題,歡迎大家參考!(1)需要登入進入線上考試系統才能檢視答案及解...
-
Linux認證基礎知識:php相對路徑和絕對路徑
在不斷注重大學聯考能力提高的同時,尤其是Linux認證備考的'後階段,我們選擇的是求準求穩求規範。此複習輔導不等於題海戰術,而是要積累實戰經驗,解決掉一些考場失誤等問題。一個好的php程式碼,無論放到windows還是linux,不同版本的php上,都能正確的輸出結果,才是一個好程式碼...
-
Linux中正則表示式使用方法
在Linux系統中使用grep、awk和sed命令時,需要使用正則表示式。那麼正則表示式的使用方法有哪些?跟yjbys小編一起來看看吧!比如我通過grep找程式碼編譯結果中是否有錯誤。或者是否有我程式碼的錯誤。這裡說下正則表示式基本的應用:•匹配行首與行尾。•匹配數...
-
Linux許可權管理基本知識大全
Linux系統有什麼基本許可權,許可權管理命令是什麼?下面跟yjbys小編一起來看看吧!一、基本許可權linux許可權機制採用UGO模式。其中u(user)表示所屬使用者、g(group)表示所屬組、o(other)表示除了所屬使用者、所屬組之外的情況。u、g、o都有讀(read)、寫(write)、執行(excute...