免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 541 | 回复: 0
打印 上一主题 下一主题

查询系统帮助 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-04-24 13:05 |只看该作者 |倒序浏览
查询系统帮助

1、        man命令用法:man 待查的命令名称
manpath 查询man的路径  
[root@REDSHEEP bill]# manpath
/usr/share/man:/usr/X11R6/man:/usr/kerberos/man:/usr/man

2、        简易帮助查询  whatis 和apropos命令用法 whatis 待查的命令名称
     apropos 待查的命令名称

3、        搜索文件及目录  find 命令格式(find 路径 参数 等等)
★在特定的目录下搜索并显示指定的名称的文件和目录
例:find /etc –name man –print
    find /  –name man  
★搜索一段时间内被存取/ 变更的文件或目录
使用参数-amin(分钟)或-atime(小时)《a开头表示access 存取》,  
如果是变更则用-cmin(分钟)和-ctime(小时)《c开头表示changes》
[root@REDSHEEP bill]# find /home -amin 10  
[root@REDSHEEP bill]# find /home -atime 10
[root@REDSHEEP bill]# find /home -cmin 10
[root@REDSHEEP bill]# find /home -ctime 10
★搜索指定用户创建的文件或目录
  使用-user参数
如在/home由root所创建的文件或目录
[root@REDSHEEP bill]# find /home -user root
/home
/home/bill/mount
………
★搜索后执行指定的命令
参数是 –exec linux管理上经常使用这个特性删除系统中的core(是指系统执行程序发生错误的时候,会将残留在内存中的数据存成core文件)
清除的命令如下:
[root@REDSHEEP bill]# find / -name core -print -exec rm -rf {} \;

{}表示所有搜索的结果 最后必须以\; 结尾 否则会出错find: missing argument to `-exec'
★        搜索特定大小的文件 -size
b(block)系统默认 ; c(byte单位) ;k(Kbytes单位);w(2个bytes为单位)
搜索大于100K的文件
[root@REDSHEEP bill]# find /  -size +100k




4、文件和目录简易搜索 locate  whereis(搜索源代码,二进制文件或是帮助文件) 和which查讯命令所在的位置
[root@REDSHEEP home]# whereis cd ls
cd: /usr/share/man/man1/cd.1.gz
ls: /bin/ls /usr/share/man/man1/ls.1.gz

[root@REDSHEEP home]# which reboot ls mv
alias ls='ls --color=tty'
        /bin/ls
alias mv='mv -i'
        /bin/mv
/usr/bin/reboot
[root@REDSHEEP home]#

5、        搜索包含特定字符串的文件  ――――  grep(Global Regular Expression Print)
不能在指定的目录中搜索 ,只能在指定的对象目录中搜索
如:[root@REDSHEEP root]# grep -n 'myshare' /etc/samba/*.*
/etc/samba/smb.conf:304:;[myshare]
搜寻的字符需用符号 ‘’
管道《|》将结果传到wc计算 字符串的 列数 字数 和字节数
[root@REDSHEEP root]# grep -n 'share' /etc/samba/*.*  (-n显示在第几行)
/etc/samba/smb.conf:75:;   ssl CA certFile = /usr/share/ssl/certs/ca-bundle.crt
/etc/samba/smb.conf:158:#        You must uncomment the [Profiles] share below
/etc/samba/smb.conf:180:# NOTE: These can be set on a per share basis
/etc/samba/smb.conf:206:;   share modes = no
/etc/samba/smb.conf:209:# Un-comment the following to provide a specific roving profile share
/etc/samba/smb.conf:228:# This one is useful for people to share files
/etc/samba/smb.conf:285:   path = /share/aaa
/etc/samba/smb.conf:290: path = /share/bbb
/etc/samba/smb.conf:299:# The following two entries demonstrate how to share a directory so that two
/etc/samba/smb.conf:304:;[myshare]
/etc/samba/smb.conf:306:;   path = /usr/somewhere/shared
[root@REDSHEEP root]# grep -n 'share' /etc/samba/*.* | wc
     11      78     720 à 11表示行数  78表示字数 720表示bytes数

参数-v 表示反转搜索的意思 他会显示不含字符串的内容
命令格式:grep -v 'share' /etc/samba/*.*


管道《|》作用
如想搜索/usr/bin 中与install有关的文件
[root@REDSHEEP root]# ls -al /usr/bin | grep install
-rwxr-xr-x    1 root     root        45027 Aug  7  2002 desktop-file-install
-rwxr-xr-x    1 root     root        51547 Jul 26  2002 gnome-font-install
-rwxr-xr-x    1 root     root        11993 Aug 29  2002 gpilot-install-file
………………
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP