樓主: changyongid
打印 上一主題 下一主題

一天一個(gè)Linux命令

[復制鏈接]
41
發(fā)表于 2009-9-4 17:20:08 | 只看該作者
加精是應該的。
快速插入一樓。
42
 樓主| 發(fā)表于 2009-9-4 17:32:37 | 只看該作者
本帖最后由 changyongid 于 2009-9-4 17:57 編輯

我們還是先來(lái)help一下,因為看幫助文檔是一個(gè)非常好的習慣。

[changyongid@localhost src]$ od --help
Usage: od [OPTION]... [FILE]...
  or:  od [-abcdfilosx]... [FILE] [[+]OFFSET[.]]
  or:  od --traditional [OPTION]... [FILE] [[+]OFFSET[.] [+][LABEL][.]]

Write an unambiguous representation, octal bytes by default,
of FILE to standard output.  With more than one FILE argument,
concatenate them in the listed order to form the input.
With no FILE, or when FILE is -, read standard input.

All arguments to long options are mandatory for short options.
  -A, --address-radix=RADIX   decide how file offsets are printed 指定地址基數,這里的RADIX在help下面有詳細的解釋。
  -j, --skip-bytes=BYTES      skip BYTES input bytes first
  -N, --read-bytes=BYTES      limit dump to BYTES input bytes
  -S, --strings[=BYTES]       output strings of at least BYTES graphic chars
  -t, --format=TYPE           select output format or formats 數據顯示格式 ,同樣的,TYPE在help的下面也有詳細的解釋。
  -v, --output-duplicates     do not use * to mark line suppression
  -w, --width[=BYTES]         output BYTES bytes per output line
      --traditional           accept arguments in traditional form
      --help     顯示此幫助信息并退出
      --version  輸出版本信息并退出

我們比較常用的就是-A 和 -t參數了。。
RADIX的說(shuō)明如下:

RADIX is d for decimal, o for octal, x for hexadecimal or n for none.

即:
d -十進(jìn)制
o -八進(jìn)制
x -十六進(jìn)制
n -不打印偏移植

TYPE的說(shuō)明如下:
TYPE is made up of one or more of these specifications:

  a          named character, ignoring high-order bit
  c          ASCII character or backslash escape ASCII字符或反斜杠序列
  d[SIZE]    signed decimal, SIZE bytes per integer有符號十進(jìn)制數
  f[SIZE]    floating point, SIZE bytes per integer浮點(diǎn)數
  o[SIZE]    octal, SIZE bytes per integer八進(jìn)制(系統默認值為02)
  u[SIZE]    unsigned decimal, SIZE bytes per integer無(wú)符號十進(jìn)制數
  x[SIZE]    hexadecimal, SIZE bytes per integerx 十六進(jìn)制數

除了選項c以外的其他選項后面都可以跟一個(gè)十進(jìn)制數n,指定每個(gè)顯示值所包含的字節數。

說(shuō)明:od命令系統默認的顯示方式是八進(jìn)制,這也是該命令的名稱(chēng)由來(lái)(Octal Dump)。但這不是最有用的顯示方式,用ASCII碼和十六進(jìn)制組合的方式能提供更有價(jià)值的信息輸出。
43
 樓主| 發(fā)表于 2009-9-4 17:59:29 | 只看該作者
來(lái)個(gè)列子,其中mmu為我編譯一個(gè)程序后生成的可執行文件。輸出太多,我沒(méi)有貼全。
[changyongid@localhost mmu]$ od -Ax mmu
000000 000007 165000 177776 165377 177776 165377 177776 165377
000010 177776 165377 177776 165377 170000 162637 177776 165377
000020 040160 030000 155001 161640 000033 165400 000041 165400
000030 000141 165400 000351 165400 000361 165400 150100 162637
000040 170100 162637 000542 165400 000626 165400 170322 161441
000050 152063 161640 170337 161441 150044 162637 000361 165400
000060 170137 161441 160040 162637 170040 162637 177776 165377
000070 160004 161116 057777 164455 160024 162637 170024 162637
000080 117777 164375 000000 030020 040104 030000 040154 030000
000090 044054 030000 040200 030000 043440 030000 140015 160640
0000a0 154000 164455 130004 161114 022123 161640 030000 161640
44
 樓主| 發(fā)表于 2009-9-4 18:11:23 | 只看該作者
這個(gè)od命令,平時(shí)沒(méi)怎么用過(guò),確實(shí)不知道有什么實(shí)用的地方。
45
發(fā)表于 2009-9-5 17:37:52 | 只看該作者
期待今天的更新。
46
 樓主| 發(fā)表于 2009-9-5 21:06:26 | 只看該作者
嘿嘿。今 天周末。。本來(lái)想給大家放天假。。。

恰 今天有個(gè)文檔要編輯整理下。。。

不過(guò),還是繼續的好。。說(shuō)好一天一個(gè)的。。。呆會(huì )更新。。。謝謝支持。
47
 樓主| 發(fā)表于 2009-9-7 08:24:39 | 只看該作者
周末停了兩天。  宿舍里不是很方便。。。。
48
 樓主| 發(fā)表于 2009-9-7 08:27:40 | 只看該作者
前面我們學(xué)習了幾個(gè)查看文件內容的命令。會(huì )用這幾個(gè)命令,查看一般的文件內容也就夠用了。。。
那么,接下來(lái)學(xué)習一個(gè)命令,用于文件內容的統計。。。
49
 樓主| 發(fā)表于 2009-9-7 08:36:00 | 只看該作者
這個(gè)命令就是 wc  我們先來(lái)help一下。
[changyongid@localhost ~]$ wc --help
用法:wc [選項]... [文件]...
  或:wc [選項]... --files0-from=F
Print newline, word, and byte counts for each FILE, and a total line if
more than one FILE is specified.  With no FILE, or when FILE is -,打印文件的行、字、字節數
read standard input. 沒(méi)有指定文件時(shí),則從標準輸入讀取
  -c, --bytes            print the byte counts字節數
  -m, --chars            print the character counts 這個(gè)好像也是字節數
  -l, --lines            print the newline counts行數
      --files0-from=F    read input from the files specified by
                           NUL-terminated names in file F;
                           If F is - then read names from standard input
  -L, --max-line-length  print the length of the longest line 最長(cháng)行的長(cháng)度
  -w, --words            print the word counts字數
      --help     顯示此幫助信息并退出
      --version  輸出版本信息并退出
50
 樓主| 發(fā)表于 2009-9-7 08:48:07 | 只看該作者
現在來(lái)試一下這個(gè)命令。。。有名為 tt 的一個(gè)文件。。我們來(lái)對其操作一下。。

[changyongid@localhost ~]$ cat tt                        //這里是tt的內容
ok let is abc def g
abc efg
asdfghjkldafsdfa
[changyongid@localhost ~]$ wc -c tt              //字節數
45 tt
[changyongid@localhost ~]$ wc -m tt             //這個(gè)跟字節數相同,不敢確定
45 tt
[changyongid@localhost ~]$ wc -l tt              //行數
3 tt
[changyongid@localhost ~]$ wc -L tt               //最長(cháng)行的字符數
19 tt
[changyongid@localhost ~]$ wc -w tt            //字數,以空格分開(kāi)的
9 tt
51
 樓主| 發(fā)表于 2009-9-8 19:06:40 | 只看該作者
前面所學(xué)的命令都是針對文件的。!,F在開(kāi)始來(lái)學(xué)習針對目錄的命令吧。。。
cd   這個(gè)命令很簡(jiǎn)單,也很基本。。也最常用。
52
 樓主| 發(fā)表于 2009-9-8 19:07:29 | 只看該作者
首先,我們來(lái)help一下。。
[changyongid@localhost vivi]$ cd --help
bash: cd: --: invalid option
cd: usage: cd [-L|-P] [dir]

可以看到,這個(gè)命令的參數非常的簡(jiǎn)單。
53
 樓主| 發(fā)表于 2009-9-8 21:45:59 | 只看該作者
繼續來(lái)看。 help得到的信息很少,那么就man一下。。 截取一些有用的信息。
Change  the  current directory to dir.  The variable HOME is the
              default dir.  
The  -P  option  says  to use the physical directory structure instead of
              following symbolic links (see also the  -P  option  to  the  set
              builtin command); the -L option forces symbolic links to be fol-
              lowed.  An argument of - is equivalent to $OLDPWD.   

英語(yǔ)不好,大意是 改變當前目錄到參數dir這個(gè)目錄里。HOME是進(jìn)入終端時(shí)的默認目錄。
至于-P 和-L命令我也沒(méi)搞大清楚。大概跟鏈接link有關(guān)

還有一個(gè)比較有用的就是  - 參數。。它代表上一個(gè)進(jìn)入的目錄。。
比如:
[changyongid@Fedora ~]$ pwd
/home/changyongid
可以看到,當前目錄是這個(gè)用戶(hù)的主目錄。。。
[changyongid@Fedora ~]$ cd /
[changyongid@Fedora /]$ pwd
/
這樣之后,又到了根目錄里。。。
那么:
[changyongid@Fedora /]$ cd -
/home/changyongid
[changyongid@Fedora ~]$ pwd
/home/changyongid
這樣,看到,又回到上一次進(jìn)入的目錄。。。。

這個(gè)參數感覺(jué)非常的有用。。用起來(lái)很方便。。。當然,這里具的例子可能不恰當,因為路徑很少,當路徑很長(cháng)時(shí)它的作用就明顯了。

直接cd 不帶參數,則會(huì )進(jìn)入當前用戶(hù)主目錄。
54
 樓主| 發(fā)表于 2009-9-8 21:48:53 | 只看該作者
另外還有兩個(gè)小技巧。
cd !$          #把上個(gè)命令的參數作為輸入。
cd ~         #同樣也是回到主目錄

其實(shí),這都是跟環(huán)境變量很有關(guān)系。
先了解這么多,今天有些累。。。散會(huì )。
55
 樓主| 發(fā)表于 2009-9-8 21:50:05 | 只看該作者
另外還有兩個(gè)小技巧。
cd !$          #把上個(gè)命令的參數作為輸入。
cd ~         #同樣也是回到主目錄

其實(shí),這都是跟環(huán)境變量很有關(guān)系。
先了解這么多,今天有些累。。。散會(huì )。
56
 樓主| 發(fā)表于 2009-9-9 08:29:45 | 只看該作者
又是一天的開(kāi)始,我們繼續努力。
57
 樓主| 發(fā)表于 2009-9-9 08:32:54 | 只看該作者
本帖最后由 changyongid 于 2009-9-9 08:36 編輯

學(xué)習cd命令的時(shí)候,看到我打的pwd命令了吧。。。。那么這個(gè)命令是干什么的呢?相信你肯定已經(jīng)知道了。沒(méi)錯。我們來(lái)man一下
PWD(1)                           User Commands                          PWD(1)

NAME
       pwd - print name of current/working directory  

SYNOPSIS
       pwd [OPTION]...

DESCRIPTION
       Print the full filename of the current working directory.
打印當前工作目錄的絕對路徑

       -L, --logical
              use PWD from environment, even if it contains symlinks

       -P, --physical
              avoid all symlinks

       --help display this help and exit

       --version
              output version information and exit

至于-P -L的選項,我還不知道是什么意思。。

58
 樓主| 發(fā)表于 2009-9-9 08:46:03 | 只看該作者
今天這個(gè)命令挺簡(jiǎn)單的。好像偷懶了。。
那么來(lái)規劃一下未來(lái)幾天要學(xué)習的命令吧。。。
mkdir  創(chuàng )建目錄
rmdir   刪除目錄
ls   列出一個(gè)目錄中的文件
cp  復制
mv 移動(dòng)
rm 刪除
一看就知道這些命令在我們的日常使用中的頻率有多么高。所以好好的掌握是非常有必要的。
59
 樓主| 發(fā)表于 2009-9-10 15:45:12 | 只看該作者
有時(shí)候就是這樣,腦子一下子僵在那里……突然想不動(dòng)事情。

于是,再來(lái)學(xué)習一個(gè)命令。。。。

話(huà)又說(shuō)回來(lái)。這些命令,如果不經(jīng)常的去敲打的話(huà),學(xué)到后面,很容易就忘了前面,特別是那些參數,忘起來(lái)就更快了。所以,還是有必要定時(shí)回過(guò)頭去翻翻前面的貼子。

這樣的話(huà),就定個(gè)定時(shí)器,中斷觸發(fā),專(zhuān)門(mén)的處理函數去響應。。。。

學(xué)習就是這個(gè)道理,給自己定個(gè)定時(shí)器,采用中斷觸發(fā),定時(shí)回過(guò)頭來(lái)復習已學(xué)過(guò)的內容。這樣我們的大腦這臺cpu才能跑的更好。。。
如查采取循環(huán)的模式,一個(gè)循環(huán)回來(lái)響應一次這個(gè)“復習”處理函數,那可就時(shí)間長(cháng)了。說(shuō)不定我們的cpu一直跑下去了,再也不回頭了。。。這就是人的特殊性,因為這個(gè)程序往往是不循環(huán)的……
60
 樓主| 發(fā)表于 2009-9-10 15:50:06 | 只看該作者
ok 。。。mkdir。

[changyongid@localhost ~]$ mkdir --help
用法:mkdir [選項]... 目錄...
若目錄不是已經(jīng)存在則創(chuàng )建目錄。

長(cháng)選項必須用的參數在使用短選項時(shí)也是必需的。
  -m, --mode=MODE   set file mode (as in chmod), not a=rwx - umask 對新建目錄設置存取權限
  -p, --parents     no error if existing, make parent directories as needed 如果路徑中有個(gè)目錄不存在,則創(chuàng )建它
  -v, --verbose     print a message for each created directory 會(huì )顯示出提示信息。這個(gè)選項許多命令里都會(huì )有。大至是一個(gè)提示的作用,讓我們用戶(hù)可以看到操作的結果。
  -Z, --context=CTX  set the SELinux security context of each created
                      directory to CTX
      --help     顯示此幫助信息并退出
      --version  輸出版本信息并退出
您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

關(guān)于我們  -  服務(wù)條款  -  使用指南  -  站點(diǎn)地圖  -  友情鏈接  -  聯(lián)系我們
電子工程網(wǎng) © 版權所有   京ICP備16069177號 | 京公網(wǎng)安備11010502021702
快速回復 返回頂部 返回列表
午夜高清国产拍精品福利|亚洲色精品88色婷婷七月丁香|91久久精品无码一区|99久久国语露脸精品|动漫卡通亚洲综合专区48页