linux学习命令总结⑩④

#ldd命令:查看应用程序所依赖的共享库

二进制程序:bin /bin

[root@VM_168_102_centos ~]# ldd /bin/df
    linux-vdso.so.1 =>  (0x00007ffff77ff000)
    libc.so.6 => /lib64/libc.so.6 (0x00000037a7600000)
    /lib64/ld-linux-x86-64.so.2 (0x00000037a6e00000)

ldd –v 显示更加详细信息

[root@VM_168_102_centos ~]# ldd -v /bin/df
    linux-vdso.so.1 =>  (0x00007fff1548c000)
    libc.so.6 => /lib64/libc.so.6 (0x00000037a7600000)
    /lib64/ld-linux-x86-64.so.2 (0x00000037a6e00000)

    Version information:
    /bin/df:
        libc.so.6 (GLIBC_2.3) => /lib64/libc.so.6
        libc.so.6 (GLIBC_2.4) => /lib64/libc.so.6
        libc.so.6 (GLIBC_2.3.4) => /lib64/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
    /lib64/libc.so.6:
        ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2
        ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-x86-64.so.2

#rpm包管理

rpm –i:安装指定rpm包

[root@VM_168_102_centos ~]# rpm -ihv amtu-1.0.8-11.el6.x86_64.rpm 
warning: amtu-1.0.8-11.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:amtu                   ########################################### [100%]

-v/-vv/-vvv:显示更加详细的信息

-h:以#的个数显示安装进度,一个#表示2%的进度

rpm –ivh --test:测试安装,不真正执行安装过程

[root@VM_168_102_centos ~]# rpm -ihv --test amtu-1.0.8-11.el6.x86_64.rpm 
warning: amtu-1.0.8-11.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]

rpm –ivh –nodeps:安装时忽略依赖关系

[root@VM_168_102_centos ~]# rpm -ivh gnupg2-smime-2.0.14-8.el6.x86_64.rpm 
warning: gnupg2-smime-2.0.14-8.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
    dirmngr is needed by gnupg2-smime-2.0.14-8.el6.x86_64
    gnupg2 = 2.0.14-8.el6 is needed by gnupg2-smime-2.0.14-8.el6.x86_64
    libksba.so.8()(64bit) is needed by gnupg2-smime-2.0.14-8.el6.x86_64
    libksba.so.8(KSBA_0.9)(64bit) is needed by gnupg2-smime-2.0.14-8.el6.x86_64
[root@VM_168_102_centos ~]# rpm -ivh --nodeps gnupg2-smime-2.0.14-8.el6.x86_64.rpm 
warning: gnupg2-smime-2.0.14-8.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:gnupg2-smime           ########################################### [100%]

rpm –ivh --replacepkgs:无论软件包是否已被安装,都强行安装软件包

[root@VM_168_102_centos ~]# rpm -q aide
aide-0.14-7.el6.x86_64
[root@VM_168_102_centos ~]# rpm -ivh --replacepkgs aide-0.14-7.el6.x86_64.rpm 
warning: aide-0.14-7.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:aide                   ########################################### [100%]
[root@VM_168_102_centos ~]# rpm -ivh aide-0.14-7.el6.x86_64.rpm 
warning: aide-0.14-7.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
    package aide-0.14-7.el6.x86_64 is already installed

rpm -e:卸载

如果有依赖关系:1、把依赖者一同卸载;2、忽略依赖关系 --nodeps;

[root@VM_168_102_centos ~]# rpm -e gnupg2
error: Failed dependencies:
    gnupg2 is needed by (installed) gpgme-1.1.8-3.el6.x86_64
    gnupg2 = 2.0.14-8.el6 is needed by (installed) gnupg2-smime-2.0.14-8.el6.x86_64
[root@VM_168_102_centos ~]# rpm -q gnupg2
gnupg2-2.0.14-4.el6.x86_64
[root@VM_168_102_centos ~]# rpm -e --nodeps gnupg2
[root@VM_168_102_centos ~]# rpm -q gnupg2
package gnupg2 is not installed

rpm –q package_name:查询软件包是否已经安装

[root@VM_168_102_centos ~]# rpm -q aide
aide-0.14-7.el6.x86_64
[root@VM_168_102_centos ~]# rpm -q zsh
package zsh is not installed

rpm -qa:查询所有已经安装的包

rpm -qi package_name:查询包的描述信息

[root@VM_168_102_centos ~]# rpm -qi aide
Name        : aide                         Relocations: (not relocatable)
Version     : 0.14                              Vendor: CentOS
Release     : 7.el6                         Build Date: Mon Jul 28 19:06:21 2014
Install Date: Mon Aug 25 10:54:15 2014         Build Host: c6b9.bsys.dev.centos.org
Group       : Applications/System           Source RPM: aide-0.14-7.el6.src.rpm
Size        : 303714                           License: GPLv2+
Signature   : RSA/SHA1, Fri Aug  1 03:27:40 2014, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem <http://bugs.centos.org>
URL         : http://sourceforge.net/projects/aide
Summary     : Intrusion detection environment
Description :
AIDE (Advanced Intrusion Detection Environment) is a file integrity
checker and intrusion detection program.

rpm –ql package_name:查询包安装之后在当前系统生成的文件列表

[root@VM_168_102_centos ~]# rpm -ql aide
/etc/aide.conf
/etc/logrotate.d/aide
/usr/sbin/aide
/usr/share/doc/aide-0.14
/usr/share/doc/aide-0.14/AUTHORS
/usr/share/doc/aide-0.14/COPYING
/usr/share/doc/aide-0.14/ChangeLog
/usr/share/doc/aide-0.14/NEWS
/usr/share/doc/aide-0.14/README
/usr/share/doc/aide-0.14/README.quickstart
/usr/share/doc/aide-0.14/contrib
/usr/share/doc/aide-0.14/contrib/bzip2.sh
/usr/share/doc/aide-0.14/contrib/gpg2_check.sh
/usr/share/doc/aide-0.14/contrib/gpg2_update.sh
/usr/share/doc/aide-0.14/contrib/gpg_check.sh
/usr/share/doc/aide-0.14/contrib/gpg_update.sh
/usr/share/doc/aide-0.14/contrib/sshaide.sh
/usr/share/doc/aide-0.14/manual.html
/usr/share/man/man1/aide.1.gz
/usr/share/man/man5/aide.conf.5.gz
/var/lib/aide
/var/log/aide

rpm –qf /path/to/file:查询某文件是哪个包安装生成的

[root@VM_168_102_centos ~]# rpm -qf /bin/df
coreutils-8.4-19.el6.x86_64

rpm –qd package_name:查询包安装后生成的帮助文档

[root@VM_168_102_centos ~]# rpm -qd aide
/usr/share/doc/aide-0.14/AUTHORS
/usr/share/doc/aide-0.14/COPYING
/usr/share/doc/aide-0.14/ChangeLog
/usr/share/doc/aide-0.14/NEWS
/usr/share/doc/aide-0.14/README
/usr/share/doc/aide-0.14/README.quickstart
/usr/share/doc/aide-0.14/contrib/bzip2.sh
/usr/share/doc/aide-0.14/contrib/gpg2_check.sh
/usr/share/doc/aide-0.14/contrib/gpg2_update.sh
/usr/share/doc/aide-0.14/contrib/gpg_check.sh
/usr/share/doc/aide-0.14/contrib/gpg_update.sh
/usr/share/doc/aide-0.14/contrib/sshaide.sh
/usr/share/doc/aide-0.14/manual.html
/usr/share/man/man1/aide.1.gz
/usr/share/man/man5/aide.conf.5.gz

rpm –qc package_name:查询包安装后生成的配置文件

[root@VM_168_102_centos ~]# rpm -qc aide
/etc/aide.conf
/etc/logrotate.d/aide

rpm –qpl:查询尚未安装的rpm包安装后会生成的文件列表

[root@VM_168_102_centos ~]# rpm -q aide                       
package aide is not installed
[root@VM_168_102_centos ~]# rpm -qpl aide-0.14-7.el6.x86_64.rpm 
warning: aide-0.14-7.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
/etc/aide.conf
/etc/logrotate.d/aide
/usr/sbin/aide
/usr/share/doc/aide-0.14
/usr/share/doc/aide-0.14/AUTHORS
/usr/share/doc/aide-0.14/COPYING
/usr/share/doc/aide-0.14/ChangeLog
/usr/share/doc/aide-0.14/NEWS
/usr/share/doc/aide-0.14/README
/usr/share/doc/aide-0.14/README.quickstart
/usr/share/doc/aide-0.14/contrib
/usr/share/doc/aide-0.14/contrib/bzip2.sh
/usr/share/doc/aide-0.14/contrib/gpg2_check.sh
/usr/share/doc/aide-0.14/contrib/gpg2_update.sh
/usr/share/doc/aide-0.14/contrib/gpg_check.sh
/usr/share/doc/aide-0.14/contrib/gpg_update.sh
/usr/share/doc/aide-0.14/contrib/sshaide.sh
/usr/share/doc/aide-0.14/manual.html
/usr/share/man/man1/aide.1.gz
/usr/share/man/man5/aide.conf.5.gz
/var/lib/aide
/var/log/aide

rpm –qpi:查询尚未安装的rpm包安装后的描述信息

[root@VM_168_102_centos ~]# rpm -q aide
package aide is not installed
[root@VM_168_102_centos ~]# rpm -qpi aide-0.14-7.el6.x86_64.rpm 
warning: aide-0.14-7.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Name        : aide                         Relocations: (not relocatable)
Version     : 0.14                              Vendor: CentOS
Release     : 7.el6                         Build Date: Mon Jul 28 19:06:21 2014
Install Date: (not installed)               Build Host: c6b9.bsys.dev.centos.org
Group       : Applications/System           Source RPM: aide-0.14-7.el6.src.rpm
Size        : 303714                           License: GPLv2+
Signature   : RSA/SHA1, Fri Aug  1 03:27:40 2014, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem <http://bugs.centos.org>
URL         : http://sourceforge.net/projects/aide
Summary     : Intrusion detection environment
Description :
AIDE (Advanced Intrusion Detection Environment) is a file integrity
checker and intrusion detection program.

 

#find命令:用于在文件树种查找文件,并作出相应的处理

find [选项] [查找路径] [查找条件] [处理动作]

查找条件:

-name:根据文件名查找文件,支持globbing

[root@VM_168_102_centos tmp]# find /tmp/ -name "c*"
/tmp/ceshi.sh
/tmp/ceshi

-iname:根据文件名查找文件,不区分大小写

[root@VM_168_102_centos tmp]# find /tmp/ -iname "c*"
/tmp/ceshi.sh
/tmp/ceshi
/tmp/Ceshi

-user user_name:根据文件属主查找

[root@VM_168_102_centos tmp]# find /tmp/ -user wanghan
/tmp/find.sh
/tmp/test
[root@VM_168_102_centos tmp]# find /tmp/ -uid 500     
/tmp/find.sh
/tmp/test

-group group_name:根据文件属组查找

[root@VM_168_102_centos tmp]# find /tmp/ -group wanghan
/tmp/find.sh
/tmp/ceshi
/tmp/test
[root@VM_168_102_centos tmp]# find /tmp/ -gid 500      
/tmp/find.sh
/tmp/ceshi
/tmp/test
[root@VM_168_102_centos tmp]# ls -l /tmp/find.sh 
-rw-rw-r-- 1 wanghan wanghan 0 Aug 25 15:11 /tmp/find.sh

-nouser:查找没有属主的文件

[root@VM_168_102_centos tmp]# find /tmp/ -nouser
/tmp/find.sh
/tmp/test
[root@VM_168_102_centos tmp]# ls -l /tmp/find.sh 
-rw-rw-r-- 1 500 500 0 Aug 25 15:11 /tmp/find.sh

-nogroup:查找没有属组的文件

[root@VM_168_102_centos tmp]# find /tmp/ -nogroup
/tmp/find.sh
/tmp/ceshi
/tmp/test
[root@VM_168_102_centos tmp]# ls -ld ceshi
drwxr-xr-x 2 root 500 4096 Aug 25 15:08 ceshi

组合条件:

-a:与,同时满足

[root@VM_168_102_centos tmp]# find /tmp/ -iname "c*" -a -nouser
[root@VM_168_102_centos tmp]# find /tmp/ -iname "c*" -a -nogroup
/tmp/ceshi

-o:或,满足任意其中一个条件就会被查找到

[root@VM_168_102_centos tmp]# find /tmp/ -iname "c*" -o -nouser | xargs ls -ld
drwxr-xr-x 2 root root 4096 Aug 25 15:03 /tmp/Ceshi
drwxr-xr-x 2 root  500 4096 Aug 25 15:08 /tmp/ceshi
-rw-r--r-- 1 root root  153 Aug 22 11:49 /tmp/ceshi.sh
-rw-rw-r-- 1  500  500    0 Aug 25 15:11 /tmp/find.sh
drwxrwxr-x 2  500  500 4096 Aug 25 15:12 /tmp/test

-not/!:非,取反

[root@VM_168_102_centos tmp]# find /tmp/ -not -user root | xargs ls -ld
-rw-rw-r-- 1 500 500    0 Aug 25 15:11 /tmp/find.sh
drwxrwxr-x 2 500 500 4096 Aug 25 15:12 /tmp/test

-type:根据文件类型查找

f:普通文件

d:目录

b:块设备

c:字符设备

l:符号链接

p:命名管道

s:套接字

[root@VM_168_102_centos tmp]# find /tmp -type f | xargs ls -ld
-rw-r--r-- 1 root root         14 Aug 25 15:57 /tmp/.PATH
-rw------- 1 root root          0 Aug 22 08:31 /tmp/ap_1002.pid
-rw------- 1 root root          0 Aug 22 08:55 /tmp/ap_1004.pid
-rw------- 1 root root          0 Aug 22 09:34 /tmp/ap_1005.pid
-rw------- 1 root root          0 Aug 22 09:55 /tmp/ap_1007.pid
-rw------- 1 root root          0 Aug 22 09:16 /tmp/ap_1008.pid
-rw-r--r-- 1 root root        153 Aug 22 11:49 /tmp/ceshi.sh
-rw-rw-r-- 1  500  500          0 Aug 25 15:11 /tmp/find.sh
-rw-r--r-- 1 root root        153 Aug 22 11:48 /tmp/new_test.sh
-rw-r--r-- 1 root root 1073741824 Aug 22 16:06 /tmp/swap1
-rw-r--r-- 1 root root        512 Aug 22 14:48 /tmp/xvdb
-rw------- 1 root root        370 Aug 25 10:05 /tmp/yum_save_tx-2014-08-25-10-058uNVYH.yumtx
[root@VM_168_102_centos tmp]# find /tmp -type d | xargs ls -ld
drwxrwxrwt 9 root root 4096 Aug 25 15:12 /tmp
drwxrwxrwt 2 root root 4096 Aug 21 20:50 /tmp/.ICE-unix
drwxr-xr-x 2 root root 4096 Aug 25 15:03 /tmp/Ceshi
drwxr-xr-x 2 root  500 4096 Aug 25 15:08 /tmp/ceshi
drwxrwxr-x 2  500  500 4096 Aug 25 15:12 /tmp/test
drwxr-xr-x 2 root root 4096 Aug 21 20:57 /tmp/wanghan
drwxr-xr-x 2 root root 4096 Aug 22 16:31 /tmp/xvdb1
drwxr-xr-x 2 root root 4096 Aug 22 16:31 /tmp/xvdb2

-size:根据文件大小查找

-size [+|-] #Unit

[root@VM_168_102_centos tmp]# find /tmp/ -size 4k | xargs ls –ldh #等于4K
drwxrwxrwt 9 root root 4.0K Aug 25 15:12 /tmp/
drwxrwxrwt 2 root root 4.0K Aug 21 20:50 /tmp/.ICE-unix
drwxr-xr-x 2 root root 4.0K Aug 25 15:03 /tmp/Ceshi
drwxr-xr-x 2 root  500 4.0K Aug 25 15:08 /tmp/ceshi
drwxrwxr-x 2  500  500 4.0K Aug 25 15:12 /tmp/test
drwxr-xr-x 2 root root 4.0K Aug 21 20:57 /tmp/wanghan
drwxr-xr-x 2 root root 4.0K Aug 22 16:31 /tmp/xvdb1
drwxr-xr-x 2 root root 4.0K Aug 22 16:31 /tmp/xvdb2
[root@VM_168_102_centos tmp]# find /tmp/ -size -4k | xargs ls –ldh #小于4k 
-rw-r--r-- 1 root root  14 Aug 25 16:04 /tmp/.PATH
srwxrwxrwx 1 root root   0 Aug 22 10:07 /tmp/agent_cmd.sock
-rw------- 1 root root   0 Aug 22 08:31 /tmp/ap_1002.pid
-rw------- 1 root root   0 Aug 22 08:55 /tmp/ap_1004.pid
-rw------- 1 root root   0 Aug 22 09:34 /tmp/ap_1005.pid
-rw------- 1 root root   0 Aug 22 09:55 /tmp/ap_1007.pid
-rw------- 1 root root   0 Aug 22 09:16 /tmp/ap_1008.pid
-rw-r--r-- 1 root root 153 Aug 22 11:49 /tmp/ceshi.sh
-rw-rw-r-- 1  500  500   0 Aug 25 15:11 /tmp/find.sh
lrwxrwxrwx 1 root root  13 Aug 22 16:57 /tmp/new_ceshi.sh -> /tmp/ceshi.sh
-rw-r--r-- 1 root root 153 Aug 22 11:48 /tmp/new_test.sh
lrwxrwxrwx 1 root root  12 Aug 22 17:00 /tmp/new_wanghan -> /tmp/wanghan
-rw-r--r-- 1 root root 512 Aug 22 14:48 /tmp/xvdb
-rw------- 1 root root 370 Aug 25 10:05 /tmp/yum_save_tx-2014-08-25-10-058uNVY
[root@VM_168_102_centos tmp]# find /tmp/ -size +4k | xargs ls –ldh #大于4K
-rw-r--r-- 1 root root 1.0G Aug 22 16:06 /tmp/swap1

根据时间戳查找:

以天为单位:

-atime [+|-]# :

+:表示#天之内没有访问过

[root@VM_168_102_centos tmp]# find /tmp/ -atime +2 | xargs stat
  File: `/tmp/  Size: 4096          Blocks: 8          IO Block: 4096   directory
Device: ca01h/51713d    Inode: 458753      Links: 9
Access: (1777/drwxrwxrwt)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-11-14 21:01:36.000000000 +0800
Modify: 2014-08-25 15:12:12.000000000 +0800
Change: 2014-08-25 15:12:12.000000000 +0800
  File: `/tmp/new_test.sh  Size: 153           Blocks: 8          IO Block: 4096   regular file
Device: ca01h/51713d    Inode: 458763      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2014-08-22 11:48:33.000000000 +0800
Modify: 2014-08-22 11:48:33.000000000 +0800
Change: 2014-08-22 16:50:09.000000000 +0800

-:表示#天之内访问过

[root@VM_168_102_centos tmp]# find /tmp/ -atime -2 | xargs stat
  File: `/tmp/find.sh  Size: 0             Blocks: 0          IO Block: 4096   regular empty file
Device: ca01h/51713d    Inode: 458773      Links: 1
Access: (0664/-rw-rw-r--)  Uid: (  500/ UNKNOWN)   Gid: (  500/ UNKNOWN)
Access: 2014-08-25 15:11:59.000000000 +0800
Modify: 2014-08-25 15:11:59.000000000 +0800
Change: 2014-08-25 15:11:59.000000000 +0800

无符号:表示短于(#+1)>x>=#天的时间被访问过

[root@VM_168_102_centos tmp]# find /tmp/ -atime 2 | xargs stat
  File: `/tmp/xvdb2  Size: 4096          Blocks: 8          IO Block: 4096   directory
Device: ca01h/51713d    Inode: 458767      Links: 2
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2014-08-22 16:31:38.000000000 +0800
Modify: 2014-08-22 16:31:38.000000000 +0800
Change: 2014-08-25 03:33:01.000000000 +0800

-mtime:内容修改时间

-ctime:属性变动时间

以分钟为单位:

-amin

-mmin

-cmin

根据权限查找文件:

-perm [+|-] MODE

MODE:表示严格匹配,也就是你的文件权限位转换成对应的十进制数字与mode一模一样,那么匹配成功,需要注意的是如果mode给的数字不足3位,那么前面自动添0

[root@VM_168_102_centos tmp]# find /tmp/ -perm 777 | xargs ls -ld
srwxrwxrwx 1 root root  0 Aug 22 10:07 /tmp/agent_cmd.sock
lrwxrwxrwx 1 root root 13 Aug 22 16:57 /tmp/new_ceshi.sh -> /tmp/ceshi.sh
lrwxrwxrwx 1 root root 12 Aug 22 17:00 /tmp/new_wanghan -> /tmp/wanghan

-MODE:表示mode中转换成二进制的1在文件权限位里面必须匹配,比如mode=644那么转换成二进制为110 100 100,而被查找的文件的权限位也可以被转换成一个二进制数,两者在位上为1的部分必须完全匹配,而0则不管。例如被查找的文件的权限为转换成二进制数是111 111 111那么这个比如被匹配,而假如是100 100 100那么则不会匹配。所以这个‘-‘的作用归结起来就是匹配比mode权限更充足的文件

[root@VM_168_102_centos tmp]# find /tmp/ -perm -644 | xargs ls -ld
drwxrwxrwt 9 root root       4096 Aug 25 15:12 /tmp/
drwxrwxrwt 2 root root       4096 Aug 21 20:50 /tmp/.ICE-unix
-rw-r--r-- 1 root root         14 Aug 25 16:50 /tmp/.PATH
drwxr-xr-x 2 root root       4096 Aug 25 15:03 /tmp/Ceshi
srwxrwxrwx 1 root root          0 Aug 22 10:07 /tmp/agent_cmd.sock
drwxr-xr-x 2 root  500       4096 Aug 25 15:08 /tmp/ceshi
-rw-r--r-- 1 root root        153 Aug 22 11:49 /tmp/ceshi.sh
-rw-rw-r-- 1  500  500          0 Aug 25 15:11 /tmp/find.sh
lrwxrwxrwx 1 root root         13 Aug 22 16:57 /tmp/new_ceshi.sh -> /tmp/ceshi.sh
-rw-r--r-- 1 root root        153 Aug 22 11:48 /tmp/new_test.sh
lrwxrwxrwx 1 root root         12 Aug 22 17:00 /tmp/new_wanghan -> /tmp/wanghan
-rw-r--r-- 1 root root 1073741824 Aug 22 16:06 /tmp/swap1
drwxrwxr-x 2  500  500       4096 Aug 25 15:12 /tmp/test
drwxr-xr-x 2 root root       4096 Aug 21 20:57 /tmp/wanghan
-rw-r--r-- 1 root root        512 Aug 22 14:48 /tmp/xvdb
drwxr-xr-x 2 root root       4096 Aug 22 16:31 /tmp/xvdb1
drwxr-xr-x 2 root root       4096 Aug 22 16:31 /tmp/xvdb2
[root@VM_168_102_centos tmp]# find /tmp/ -perm 644 | xargs ls -ld
-rw-r--r-- 1 root root         14 Aug 25 16:50 /tmp/.PATH
-rw-r--r-- 1 root root        153 Aug 22 11:49 /tmp/ceshi.sh
-rw-r--r-- 1 root root        153 Aug 22 11:48 /tmp/new_test.sh
-rw-r--r-- 1 root root 1073741824 Aug 22 16:06 /tmp/swap1
-rw-r--r-- 1 root root        512 Aug 22 14:48 /tmp/xvdb

+MODE:与 -mode的区别是+mode只需其中的任意一个1的部分被匹配,-mode是所有1的部分都必须被匹配,同样+mode也不管0位

[root@VM_168_102_centos tmp]# find /tmp/ -perm +644 | xargs ls -ld
drwxrwxrwt 9 root root       4096 Aug 25 15:12 /tmp/
drwxrwxrwt 2 root root       4096 Aug 21 20:50 /tmp/.ICE-unix
-rw-r--r-- 1 root root         14 Aug 25 16:51 /tmp/.PATH
drwxr-xr-x 2 root root       4096 Aug 25 15:03 /tmp/Ceshi
srwxrwxrwx 1 root root          0 Aug 22 10:07 /tmp/agent_cmd.sock
-rw------- 1 root root          0 Aug 22 08:31 /tmp/ap_1002.pid
-rw------- 1 root root          0 Aug 22 08:55 /tmp/ap_1004.pid
-rw------- 1 root root          0 Aug 22 09:34 /tmp/ap_1005.pid
-rw------- 1 root root          0 Aug 22 09:55 /tmp/ap_1007.pid
-rw------- 1 root root          0 Aug 22 09:16 /tmp/ap_1008.pid

处理动作:

-ls:以长格式输出各文件信息

[root@VM_168_102_centos tmp]# find /tmp/ -name "c*" -ls
458762    4 -rw-r--r--   1 root     root          153 Aug 22 11:49 /tmp/ceshi.sh
458772    4 drwxr-xr-x   2 root     500          4096 Aug 25 15:08 /tmp/ceshi

find | xargs COMMAND:对查找到的文件执行指定的命令

[root@VM_168_102_centos tmp]# find /tmp/ -name "c*" | xargs ls -ld
drwxr-xr-x 2 root  500 4096 Aug 25 15:08 /tmp/ceshi
-rw-r--r-- 1 root root  153 Aug 22 11:49 /tmp/ceshi.sh

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。