档案 & 权限管理

1. owner, group, others

   root 是万能的天神

image

权限 连结档 owner group 容量 修改日期 档名

2. chown, chgrp, chmod

   chgrp –R root abc/

   chown –R abc:abc abc/

   chown –R    .abc abc/

   chmod –R 777 abc.txt

   chmod u=rwe, go=rx abc.txt

   chmod a+x abc.txt chmod a-x abc.txt chmod a+x abc/  ( a 就是 all )

3. cp pwd mkdir rmdir

   mkdir –m 配置目录权限, 不考虑 umask, 例如 mkdir –m 711 abc/

   mkdir –p 递归, 例如 mkdir –p test1/test2/test3/test4

   rmdir –p 递归, rmdir –p test1/test2/test3/test4 ( 文件夹必须是空的 )

   cp –a 相当于 pdr, 就是档案完全一模一样复制 ( –r 为递归复制 )

   rm –f –i –r ( 强制 提示 递归 )

   mv –f –i –u 源文件, 目的地 ( –f 强制 –i 提示 –u 只有源文件比目的地新才覆盖 )

4. basename, dirname

   basename: /var/tmp/aaa.txt ( 此处为 aaa.txt )

   dirname:  /var/tmp/aaa.txt ( 此处为 /var/tmp )

5. touch

   可以建立空档案, 修改档案时间

   modification time ( mtime 默认显示时间)

   status time ( ctime 权限等被修改的时间 )

   access time ( atime 读取时间 )

   touch –d “2 days ago” ( 只改变 atime, mtime, 没有改变ctime)

   touch –t 1305011315 xax ( 改变 atime, mtime 到 13年5月1日13点15分 )

   touch –a –t 1305011315 xax ( 只改变 atime 时间 )

   没有办法修改档案的 ctime, 只能是改变档案的权限, 才可以修改, 即便是档案的权限与之前相同, 但是只要修改了, 就会有变化

6. head tail

   head –10 xax

   tail –10 xax

7. file 查询档案是什么, 例如 ASCII 档案

8. type 查询命令类型    例如 type ls

9. which, whereis 查询命令位置

   image

10. find

   find [path][option][action]

   -print 标准输出

   -exec command {} \;  --查找到文件执行command操作,{}和\; 之间有空格

   -ok 和 –exec 相同, 只是每次执行命令的时候会提示给用户, 是否执行

   find 后边可以接很多目录, 例如 find etc home apps

   -depth 查找本level 目录后再进入子目录

   例子如下

   find . –name xax | xargs rm –rf

   find ~ –name “*.txt” –print   # 支持正则表达式

   find . –perm 755 –print

   find . –perm 770 –exec ls –l {} \;

   find . –type d –print

   find . –size +1000000c –print  # 查询大于 1M 的文件

   find . –size 1000000c –print   # 查询等于 1M 的文件

   find /etc –name “passwd*” –exec grep “admin” {} \;   # 查找看看有没有 admin这个用户

   find –mtime n ( n是n天以内, 过去<-+4,4,-4->现在 )

   参数:

   -name

   -perm

   -user

   -group

   -mtime

   -atime

   -ctime

   -nogroup

   -nouser

   -newer

   -type b/d/c/p/l/f

   -size

   -depth

   -mount ( 查文件时不跨过 mount 点 )

   -prune # 忽略某个目录

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值