Linux常用命令

来源:互联网 发布:mysql between 编辑:程序博客网 时间:2024/06/07 02:26

Linux常用命令

  • Linux常用命令
    • ar
    • ldd

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 //详细信息模式,打印所有相关信息