一、文件属性

  • 权限位:

  1. - 表示文件
  2.  
  3. d 表示目录
  4.  
  5. l 表示软连接
  6.  
  7. b 表示接口存储设备文件
  8.  
  9. c 表示串行端口设备
  • 文件的时间属性
  1. [root@web02 ~]# ll /etc/passwd      ####默认显示的时间属性为mtime(modification time)文件内容变更时间
  2. -rw-r--r-- root root 4 : /etc/passwd
  3. [root@web02 ~]# ll --time=atime /etc/passwd  #####atime(access time)文件被访问时间
  4. -rw-r--r-- root root 5 : /etc/passwd
  5. [root@web02 ~]# ll --time=ctime /etc/passwd  #####ctime(status time)文件状态时间,文件属性被修改会更改这个属性
  6. -rw-r--r-- root root 4 : /etc/passwd
  • 权限对于文件的意义

  

  1.   rread):可读取文件的实际内容
  2.  
  3.   wwrite):可以编辑、新增或修改文件的内容(但不能删除)
  4.  
  5.   xexecute):可以被系统执行
  • 权限对于目录的意义
  1.   r:表示具有读取目录结构的权限,如:可以用ls查看目录内容
  2.  
  3.   w:表示可以新增、删除、更改、移动该目录下的文件或目录
  4.  
  5.   x:表示可以进入该目录
  • 文件与目录得默认权限
  1. [root@web01 tmp]# umask
  2.  
  3. 若使用者创建为『文件』则默认『没有可运行( x )权限』,亦即只有 rw 这两个权限,也就是最大为
  4. 若使用者创建为『目录』,则由于 x 与是否可以进入此目录有关,因此默认为所有权限均开放,亦即为
  5. umask值,是创建文件和目录时需要减掉得权限,所以创建文件时权限为644,目录为755
  • 文件隐藏属性
  1. [root@web01 tmp]# chattr +i passwd.bk   ######## +i属性,不能删除,不能更改
  2. [root@web01 tmp]# lsattr passwd.bk
  3. ----i--------e- passwd.bk
  4. [root@web01 tmp]# chattr -i passwd.bk
  5. [root@web01 tmp]# chattr +a passwd.bk   ####### +a属性,只能添加内容,不能删除内容
  6. [root@web01 tmp]# >passwd.bk
  7. -bash: passwd.bk: 不允许的操作
  8. [root@web01 tmp]# lsattr passwd.bk
  9. -----a-------e- passwd.bk

二、命令操作

  • 创建目录
  1. [root@web01 tmp]# ll
  2. 总用量
  3. [root@web01 tmp]# mkdir test
  4. [root@web01 tmp]# ls
  5. test
  6. [root@web01 tmp]# mkdir test/test1/test2   ####不能直接创建多层目录
  7. mkdir: 无法创建目录"test/test1/test2": 没有那个文件或目录  
  8. [root@web01 tmp]# mkdir -p test/test1/test2    #####-p 递归创建目录
  9. [root@web01 tmp]# ll
  10. 总用量
  11. drwxr-xr-x root root 5 : test
  12. [root@web01 tmp]# mkdir -m test1  ####-m 创建目录时,给予属性
  13. [root@web01 tmp]# ll
  14. 总用量
  15. drwxr-xr-x root root 5 : test
  16. drwx--x--x root root 5 : test1
  • 创建文件
  1. [root@web01 tmp]# ll
  2. 总用量
  3. -rw-r--r-- root root 5 : file.txt
  4. drwxr-xr-x root root 5 : test
  5. drwx--x--x root root 5 : test1
  • 复制文件或目录
  1. [root@web01 tmp]# cp -p /etc/passwd passwd  #####连同文件得属性一起复制(备份常用)
  2. [root@web01 tmp]# ll /etc/passwd passwd
  3. -rw-r--r-- root root 5 : /etc/passwd
  4. -rw-r--r-- root root 5 : passwd
  5. [root@web01 tmp]# cp /etc/ssh/ test
  6. cp: 略过目录"/etc/ssh/"
  7. [root@web01 tmp]# cp -r /etc/ssh/ test  ####递归复制,用于目录得复制
  8. [root@web01 tmp]# ll test
  9. 总用量
  10. drwxr-xr-x root root 5 : ssh
  11. drwxr-xr-x root root 5 : test1
  12. [root@web01 tmp]# cp -a /var/log/wtmp wtmp.bk  ###相当于-pdr -d为复制链接文件属性,而非文件实体
  13. [root@web01 tmp]# ll /var/log/wtmp wtmp.bk
  14. -rw-rw-r--. root utmp 5 : /var/log/wtmp
  15. -rw-rw-r--. root utmp 5 : wtmp.bk
  • 移动文件或目录
  1. [root@web01 tmp]# mv -u /etc/passwd passwd   ####如果目标文件存在,当源文件比较新得时候才会移动
  2. [root@web01 tmp]# mv -f /etc/passwd passwd   #####如果目标存在,强制覆盖
  • 删除文件或目录
  1. [root@web01 tmp]# rm file.txt
  2. rm:是否删除普通空文件 "file.txt"n
  3. [root@web01 tmp]# ll
  4. 总用量
  5. -rw-r--r-- root 5 : file.txt
  6. -rw-r--r-- root 5 : passwd
  7. drwxr-xr-x root 5 : test
  8. drwx--x--x root 5 : test1
  9. -rw-rw-r--. utmp 5 : wtmp.bk
  10. [root@web01 tmp]# rm -f file.txt   ######强制删除
  11. [root@web01 tmp]# ll
  12. 总用量
  13. -rw-r--r-- root 5 : passwd
  14. drwxr-xr-x root 5 : test
  15. drwx--x--x root 5 : test1
  16. -rw-rw-r--. utmp 5 : wtmp.bk
  17. [root@web01 tmp]# rm -f test
  18. rm: 无法删除"test": 是一个目录
  19. [root@web01 tmp]# rm -rf test    ########递归删除,删除目录
  20. [root@web01 tmp]# ll
  21. 总用量
  22. -rw-r--r-- root 5 : passwd
  23. drwx--x--x root 5 : test1
  24. -rw-rw-r--. utmp 5 : wtmp.bk[root@web01 tmp]# ll test1/总用量 0[root@web01 tmp]# rmdir test1/  ########删除空目录[root@web01 tmp]# ll总用量 84-rw-r--r--  1 0 root  1948 5月  29 17:35 passwd-rw-rw-r--. 1 0 utmp 76032 5月  29 15:22 wtmp.bk
  • 文件名变更
  1. [root@web01 tmp]# ll
  2. 总用量
  3. -rw-r--r-- root 5 : passwd
  4. drwxr-xr-x root 5 : test
  5. -rw-rw-r--. utmp 5 : wtmp.bk
  6. [root@web01 tmp]# mv passwd passwd.bk  #######同路径为改名
  7. [root@web01 tmp]# mv test test1
  8. [root@web01 tmp]# ll
  9. 总用量
  10. -rw-r--r-- root 5 : passwd.bk
  11. drwxr-xr-x root 5 : test1
  12. -rw-rw-r--. utmp 5 : wtmp.bk
  • 查看文件
  1. [root@web01 tmp]# cat passwd.bk
  2. root:x:::root:/root:/bin/bash
  3. bin:x:::bin:/bin:/sbin/nologin
  4. daemon:x:::daemon:/sbin:/sbin/nologin
  5. [root@web01 tmp]# cat -n passwd.bk
  6. root:x:::root:/root:/bin/bash
  7. bin:x:::bin:/bin:/sbin/nologin
  8. daemon:x:::daemon:/sbin:/sbin/nologin
  9.  
  10. [root@web01 tmp]# more passwd.bk    ####以一页一页显示内容,不可向上翻[root@web01 tmp]# less passwd.bk    ####以一页一页像是内容,可向上翻[root@web01 tmp]# head -1 passwd.bk   ######从头开始显示一行root:x:0:0:root:/root:/bin/bash[root@web01 tmp]# tail -1 passwd.bk   #####从末尾开始显示一行test112:x:1014:1014::/home/test112:/bin/bash
  • 查找文件
  1. [root@web01 tmp]# whereis ifconfig  ####查找数据库中得数据
  2. ifconfig: /sbin/ifconfig /usr/share/man/man8/ifconfig..gz
  3. [root@web01 tmp]# locate ifconfig  #####从数据库中查找数据
  4. /sbin/ifconfig
  5. /usr/sbin/pifconfig
  6. /usr/share/man/de/man8/ifconfig..gz
  7. /usr/share/man/fr/man8/ifconfig..gz
  8. /usr/share/man/man8/ifconfig..gz
  9. /usr/share/man/man8/pifconfig..gz
  10. /usr/share/man/pt/man8/ifconfig..gz[root@web01 tmp]# updatedb  ####更新locate数据库
  11.  
  12. [root@web01 tmp]# find / -mtime 0  ######将/目录下,24小时内更改过得文件列出[root@web01 tmp]# find / -mtime -4  #####将/目录下,小于等于4天以内更改过的文件列出[root@web01 tmp]# find / -mtime 4  #####将/目录下,4-5那一天变动得文件列出[root@web01 tmp]# find / -mtime +4  #####将/目录下,大于等于5天前变动得文件列出[root@web01 tmp]# find /tmp -name passwd.bk #######查找/tmp目录下文件名为passwd.bk的文件/tmp/passwd.bk[root@web01 tmp]# find /tmp -type f  ######查找/tmp目录下的文件/tmp/passwd.bk/tmp/wtmp.bk[root@web01 tmp]# find /tmp -type d  #####查找/tmp目录的目录/tmp/tmp/.ICE-unix/tmp/test1[root@web01 tmp]# find /tmp -size +50k  #####查找/tmp目录下大于50k的文件/tmp/wtmp.bk[root@web01 tmp]# find /tmp -size -50k  #####查找/tmp目录下小于50k的文件/tmp/tmp/.ICE-unix/tmp/passwd.bk/tmp/test1

centos6 文件管理的更多相关文章

  1. VMware下CentOS6.8配置GFS文件系统

    1.GFS介绍 GFS简要说明,它有两种: 1. Google文件系统:GFS是GOOGLE实现的是一个可扩展的分布式文件系统,用于大型的.分布式的.对大量数据进行访问的应用.它运行于廉价的普通硬件上 ...

  2. VirtualBox中安装CentOS-6.6虚拟机

    1. 下载 可以到官网下载,http://mirror.centos.org/centos/ 如果下载速度太慢的话,也可以到163镜像下载: http://mirrors.163.com/centos ...

  3. VirtualBox中安装CentOS-6.6虚拟机(转载)

    1. 下载 可以到官网下载,http://mirror.centos.org/centos/ 如果下载速度太慢的话,也可以到163镜像下载: http://mirrors.163.com/centos ...

  4. centos6.3 + db2v9.7的数据库移行

    工作内容如题,我要做的事情大体如下: 1,正确备份可用数据库: 2,安装64位的cent os 6.3: 3,将1备份的数据恢复到新的cent os 6.3系统上. 第一件事情,就是备份一个可用的数据 ...

  5. centos6.5环境基于conga的web图形化界面方式配置rhcs集群

    一.简介 RHCS 即 RedHat Cluster Suite ,中文意思即红帽集群套件.红帽集群套件(RedHat Cluter Suite, RHCS)是一套综合的软件组件,可以通过在部署时采用 ...

  6. Linux权限管理(用户、组、文件管理)

    一. Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示. 1. 文件查看类命令cat,tac, head, tail, more, less, ls ,file: -ls : l ...

  7. 在Centos6.5上部署kvm虚拟化技术

    KVM是什么? KVM 全称是 基于内核的虚拟机(Kernel-based Virtual Machine),它是一个 Linux 的一个内核模块,该内核模块使得 Linux 变成了一个 Hyperv ...

  8. 3-2 LInux文件管理

    LInux文件管理 文件系统目录结构 Linux中目录结构是有一定的约定的FHS /bin:存放二进制程序 /boot:启动相关 /dev:设备文件 /etc:配置文件 /home:用户家目录 /li ...

  9. Linux安装LAMP开发环境及配置文件管理

    Linux主要分为两大系发行版,分别是RedHat和Debian,lamp环境的安装和配置也会有所不同,所以分别以CentOS 7.1和Ubuntu 14.04做为主机(L) Linux下安装软件,最 ...

随机推荐

  1. 扭曲效果 效率优化 GrapPass,CommandBuffer对比

    屏幕图像捕捉: Shader的GrabPass GrabPass可以很方便地捕获当前渲染时刻的FrameBuffer中的图像. 其原理就是从当前FrameBuffer中copy一份纹理,通过SetTe ...

  2. 第三篇(那些JAVA程序BUG中的常见单词)

    illegal modifier for parameter xxx; only final is permitted 参数xxx的修饰符非法:只允许final illegal 非法的 modifie ...

  3. 【原创】《从0开始学Elasticsearch》—初识Elasticsearch

    目录 1. Elasticsearch 是什么2. Elasticsearch 中基本概念3. Elasticsearch 安装4. 访问 Elasticsearch 1. Elasticsearch ...

  4. python之排序算法-冒泡、选排、快排

    影响内排序算法性能的三个因素: 时间复杂度:即时间性能,高效率的排序算法应该是具有尽可能少的关键字比较次数和记录的移动次数 空间复杂度:主要是执行算法所需要的辅助空间,越少越好. 算法复杂性.主要是指 ...

  5. python正则表达式_总结

    正则表达式: 作用:正则表达式是用来查找字符串的. 之前:使用正则表达式首先要导入re模块(import re) re.match -- 从字符串的第一个单词开始匹配字符串.如果匹配到则返回一个对象: ...

  6. [Usaco2017 Feb]Why Did the Cow Cross the Road II (Gold)

    Description 上下有两个长度为n.位置对应的序列A.B, 其中数的范围均为1~n.若abs(A[i]-B[j])<= 4,则A[i]与B[j]间可以连一条边. 现要求在边与边不相交的情 ...

  7. Coins HDU - 2844 POJ - 1742

    Coins HDU - 2844 POJ - 1742 多重背包可行性 当做一般多重背包,二进制优化 #include<cstdio> #include<cstring> in ...

  8. 数学 SCU 4436 Easy Math

    题目传送门 /* 数学题:当有一个数开根号后是无理数,则No */ #include <cstdio> #include <algorithm> #include <cs ...

  9. Python multiprocessing相关疑问

    1. multiprocessing 和 threading有什么区别? threading module并没有真正利用多核.而multiprocessing 利用subprocess避开了pytho ...

  10. D. Green and Black Tea 贪心 + 构造

    http://codeforces.com/contest/746/problem/D 首先说下一定是NO的情况. 假设a > b 那么,b最多能把a分成b + 1分,如果每份刚好是k的话,那么 ...