/*********************************************************************
* Author          :     lile
* Modified        :     2019年12月28日星期六  13:36:13
* Email           :     roger0212@163.com
* HomePage        :     lile777.blog.csdn.net
* CopyRight       :     该文章版权由lile所有。
*                       保留原文出处链接和本声明的前提下,可在非商业目的下任意传播和复制。
*                       对于商业目的下对本文的任何行为需经作者同意。
*********************************************************************/

1. # ldd cfconv /查看程序使用的动态库

[root@localhost helloqt]# ldd cfconv                     / 查看程序使用的动态库
        linux-gate.so.1 =>  (0x00826000)
        libqt-mt.so.3 => /usr/local/qt/lib/libqt-mt.so.3 (0x008c0000)
        libXext.so.6 => /usr/lib/libXext.so.6 (0x00110000)
        libX11.so.6 => /usr/lib/libX11.so.6 (0x00120000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00222000)
        libm.so.6 => /lib/libm.so.6 (0x0030d000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00336000)
        libc.so.6 => /lib/libc.so.6 (0x00342000)
        libGL.so.1 => /usr/lib/libGL.so.1 (0x03200000)
        libXmu.so.6 => /usr/lib/libXmu.so.6 (0x03c59000)
        libXrender.so.1 => /usr/lib/libXrender.so.1 (0x00496000)
        libXrandr.so.2 => /usr/lib/libXrandr.so.2 (0x0049f000)
        libXcursor.so.1 => /usr/lib/libXcursor.so.1 (0x004a6000)
        libXinerama.so.1 => /usr/lib/libXinerama.so.1 (0x004b0000)
        libXft.so.2 => /usr/lib/libXft.so.2 (0x00835000)
        libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x004b3000)
        libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0x0053d000)
        libSM.so.6 => /usr/lib/libSM.so.6 (0x0056c000)
        libICE.so.6 => /usr/lib/libICE.so.6 (0x00575000)
        libdl.so.2 => /lib/libdl.so.2 (0x0058f000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x00594000)
        libXau.so.6 => /usr/lib/libXau.so.6 (0x005ac000)
        libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x005af000)
        /lib/ld-linux.so.2 (0x008a3000)
        libXxf86vm.so.1 => /usr/lib/libXxf86vm.so.1 (0x031f9000)
        libdrm.so.2 => /usr/lib/libdrm.so.2 (0x007df000)
        libXt.so.6 => /usr/lib/libXt.so.6 (0x0319f000)
        libXfixes.so.3 => /usr/lib/libXfixes.so.3 (0x005b5000)
        libexpat.so.0 => /lib/libexpat.so.0 (0x005ba000)


2. # top /相当于 windows下的任务管理器


[root@localhost helloqt]# top             /相当于 windows下的任务管理器
top - 10:42:13 up  1:42,  1 user,  load average: 0.44, 0.36, 0.27
Tasks: 120 total,   2 running, 117 sleeping,   0 stopped,   1 zombie
Cpu(s):  1.3%us,  1.3%sy,  0.0%ni, 97.0%id,  0.0%wa,  0.3%hi,  0.0%si,  0.0%st
Mem:    515288k total,   502464k used,    12824k free,   106068k buffers
Swap:  2031608k total,        0k used,  2031608k free,   219604k cached


  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                         
 3496 root      15   0  149m  12m 5648 S  1.7  2.5   0:30.77 Xorg                                                                                            
  244 root      15   0     0    0    0 S  0.3  0.0   0:00.55 pdflush                                                                                         
 2210 root      15   0 39784 4144 3336 S  0.3  0.8   0:07.97 vmtoolsd                                                                                        
 3340 root      18   0  3136  868  752 S  0.3  0.2   0:01.21 hald-addon-stor                                                                                 
 3874 root      15   0  119m  22m  12m R  0.3  4.4   0:03.77 gnome-terminal                                                                                  
    1 root      15   0  2140  632  544 S  0.0  0.1   0:01.77 init                                                                                            
    2 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0                                                                                     
    3 root      34  19     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/0                                                                                     
    4 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/0                                                                                      
    5 root      10  -5     0    0    0 S  0.0  0.0   0:00.07 events/0                                                                                        
    6 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 khelper        



3. # objdump cfconv /可以用来反汇编

[root@localhost helloqt]# objdump   cfconv                                    /可以用来反汇编
Usage: objdump <option(s)> <file(s)>
 Display information from object <file(s)>.
 At least one of the following switches must be given:
  -a, --archive-headers    Display archive header information
  -f, --file-headers       Display the contents of the overall file header
  -p, --private-headers    Display object format specific file header contents
  -h, --[section-]headers  Display the contents of the section headers
  -x, --all-headers        Display the contents of all headers
  -d, --disassemble        Display assembler contents of executable sections
  -D, --disassemble-all    Display assembler contents of all sections
  -S, --source             Intermix source code with disassembly
  -s, --full-contents      Display the full contents of all sections requested
  -g, --debugging          Display debug information in object file
  -e, --debugging-tags     Display debug information using ctags style
  -G, --stabs              Display (in raw form) any STABS info in the file
  -W, --dwarf              Display DWARF info in the file
  -t, --syms               Display the contents of the symbol table(s)
  -T, --dynamic-syms       Display the contents of the dynamic symbol table
  -r, --reloc              Display the relocation entries in the file
  -R, --dynamic-reloc      Display the dynamic relocation entries in the file
  @<file>                  Read options from <file>
  -v, --version            Display this program's version number
  -i, --info               List object formats and architectures supported
  -H, --help               Display this information


4. # uname -a /查看系统信息

[root@localhost helloqt]# uname -a                                /查看系统信息
Linux localhost.localdomain 2.6.21-1.3194.fc7 #1 SMP Wed May 23 22:35:01 EDT 2007 i686 athlon i386 GNU/Linux

5. # vmstat /查看系统虚拟机各资源信息

[root@localhost helloqt]# vmstat                                /查看系统虚拟机各资源信息
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0  10048 106412 208040    0    0    50    14   13  178  1  2 92  5  0



6. # file cfconv /查看文件格式

[root@localhost helloqt]# file cfconv                                /查看文件格式
cfconv: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped


7. # cat /etc/shells /查看文件

[root@localhost helloqt]# cat /etc/shells 
/bin/sh
/bin/bash
/sbin/nologin
/bin/tcsh
/bin/csh
[root@localhost helloqt]# /bin/sh
sh-3.2# 
sh-3.2# /bin/csh 
[root@localhost helloqt]# 
[root@localhost helloqt]# /bin/tcsh 
[root@localhost helloqt]# 
[root@localhost helloqt]# /bin/bash
[root@localhost helloqt]# 
[root@localhost helloqt]# echo $SHELL
/bin/bash


8. # Vim+xxd /强大的十六进制编辑器

vim是黑客文化中强大的编辑器。利用它调用外部十六进制文件显示命令xxd就可以顺利的编辑二进制文件了。
其中,%在vimComandLine时代表当前文件的路径,xxd是以十六进制显示一个文件,xxd -r>是将十六进制还原为二进制。
下面举一个例子,备份我们的MBR。
sudo dd if=/dev/sda of=~/mbr.backup bs=512 count=1
题外话:其中含有分区表,这时我们可以利用这个命令恢复我们的MBr:
sudo dd if=~/mbr.backup of=/dev/sda bs=512 count=1
sudo dd if=~/mbr.backup of=/dev/sda bs=1 count=66 seek=446(恢复分区表)
好了,这个就是我们的MBR文件,是二进制的。


首先以二进制的方式打开它:
vim mbr.backup -b
再在vim 命令模式下输入:
:%!xxd #参数%指当前所编辑的文件 
此时MBR文件会以十六进制显示,现在就可以编辑它了。。
========================================================
 
 
0000090: be88 7de8 1c01 be05 7cf6 c280 7448 b441 ..}.....|...tH.A
00000a0: bbaa 55cd 135a 5272 3d81 fb55 aa75 3783 ..U..ZRr=..U.u7.
00000b0: e101 7432 31c0 8944 0440 8844 ff89 4402 ..t21..D.@.D..D.
00000c0: c704 1000 668b 1e5c 7c66 895c 0866 8b1e ....f..\|f.\.f..
00000d0: 607c 6689 5c0c c744 0600 70b4 42cd 1372 `|f.\..D..p.B..r
00000e0: 05bb 0070 eb76 b408 cd13 730d f6c2 800f ...p.v....s.....
00000f0: 84d0 00be 937d e982 0066 0fb6 c688 64ff .....}...f....d.
0000100: 4066 8944 040f b6d1 c1e2 0288 e888 f440 @f.D...........@
0000110: 8944 080f b6c2 c0e8 0266 8904 66a1 607c .D.......f..f.`|
0000120: 6609 c075 4e66 a15c 7c66 31d2 66f7 3488 f..uNf.\|f1.f.4.
0000130: d131 d266 f774 043b 4408 7d37 fec1 88c5 .1.f.t.;D.}7....
0000140: 30c0 c1e8 0208 c188 d05a 88c6 bb00 708e 0........Z....p.
0000150: c331 dbb8 0102 cd13 721e 8cc3 601e b900 .1......r...`...
0000160: 018e db31 f6bf 0080 8ec6 fcf3 a51f 61ff ...1..........a.
0000170: 265a 7cbe 8e7d eb03 be9d 7de8 3400 bea2 &Z|..}....}.4...
0000180: 7de8 2e00 cd18 ebfe 4752 5542 2000 4765 }.......GRUB .Ge
0000190: 6f6d 0048 6172 6420 4469 736b 0052 6561 om.Hard Disk.Rea
00001a0: 6400 2045 7272 6f72 0d0a 00bb 0100 b40e d. Error........
00001b0: cd10 ac3c 0075 f4c3 e3b9 76fb 0000 8001 ...<.u....v.....
00001c0: 0100 07fe ffff 3f00 0000 499d d801 00fe ......?...I.....
00001d0: ffff 0ffe ffff c59d d801 eb4c 6a23 0000 ...........Lj#..
00001e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00001f0: 0000 0000 0000 0000 0000 0000 0000 55aa ..............U.


 
================================================================
编辑完了以后,我们需要还原为二进制文件:
:%!xxd -r #参数-r是指将当前的十六进制转换为二进制


好了,保存退出:
:wq
==========================================



9. # cp命令

cp命令用来复制文件或者目录,是Linux系统中最常用的命令之一。一般情况下,shell会设置一个别名,在命令行下复制文件时,如果目标文件已经存在,就会询问是否覆盖,不管你是否使用-i参数。但是如果是在shell脚本中执行cp时,没有-i参数时不会询问是否覆盖。这说明命令行和shell脚本的执行方式有些不同。 
1.命令格式:
用法:
  cp [选项]... [-T] 源 目的
   或:cp [选项]... 源... 目录
   或:cp [选项]... -t 目录 源...

2.命令功能:
将源文件复制至目标文件,或将多个源文件复制至目标目录。
3.命令参数:
-a, --archive    等于-dR --preserve=all
    --backup[=CONTROL    为每个已存在的目标文件创建备份
-b                类似--backup 但不接受参数
   --copy-contents        在递归处理是复制特殊文件内容
-d                等于--no-dereference --preserve=links
-f, --force        如果目标文件无法打开则将其移除并重试(当 -n 选项
                    存在时则不需再选此项)
-i, --interactive        覆盖前询问(使前面的 -n 选项失效)
-H                跟随源文件中的命令行符号链接
-l, --link            链接文件而不复制
-L, --dereference   总是跟随符号链接
-n, --no-clobber   不要覆盖已存在的文件(使前面的 -i 选项失效)
-P, --no-dereference   不跟随源文件中的符号链接
-p                等于--preserve=模式,所有权,时间戳
    --preserve[=属性列表   保持指定的属性(默认:模式,所有权,时间戳),如果
               可能保持附加属性:环境、链接、xattr 等
-R, -r, --recursive  复制目录及目录内的所有项目


10. # tar常见文件解压法

tar -czf ../jpg.tar.gz *.jpg   
//将目录里所有jpg文件打包成jpg.tar后,并且将其用gzip压缩,生成一个gzip压缩过的包,命名为jpg.tar.gz

tar -cjf ../jpg.tar.bz2 *.jpg 
//将目录里所有jpg文件打包成jpg.tar后,并且将其用bzip2压缩,生成一个bzip2压缩过的包,命名为jpg.tar.bz2

tar常见文件解压法:
    .gz - z 小写;
    .bz2 - j 小写;
    .xz - J 大写; /// tar xvJf  ***.tar.xz
    .Z - Z大写; 

或者 xf -- 自行识别
	tar xf abc.tgz -C /home/abc/
	==========================================================================
tar.gz    VS  tar.bz2  —— .bz2 压缩比更高
root@desktop:armfs# ll ../newfs.tar.*
-rw-r--r-- 1 root root 72741334 2016-09-07 00:09 ../newfs.tar.bz2
-rw-r--r-- 1 root root 93796646 2016-09-06 23:39 ../newfs.tar.gz

root@desktop:targetfs_ok# ll  ../targetfs_ok*
-rwxrw-rw-  1 root     root     11708465 2016-09-07 00:07 ../targetfs_ok.tar.bz2*
-rw-r--r--  1 root     root     12929841 2016-09-07 00:03 ../targetfs_ok.tar.gz


	

11. # du -sh dir /查看文件夹文件总大小


root@RogerPC:~# du -sh ./test/
1.4M	./test/

12. # df -h   /查看磁盘使用情况

root@RogerPC:~# df -hT
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sda5     ext4     14G   12G  2.1G  85% /
none      devtmpfs    498M  252K  497M   1% /dev
none         tmpfs    502M   24K  502M   1% /dev/shm
none         tmpfs    502M  280K  501M   1% /var/run
none         tmpfs    502M     0  502M   0% /var/lock
none         tmpfs    502M     0  502M   0% /lib/init/rw

13. # od -c file     /以逐个字符输出文件内容

root@RogerPC:test# od -c 1.sh 
0000000   #   !   /   b   i   n   /   s   h  \n   f   d   i   s   k    
0000020   /   d   e   v   /   d   b   a       -   p       -   d       -
0000040   u       -   n  \n
0000045
root@RogerPC:test# 

14 # stat     查看文件属性

root@RogerPC:test# stat a.out 
  File: `a.out'
  Size: 5972      	Blocks: 16         IO Block: 4096   regular file
Device: 805h/2053d	Inode: 267748      Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2016-09-14 16:59:45.302470501 +0800
Modify: 2016-09-14 16:17:01.773796273 +0800
Change: 2016-09-14 16:20:19.008862594 +0800
root@RogerPC:test#

15 # lsattr      / 查看文件拓展属性

root@RogerPC:test# lsattr a.out 
-----------------e- a.out

16 #file filename 查看文件格式

root@RogerPC:test# file a.out 
a.out: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.14, not stripped
root@RogerPC:test#

17 # nautilus ./       / 打开文件管理器查看文件

18 # evince Guide.pdf / 使用Ubuntu默认的 PDF阅读器查看文件


###19 #dpkg -l | grep samba     //ubuntu 查看安装的软件

root@RogerPC:test# dpkg -l | grep samba
ii  samba                                2:3.4.7~dfsg-1ubuntu3.8                         SMB/CIFS file, print, and login server for U
ii  samba-common                         2:3.4.7~dfsg-1ubuntu3.8                         common files used by both the Samba server a
ii  samba-common-bin                     2:3.4.7~dfsg-1ubuntu3.1                         common files used by both the Samba server a
root@RogerPC:test# 


20 #cut -d ‘/’ -f 1 // 按照指定的分隔符截取所需要的字符段

[/] # echo '/dev/mmcblk2' | cut -d 'k' -f 2
2


21 #diff命令###

[/] # diff -ruN uboot_300Mhz/ uboot_456M/ > 456MHZ.patch

22 #date命令###

$ date -d @1404174299
Tue Jul  1 08:24:59 CST 2014
/*  时间格式转换*/

23 #ps命令

ubuntu@tegra-ubuntu:~$ stty -a |grep columns /* 获取当前中断最大字符宽度*/
speed 115200 baud; rows 24; columns 80; line = 0;
ubuntu@tegra-ubuntu:~$ 
ubuntu@tegra-ubuntu:~$ ps -ewf |grep bus /* 输出进程详细参数*/
message+   496     1  0 10:12 ?        00:00:00 dbus-daemon --system --fork
ubuntu    1180  1129  0 10:12 ?        00:00:00 dbus-daemon --fork --session --address=unix:abstract=/tmp/dbus-9uazcWwKu4
ubuntu    1197  1129  0 10:12 ?        00:00:00 upstart-dbus-bridge --daemon --system --user --bus-name system
ubuntu    1199  1129  0 10:12 ?        00:00:00 upstart-dbus-bridge --daemon --session --user --bus-name session
ubuntu    1201  1129  0 10:12 ?        00:00:00 /usr/lib/at-spi2-core/at-spi-bus-launcher --launch-immediately
ubuntu    1207  1201  0 10:12 ?        00:00:00 /bin/dbus-daemon --config-file=/etc/at-spi2/accessibility.conf --nofork --print-address 3
ubuntu   22336  1096  0 10:53 ttyS0    00:00:00 grep bus

24 #sed命令

sed -n '6p' filename     打印文件的第6行

sed -n '6,10p' filename        打印文件的第6到10行

sed '/user/d' filename 删除包含“user”的行

sed '2d' filename 删除第2行

sed '$d' filename 删除最后一行
Logo

更多推荐