Linux常用命令

Linux常用命令

1. ar

  官方解釋:ar - create, modify, and extract from archives
  可以理解爲:從壓縮包中創建、修改、提取文件
  Linux ar命令用於建立或修改備存文件,或是從備存文件中抽取文件。ar可讓您集合許多文件,成爲單一的備存文件。在備存文件中,所有成員文件皆保有原來的屬性與權限

命令使用格式:
Usage: ar [-]{dmpqrstx}[abcDfilMNoPsSTuvV] [–plugin name] [member-name] [count] archive-file file…

操作指令 {dmpqrtx}
commands:

  • d - delete file(s) from the archive //從庫中刪除模塊,刪除備存文件中的成員文件
  • m[ab] - move file(s) in the archive //該操作是在一個庫中移動成員,如果沒有指定任選項,任何指定的成員將移到庫的最後
  • p - print file(s) found in the archive //顯示庫中指定的成員到標準輸出
  • q[f] - quick append file(s) to the archive //快速追加,增加新模塊到庫的結尾處
  • r[ab][f][u] - replace existing or insert new file(s) into the archive //在庫中插入模塊(替換)。當插入的模塊名已經在庫中存在,則替換同名的模塊。使用”r”後,需要用”s”更新符號索引表,不然會鏈接報錯
  • s - act as ranlib //創建或者更新目標文件索引,與ranlib作用一致(ranlib用來對靜態庫的符號索引表進行更新)
  • t - display contents of archive //顯示庫的模塊表清單。一般只顯示模塊名
  • x[o] - extract file(s) from the archive //從庫中提取一個成員。如果不指定要提取的模塊,則提取庫中所有的模塊。可以將靜態庫中的目標文件解壓出來

可與操作指令結合使用的特殊修飾符選項 [abDfiNoPu]
command specific modifiers:

  • [a] - put file(s) after [member-name] //在庫的一個已經存在的成員後面增加一個新的文件。如果使用任選項a,則應該爲命令行中membername參數指定一個已經存在的成員名。
  • [b]/[i] - put file(s) before [member-name] (same as [i]) //在庫的一個已經存在的成員前面增加一個新的文件。
  • [D] - use zero for timestamps and uids/gids //對uid/gid使用”0”時間戳
  • [U] - use actual timestamps and uids/gids (default) //對uid/gid使用實際的時間戳(默認)
  • [N] - use instance [count] of name //與count參數一起使用,在庫中有多個相同的文件名時指定提取或輸出的個數。
  • [f] - truncate inserted file names //在庫中截短指定的名字。
  • [P] - use full path names when matching //進行文件名匹配時使用全路徑名。ar在創建庫時不能使用全路徑名(這樣的庫文件不符合POSIX標準),但是有些工具可以。
  • [o] - preserve original dates //當提取成員時,保留成員的原始數據。如果不指定該任選項,則提取出的模塊的時間將標爲提取出的時間。
  • [u] - only replace files that are newer than current archive contents //一般說來,命令ar r…插入所有列出的文件到庫中,如果你只想插入列出文件中那些比庫中同名文件新的文件,就可以使用該任選項。該任選項只用於r操作選項。

可與操作指令結合使用的一般修飾符選項 [csSTvV]
generic modifiers:

  • [c] - do not warn if the library had to be created //創建一個庫。不管庫是否存在,都將創建。
  • [s] - create an archive index (cf. ranlib) //寫入一個目標文件索引到庫中,或者更新一個存在的目標文件索引。甚至對於沒有任何變化的庫也作該動作。對一個庫做ar s等同於對該庫做ranlib。
  • [S] - do not build a symbol table //不創建目標文件索引,這在創建較大的庫時能加快時間。
  • [T] - make a thin archive //減小文件大小
  • [v] - be verbose //該選項用來顯示執行操作選項的附加信息。
  • [V] - display the version number //ar的版本信息

@file - read options from file
–target=BFDNAME - specify the target object format as BFDNAME
optional:
–plugin p - load the specified plugin

supported targets:
elf64-x86-64 elf32-i386 elf32-x86-64 a.out-i386-linux pei-i386 pei-x86-64 elf64-l1om elf64-k1om elf64-little elf64-big elf32-little elf32-big pe-x86-64 pe-i386 plugin srec symbolsrec verilog tekhex binary ihex


2.ldd

命令介紹:
  ldd命令用於打印程序或者庫文件所依賴的共享庫列表。

命令用法:
  Usage: ldd [OPTION]… FILE…

[OPTION]選項:

  • –version print version information and exit //版本號打印
  • -d, –data-relocs process data relocations //執行重定位和報告任何丟失的對象
  • -r, –function-relocs process data and function relocations //執行數據對象和函數的重定位,並且報告任何丟失的對象和函數
  • -u, –unused print unused direct dependencies //打印未使用的直接依賴
  • -v, –verbose print all information //詳細信息模式,打印所有相關信息
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章