Linux- 查找命令——where/which/find

1  whereis 选项

是查找工具中速度最快的,只能查找二进制程序(-b)、文档(-m)和源码(-s)

格式:  whereis  二进制命令/文件

例: whereis   touch

2  帮助

ls   –-help  |  less    

//查看命令ls的参数的使用方法,less是为了进入查看,否则内容太多的话就会一闪而过

man   命令               //查看命令帮助手册

3  which 文件名/命令名

查找命令或文件,常用于查找命令,会给用户显示出命令所在的路径以及显示命令的别名。例:which  mkdir

用alias查看所有命令的别名,

用alias也可以设置命令的别名:  #alias   别名=‘命令’  

例: #alias   shanchu=’rm  –rf’

删除别名: #unalias 别名。            

例:#unalias   shanchu             //删除rm  -rf的命令别名

4  find 

格式 : find  在哪个目录下查找  按照什么类型查找  类型参数   

1) 按照文件名进行查找   -name

例如:  find  /etc  –name  passwd

2) 按照文件类型进行查找  -type

文件类型:

目录(d)           连接文件(l)    管道文件(p)      块文件(b)  

字符文件(c)    普通文件(f)    套接字文件(s)

例如:  find  /  -type  l         //在根目录下查找连接类型的文件

3) 按照文件大小进行查找   -size

例如:  

    find   ./(当前目录) -size   +512k //查找大于512k字节的文件

    find  ~  -size    1M   //查找等于1M字节的文件

    find  /    -size    -1G   //查找小于1G字节的文件

    find  ./  -size   +10M  -size  -20M //查找大于10M小于20M的文件

注意:大于 用加号+,小于 用减号-,等于 不写。

4) 查找空文件/目录   -empty

例如:  find   ./  -empty

5) 按照文件所有者进行查找

属主 –user                            属组 –group      

UID  -uid(root 是0)             GID –gid(root组是0)

没有属主  -nouser                  没有属组  -nogroup

例如: 

      find   ./   -user   root             //查找当前目录下属主是root的文件

      find   /   -nouser   –o   -group   //查找根目录下没有属主或没有属组的文件

      find   /   -nouser   -nogroup     //查找根目录下既没有属主也没有属组的文件

6)按照文件的时间来查找

访问access时间:查看时间      

状态修改(change)时间:文件名、属主、属组更改的时间

修改过(modify)的时间:内容修改的时间   

-amin<n>  //几分钟前访问                -cmin<n>//几分钟前状态修改

-mmin <n>//几分钟前内容修改         -atime<n>  //几天前访问

-ctime<n>   //几天前状态修改          -mtime<n>   //几天前内容修改

-used<n>  //几天使用过的

例如:

      find  ~   -amin   +30        //查找30分钟前访问过的文件

      find   ~   -mtime  -1         //查找1天内被修改过的文件

      find   ~   -ctime   +1         //查找1天前状态被修改过的文件

      find   ~   -used    -2         //查找2天内使用过的文件或目录

注意: n天/分钟内用减号-  ; n天/分钟前用加号+

7)按照文件系统类型进行查找  -fstype<文件系统类型>

!-fstype<文件系统类型>  非某一文件系统类型

例如: find   ~   -name   test.txt   -fstype   ext4

//在ext4上查找文件名为test.txt的文件

8)按照权限查找  -perm <3个权限值>

每个角色:r 4   w 2  x 1  ,共三个角色: 属主  属组  其他人

find   /  -perm   777      //在根目录下查找文件权限为777的文件或目录

9)按照文件的硬连接数进行查找   -links <硬连接数>

find   ~   -links   2                //在家目录下查找硬连接数为2 的文件

find   ~   -links   +2   -links   -5    //查找硬连接数大于2小于5的文件

10)按照文件的inode号查   -inum  i节点号

find   ./   -inum   12345      

注:以后用到的都是  查找ll命令下能看到的属性,其他的都很少用到

11)find的其他用法:找到文件后执行某命令   -exec  命令 {}  \;

例如:  find  ./  -name  f1  -exec  rm  {}  \;              //找到f1后删除它

注意:\可以将命令分隔,常用于在执行多个参数长命令时


转载请注明出处,谢谢!

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Log data follows: | DEBUG: Executing shell function do_configure | CMake Warning at CMakeLists.txt:7 (message): | Build type not set, falling back to Release mode. | | To specify build type use: | -DCMAKE_BUILD_TYPE=<mode> where <mode> is Debug or Release. | | | -- Building without demo. To enable demo build use: -DWITH_DEMO=True | -- The C compiler identification is GNU 7.3.0 | -- The CXX compiler identification is GNU 7.3.0 | -- Check for working C compiler: /home/wu/test_D9/D9_PTG1.5/build-d9/tmp/work/aarch64-niic-linux/antlr4/4.7.2-r0/recipe-sysroot-native/usr/bin/aarch64-niic-linux/aarch64-niic-linux-gcc | -- Check for working C compiler: /home/wu/test_D9/D9_PTG1.5/build-d9/tmp/work/aarch64-niic-linux/antlr4/4.7.2-r0/recipe-sysroot-native/usr/bin/aarch64-niic-linux/aarch64-niic-linux-gcc -- works | -- Detecting C compiler ABI info | -- Detecting C compiler ABI info - done | -- Detecting C compile features | -- Detecting C compile features - done | -- Check for working CXX compiler: /home/wu/test_D9/D9_PTG1.5/build-d9/tmp/work/aarch64-niic-linux/antlr4/4.7.2-r0/recipe-sysroot-native/usr/bin/aarch64-niic-linux/aarch64-niic-linux-g++ | -- Check for working CXX compiler: /home/wu/test_D9/D9_PTG1.5/build-d9/tmp/work/aarch64-niic-linux/antlr4/4.7.2-r0/recipe-sysroot-native/usr/bin/aarch64-niic-linux/aarch64-niic-linux-g++ -- works | -- Detecting CXX compiler ABI info | -- Detecting CXX compiler ABI info - done | -- Detecting CXX compile features | -- Detecting CXX compile features - done | -- Found PkgConfig: /home/wu/test_D9/D9_PTG1.5/build-d9/tmp/work/aarch64-niic-linux/antlr4/4.7.2-r0/recipe-sysroot-native/usr/bin/pkg-config (found version "0.29.2") | -- Checking for module 'uuid' | -- Found uuid, version 2.32.1 | -- Output libraries to /home/wu/test_D9/D9_PTG1.5/build-d9/tmp/work/aarch64-niic-linux/antlr4/4.7.2-r0/git/runtime/Cpp/dist | CMake Error at runtime/CMakeLists.txt:104 (install): | install TARGETS given no LIBRARY DESTINATION for shared library target | "antlr4_shared". | | | CMake Error at runtime/CMakeLists.txt:107 (install): | install TARGETS given no ARCHIVE DESTINATION for static library target | "antlr4_static". | | | -- Configuring incomplete, errors occurred! | See also "/home/wu/test_D9/D9_PTG1.5/build-d9/tmp/work/aarch64-niic-linux/antlr4/4.7.2-r0/build/CMakeFiles/CMakeOutput.log".这是报错的log,如何解决这个问题
07-11
根据提供的日志,可以看出在CMake配置过程中出现了两个错误。错误信息分别是: 1. CMake Error at runtime/CMakeLists.txt:104 (install): install TARGETS given no LIBRARY DESTINATION for shared library target "antlr4_shared". 2. CMake Error at runtime/CMakeLists.txt:107 (install): install TARGETS given no ARCHIVE DESTINATION for static library target "antlr4_static". 这些错误表明在配置期间,对于共享库目标 "antlr4_shared" 没有给出 LIBRARY DESTINATION,对于静态库目标 "antlr4_static" 没有给出 ARCHIVE DESTINATION。 要解决这个问题,你可以尝试以下方法: 1. 检查CMakeLists.txt文件:打开 "/home/wu/test_D9/D9_PTG1.5/build-d9/tmp/work/aarch64-niic-linux/antlr4/4.7.2-r0/git/runtime/CMakeLists.txt" 文件,并查找与 "antlr4_shared" 和 "antlr4_static" 相关的安装指令。 2. 添加正确的目标安装路径:在对应的安装指令中,确保给出了正确的目标安装路径。例如,对于共享库目标 "antlr4_shared",应该设置 LIBRARY DESTINATION,而对于静态库目标 "antlr4_static",应该设置 ARCHIVE DESTINATION。 3. 重新运行CMake配置:保存文件,并重新运行CMake配置命令以重新生成项目。可以尝试使用以下命令:`cmake /path/to/source`。 4. 编译和安装:如果配置成功,继续进行编译和安装。使用 `make` 命令编译项目,并使用 `make install` 命令安装项目。 如果问题仍然存在,可能需要进一步检查CMakeLists.txt文件中的其他配置,以及确保所有依赖项都正确安装。在解决问题时,可以查看 "/home/wu/test_D9/D9_PTG1.5/build-d9/tmp/work/aarch64-niic-linux/antlr4/4.7.2-r0/build/CMakeFiles/CMakeOutput.log" 文件,以获取更多有关配置错误的详细信息。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

鬼刺

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值