网站首页 > 技术文章 正文
目录
1.文件和目录操作命令
2.用户和用户组操作命令
3.vim编辑器操作命令
4.打包和解压操作命令
5.系统操作命令
这是总的目录的,软件测试人员需要掌握的Linux命令会分成多个章节来写。
今天终于通过新手期了,以后每天就可以发5篇文章了,今天就再发篇文章庆祝一下。
find ---文件搜索
格式:find [搜索范围][匹配条件]
find命令
1.根据name来搜索(经常用)
a.精确搜索
[root@localhost test]# find /etc -name services
b.模糊搜索init开头的文件和目录
[root@localhost test]# find /etc -name init*
c.模糊搜索init结尾的文件和目录
[root@localhost test]# find /etc -name *init
d.模糊搜索包含init的文件和目录
[root@localhost test]# find /etc -name *init*
e.模糊搜索以init开头的后面只有三个字符串的文件或目录
* 代表一组字符串
? 代表一个字符
[root@localhost test]# find /etc -name init???
linux对大小很敏感,而且空格也敏感
[root@localhost test]# find /etc -name INIT???
f.根据name搜索时,不区分大小写用选项 -iname
[root@localhost test]# find /etc -iname INIT???
/etc/inittab
[root@localhost test]# find /etc -name INIT???
没有搜索出任何数据
find命令不区分大小写
2.根据文件大小搜索
a.大于4096的文件 +4096
[root@localhost test]# find /etc -size +4096
b.小于4096的文件 -4096
[root@localhost test]# find /etc -size -4096
c.等于4096的文件
[root@localhost test]# find /etc -size 4096
d.大于4096同时小于641020的文件 -a
[root@localhost test]# find /etc -size +4096 -a -size -641020
e.大于4096或者小于641020的文件
[root@localhost test]# find /etc -size +4096 -o -size -641020
3.根据文件所有者去搜索
[root@localhost test]# find /home/test -user test
[root@localhost test]# find -user test
如果不写搜索范围,默认搜索从当前目录开始,搜索下面匹配的文件和目录
4.根据文件属性搜索
a.搜索5分钟之内内容被修改的文件
[root@localhost test]# find . -mmin -5
文件内容被修改的同时,文件属性也会被修改
b.搜索3分钟之内文件属性被修改的文件
[root@localhost test]# find . -cmin -3
amin cmin mmin后面接分钟
atime ctime mtime后面接小时
5.根据文件类型来搜索
- 二进制文件f d 目录 l 软链接
1.搜索目录---文件类型为d
[root@localhost test]# find . -type d
2.搜索当前目录下文件类型为文件 f
[root@localhost test]# find . -type - ---错误
find: -type 的参数未知: -
[root@localhost test]# find . -type f ---正确
3.搜索当前目录下的文件类型为软链接 l
[root@localhost test]# find . -type l
4.在根目录下搜索文件名称为services的文件
[root@localhost test]# find / -name services -type f
grep --搜索文件的内容
1.搜索test.log这个文件中包含qwer字符串的行
[root@localhost test]# grep qwer ./test.log
2.不区分大小写进行搜索 选项 -i
[root@localhost test]# grep -i test test.log
3.搜索不包含123的文件内容
[root@localhost test]# grep -v 123 test.log
4.搜索不包含test的文件内容,不区分大小写
[root@localhost test]# grep -iv test test.log
5.搜索不是以1开头的文件内容
[root@localhost test]# grep -v ^1 test.log
6.搜索以1开头的行
[root@localhost test]# grep ^1 test.log
^ 表示以什么开头
在shell脚本 #表示注释
7.屏蔽掉注释行 --
[root@localhost test]# grep -v ^# sysctl.conf
8.经常使用的一种方法---管道 |
[root@localhost test]# ps -ef |grep java
ps -ef 查询进程
|管道符 command1 | command2
将command1的输出作为command2的输入
[root@localhost test]# ls -l |grep test
ln --链接命令
链接分为软链接和硬链接
1.给目录创建软链接 -s
[root@localhost tmp]# ln -s /tmp/test/test12/test ./test1
lrwxrwxrwx. 1 root root 21 Apr 14 21:06 test1 -> /tmp/test/test12/test
软链接的大小非常小,只是一个链接
软链接相当于windows下面的快捷方式
2.给文件创建软链接
[root@localhost tmp]# ln -s /tmp/test/test12/test/tw.log .
软链接的目标文件和原文件的i节点不同
3.给文件创建一个硬链接
[root@localhost tmp]# ln /tmp/test/test12/test/tw.log ./tw1.log
硬链接的i节点相同
[root@localhost tmp]# ln /tmp/test/test12/test ./test_dir
ln: `/tmp/test/test12/test': hard link not allowed for directory'
硬链接不能针对目录使用,只能对文件使用
find命令和grep命令是软件测试人员经常使用的命令,一定要多练习。
猜你喜欢
- 2024-10-19 Java高频面试题之Linux(java面试 linux)
- 2024-10-19 性能测试能力提升-JVM GC监控和优化
- 2024-10-19 排查GC问题常用的工具(排查问题的方式有哪些)
- 2024-10-19 开发好物推荐8之自动化部署插件,再也不用登录SSH
- 2024-10-19 20道阿里巴巴中高级java面试题详解,把这些弄懂offer拿到你手软
- 2024-10-19 Java Web实战篇:发布和运维必备的12条Linux命令
- 2024-10-19 Java工程师常用Linux命令大全(linux javac)
- 2024-10-19 玩转linux下启动jar和关闭jar方式(java程序员必看)
- 2024-10-19 超详细的EFK安装部署教程--环境准备篇
- 2024-10-19 为什么阿里架构师是这样定位Java性能问题的?这几点总结的很详细
- 最近发表
- 标签列表
-
- cmd/c (64)
- c++中::是什么意思 (83)
- 标签用于 (65)
- 主键只能有一个吗 (66)
- c#console.writeline不显示 (75)
- pythoncase语句 (81)
- es6includes (73)
- sqlset (64)
- windowsscripthost (67)
- apt-getinstall-y (86)
- node_modules怎么生成 (76)
- chromepost (65)
- c++int转char (75)
- static函数和普通函数 (76)
- el-date-picker开始日期早于结束日期 (70)
- localstorage.removeitem (74)
- vector线程安全吗 (70)
- & (66)
- java (73)
- js数组插入 (83)
- linux删除一个文件夹 (65)
- mac安装java (72)
- eacces (67)
- 查看mysql是否启动 (70)
- 无效的列索引 (74)