命令用法 locate,grep,ps -ef,
来源:互联网 发布:组件功率优化器 编辑:程序博客网 时间:2024/05/22 17:24
命令用途
grep -RHn* 全局搜索命令
ps -ef | grep nginx
ps -ef 是显示当前进程的列表
| 是管线命令,表示由|后面的命令来处理|前面的命令的正确输出
grep httpd 表示找出含有http字符串的那一行
ps -ef 是显示当前进程的列表
| 是管线命令,表示由|后面的命令来处理|前面的命令的正确输出
grep httpd 表示找出含有http字符串的那一行
ps -C httpd|wc -l
wc表示计算有多少行http
所以结果就是当前进程里有多少个http在运行。
所以结果就是当前进程里有多少个http在运行。
locate 让使用者可以很快速的搜寻档案系统内是否有指定的档案。其方法是先建立一个包括系统内所有档案名称及路径的数据库,之后当寻找时就只需查询这个数据库,而不必实际深入档案系统之中了。所以你要知道:1. locate的速度比find快,因为它并不是真的查找文件,而是查数据库2. locate的查找并不是实时的,而是以数据库的更新为准,一般是系统自己维护
3. 升级数据库命令:locate -- u命令用法
#查看locate版本信息-V
- bixiaopeng@bixiaopeng-To-be-filled-by-O-E-M:~$ locate -V
- mlocate 0.25
- Copyright (C) 2007 Red Hat, Inc. 保留所有权利。
- 本软件在 GPL v.2 下发布。
- 本程序不提供任何担保,在法法律允许的范围内予以排除。
#查看locate帮助信息
- bixiaopeng@bixiaopeng-To-be-filled-by-O-E-M:~$ locate -h
- 用法: locate [OPTION]... [PATTERN]...
- 在mlocate数据库中搜索条目.
- -b, --basename 匹配唯一的路径名称的基本文件名
- -c, --count 只显示找到条目的号码
- -d, --database DBPATH 用 DBPATH 替代默认的数据库(/var/lib/mlocate/mlocate.db)
- -e, --existing 只显示当前存在的文件条目
- -L, --follow 当文件存在时跟随蔓延的符号链接 (默认)
- -h, --help 显示本帮助
- -i, --ignore-case 匹配模式时忽略大小写区别
- -l, --limit, -n LIMIT 限制为 LIMIT项目的输出 (或 计数)
- -m, --mmap 忽略向后兼容性
- -P, --nofollow, -H 当检查文件时不跟随蔓延的符号
- 链接
- -0, --null 输出时以 NUL 分隔项目
- -S, --statistics 不搜索项目,显示有关每个已用数据库的统计信息
- -q, --quiet 不报告关于读取数据库的错误消息
- -r, --regexp REGEXP 搜索基本正则表达式 REGEXP 来代替模式
- --regex 模式是扩展正则表达式
- -s, --stdio 忽略向后兼容性
- -V, --version 显示版本信息
- -w, --wholename 匹配完整路径名 (默认)
- 将 bug 报告给 mitr@redhat.com.
# 查找etc目录下所有以sh开头的文件
- bixiaopeng@bixiaopeng-To-be-filled-by-O-E-M:~$ locate /etc/sh
- /etc/shadow
- /etc/shadow-
- /etc/shells
#查看soft目录下以android开头的文件,限定只显示5个,使用 -n
- bixiaopeng@bixiaopeng-To-be-filled-by-O-E-M:~$ locate -n 5 /soft/android
- /home/bixiaopeng/soft/android-studio
- /home/bixiaopeng/soft/android-studio-bundle-130.737825-linux.tgz
- /home/bixiaopeng/soft/android-studio/Install-Linux-tar.txt
- /home/bixiaopeng/soft/android-studio/LICENSE.txt
- /home/bixiaopeng/soft/android-studio/NOTICE.txt
#查找时区分大小写
- bixiaopeng@bixiaopeng-To-be-filled-by-O-E-M:~$ locate makefile
- /usr/share/doc/python3-uno/demo/makefile.mk
- /usr/share/emacs/23.4/lisp/cedet/ede/makefile-edit.elc
- /usr/share/gtksourceview-3.0/language-specs/makefile.lang
- /usr/share/icons/Humanity/mimes/16/gnome-mime-text-x-makefile.svg
- /usr/share/icons/Humanity/mimes/22/gnome-mime-text-x-makefile.svg
- .....
#查找时不区分大小写,使用 -i
- bixiaopeng@bixiaopeng-To-be-filled-by-O-E-M:~$ locate -i makefile
- /usr/src/linux-headers-3.8.0-30/kernel/Makefile
- /usr/src/linux-headers-3.8.0-30/kernel/debug/Makefile
- /usr/src/linux-headers-3.8.0-30/kernel/debug/kdb/Makefile
- /usr/src/linux-headers-3.8.0-30/kernel/events/Makefile
- ......
# ------------- 使用正规运算式 做查找的条件 locate -r
#查找以makefile结尾的文件
- bixiaopeng@bixiaopeng-To-be-filled-by-O-E-M:~$ locate -r makefile$
- /usr/src/linux-headers-3.8.0-19/scripts/mkmakefile
- /usr/src/linux-headers-3.8.0-19-generic/scripts/mkmakefile
- /usr/src/linux-headers-3.8.0-27/scripts/mkmakefile
- /usr/src/linux-headers-3.8.0-27-generic/scripts/mkmakefile
- /usr/src/linux-headers-3.8.0-29/scripts/mkmakefile
- /usr/src/linux-headers-3.8.0-29-generic/scripts/mkmakefile
- /usr/src/linux-headers-3.8.0-30/scripts/mkmakefile
- /usr/src/linux-headers-3.8.0-30-generic/scripts/mkmakefile
#查找以/var/lib/dpkg/info/开头的文件
- bixiaopeng@bixiaopeng-To-be-filled-by-O-E-M:~$ locate -r ^/var/lib/dpkg/info/
- /var/lib/dpkg/info/zlib1g:amd64.postinst
- /var/lib/dpkg/info/zlib1g:amd64.postrm
- /var/lib/dpkg/info/zlib1g:amd64.shlibs
- /var/lib/dpkg/info/zlib1g:amd64.symbols
- /var/lib/dpkg/info/zlib1g:i386.list
- /var/lib/dpkg/info/zlib1g:i386.md5sums
- /var/lib/dpkg/info/zlib1g:i386.postinst
- /var/lib/dpkg/info/zlib1g:i386.postrm
- /var/lib/dpkg/info/zlib1g:i386.shlibs
- /var/lib/dpkg/info/zlib1g:i386.symbols
0 0
- 命令用法 locate,grep,ps -ef,
- ps -ef | grep tomcat 命令详解
- ps -ef|grep ssh
- ps -ef|grep解析
- ps -ef|grep php
- ps -ef|grep tomcat
- ps -ef |grep java
- ps -ef | grep **
- ps -ef |grep java
- ps -ef | grep 解释
- ps -ef | grep java
- Linux中ps -ef | grep tomcat命令详解
- linux命令ps aux|grep java和ps -ef|grep java 有什么区别?
- linux命令ps aux|grep java和ps -ef|grep java 有什么区别?
- Linux学习11_linux grep命令及ps -ef | grep java的含义
- ps -aux ps -ef 命令
- ps -aux ps -ef 命令
- ps -aux ps -ef 命令
- 关于读取Properties文件以及路径问题
- Java获取IP地址 IPUtil.getRemoteIp(request)
- HTML5绘图之Canvas标签 绘制坐标轴
- OpenJDK和SunJDK有啥区别?
- 各大热补丁方案分析和比较
- 命令用法 locate,grep,ps -ef,
- android framelayout 拖动时,界面压缩变形问题
- 精确覆盖问题-跳舞链算法
- 窥探PTAM之Mapping线程
- 如何通过CorelDRAW实现图形的精确裁剪
- git 忽略文件
- 操作系统分配内存
- C#学习笔记之委托的各种写法
- 在IntelliJ IDEA14中安装go语言插件