centos6 文件管理
一、文件属性
- 权限位:
- - 表示文件
- d 表示目录
- l 表示软连接
- b 表示接口存储设备文件
- c 表示串行端口设备
- 文件的时间属性
- [root@web02 ~]# ll /etc/passwd ####默认显示的时间属性为mtime(modification time)文件内容变更时间
- -rw-r--r-- root root 4月 : /etc/passwd
- [root@web02 ~]# ll --time=atime /etc/passwd #####atime(access time)文件被访问时间
- -rw-r--r-- root root 5月 : /etc/passwd
- [root@web02 ~]# ll --time=ctime /etc/passwd #####ctime(status time)文件状态时间,文件属性被修改会更改这个属性
- -rw-r--r-- root root 4月 : /etc/passwd
- 权限对于文件的意义
- r(read):可读取文件的实际内容
- w(write):可以编辑、新增或修改文件的内容(但不能删除)
- x(execute):可以被系统执行
- 权限对于目录的意义
- r:表示具有读取目录结构的权限,如:可以用ls查看目录内容
- w:表示可以新增、删除、更改、移动该目录下的文件或目录
- x:表示可以进入该目录
- 文件与目录得默认权限
- [root@web01 tmp]# umask
- 若使用者创建为『文件』则默认『没有可运行( x )权限』,亦即只有 rw 这两个权限,也就是最大为
- 若使用者创建为『目录』,则由于 x 与是否可以进入此目录有关,因此默认为所有权限均开放,亦即为
- umask值,是创建文件和目录时需要减掉得权限,所以创建文件时权限为644,目录为755
- 文件隐藏属性
- [root@web01 tmp]# chattr +i passwd.bk ######## +i属性,不能删除,不能更改
- [root@web01 tmp]# lsattr passwd.bk
- ----i--------e- passwd.bk
- [root@web01 tmp]# chattr -i passwd.bk
- [root@web01 tmp]# chattr +a passwd.bk ####### +a属性,只能添加内容,不能删除内容
- [root@web01 tmp]# >passwd.bk
- -bash: passwd.bk: 不允许的操作
- [root@web01 tmp]# lsattr passwd.bk
- -----a-------e- passwd.bk
二、命令操作
- 创建目录
- [root@web01 tmp]# ll
- 总用量
- [root@web01 tmp]# mkdir test
- [root@web01 tmp]# ls
- test
- [root@web01 tmp]# mkdir test/test1/test2 ####不能直接创建多层目录
- mkdir: 无法创建目录"test/test1/test2": 没有那个文件或目录
- [root@web01 tmp]# mkdir -p test/test1/test2 #####-p 递归创建目录
- [root@web01 tmp]# ll
- 总用量
- drwxr-xr-x root root 5月 : test
- [root@web01 tmp]# mkdir -m test1 ####-m 创建目录时,给予属性
- [root@web01 tmp]# ll
- 总用量
- drwxr-xr-x root root 5月 : test
- drwx--x--x root root 5月 : test1
- 创建文件
- [root@web01 tmp]# ll
- 总用量
- -rw-r--r-- root root 5月 : file.txt
- drwxr-xr-x root root 5月 : test
- drwx--x--x root root 5月 : test1
- 复制文件或目录
- [root@web01 tmp]# cp -p /etc/passwd passwd #####连同文件得属性一起复制(备份常用)
- [root@web01 tmp]# ll /etc/passwd passwd
- -rw-r--r-- root root 5月 : /etc/passwd
- -rw-r--r-- root root 5月 : passwd
- [root@web01 tmp]# cp /etc/ssh/ test
- cp: 略过目录"/etc/ssh/"
- [root@web01 tmp]# cp -r /etc/ssh/ test ####递归复制,用于目录得复制
- [root@web01 tmp]# ll test
- 总用量
- drwxr-xr-x root root 5月 : ssh
- drwxr-xr-x root root 5月 : test1
- [root@web01 tmp]# cp -a /var/log/wtmp wtmp.bk ###相当于-pdr -d为复制链接文件属性,而非文件实体
- [root@web01 tmp]# ll /var/log/wtmp wtmp.bk
- -rw-rw-r--. root utmp 5月 : /var/log/wtmp
- -rw-rw-r--. root utmp 5月 : wtmp.bk
- 移动文件或目录
- [root@web01 tmp]# mv -u /etc/passwd passwd ####如果目标文件存在,当源文件比较新得时候才会移动
- [root@web01 tmp]# mv -f /etc/passwd passwd #####如果目标存在,强制覆盖
- 删除文件或目录
- [root@web01 tmp]# rm file.txt
- rm:是否删除普通空文件 "file.txt"?n
- [root@web01 tmp]# ll
- 总用量
- -rw-r--r-- root 5月 : file.txt
- -rw-r--r-- root 5月 : passwd
- drwxr-xr-x root 5月 : test
- drwx--x--x root 5月 : test1
- -rw-rw-r--. utmp 5月 : wtmp.bk
- [root@web01 tmp]# rm -f file.txt ######强制删除
- [root@web01 tmp]# ll
- 总用量
- -rw-r--r-- root 5月 : passwd
- drwxr-xr-x root 5月 : test
- drwx--x--x root 5月 : test1
- -rw-rw-r--. utmp 5月 : wtmp.bk
- [root@web01 tmp]# rm -f test
- rm: 无法删除"test": 是一个目录
- [root@web01 tmp]# rm -rf test ########递归删除,删除目录
- [root@web01 tmp]# ll
- 总用量
- -rw-r--r-- root 5月 : passwd
- drwx--x--x root 5月 : test1
- -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
- 文件名变更
- [root@web01 tmp]# ll
- 总用量
- -rw-r--r-- root 5月 : passwd
- drwxr-xr-x root 5月 : test
- -rw-rw-r--. utmp 5月 : wtmp.bk
- [root@web01 tmp]# mv passwd passwd.bk #######同路径为改名
- [root@web01 tmp]# mv test test1
- [root@web01 tmp]# ll
- 总用量
- -rw-r--r-- root 5月 : passwd.bk
- drwxr-xr-x root 5月 : test1
- -rw-rw-r--. utmp 5月 : wtmp.bk
- 查看文件
- [root@web01 tmp]# cat passwd.bk
- root:x:::root:/root:/bin/bash
- bin:x:::bin:/bin:/sbin/nologin
- daemon:x:::daemon:/sbin:/sbin/nologin
- [root@web01 tmp]# cat -n passwd.bk
- root:x:::root:/root:/bin/bash
- bin:x:::bin:/bin:/sbin/nologin
- daemon:x:::daemon:/sbin:/sbin/nologin
- [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
- 查找文件
- [root@web01 tmp]# whereis ifconfig ####查找数据库中得数据
- ifconfig: /sbin/ifconfig /usr/share/man/man8/ifconfig..gz
- [root@web01 tmp]# locate ifconfig #####从数据库中查找数据
- /sbin/ifconfig
- /usr/sbin/pifconfig
- /usr/share/man/de/man8/ifconfig..gz
- /usr/share/man/fr/man8/ifconfig..gz
- /usr/share/man/man8/ifconfig..gz
- /usr/share/man/man8/pifconfig..gz
- /usr/share/man/pt/man8/ifconfig..gz[root@web01 tmp]# updatedb ####更新locate数据库
- [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 文件管理的更多相关文章
- VMware下CentOS6.8配置GFS文件系统
1.GFS介绍 GFS简要说明,它有两种: 1. Google文件系统:GFS是GOOGLE实现的是一个可扩展的分布式文件系统,用于大型的.分布式的.对大量数据进行访问的应用.它运行于廉价的普通硬件上 ...
- VirtualBox中安装CentOS-6.6虚拟机
1. 下载 可以到官网下载,http://mirror.centos.org/centos/ 如果下载速度太慢的话,也可以到163镜像下载: http://mirrors.163.com/centos ...
- VirtualBox中安装CentOS-6.6虚拟机(转载)
1. 下载 可以到官网下载,http://mirror.centos.org/centos/ 如果下载速度太慢的话,也可以到163镜像下载: http://mirrors.163.com/centos ...
- centos6.3 + db2v9.7的数据库移行
工作内容如题,我要做的事情大体如下: 1,正确备份可用数据库: 2,安装64位的cent os 6.3: 3,将1备份的数据恢复到新的cent os 6.3系统上. 第一件事情,就是备份一个可用的数据 ...
- centos6.5环境基于conga的web图形化界面方式配置rhcs集群
一.简介 RHCS 即 RedHat Cluster Suite ,中文意思即红帽集群套件.红帽集群套件(RedHat Cluter Suite, RHCS)是一套综合的软件组件,可以通过在部署时采用 ...
- Linux权限管理(用户、组、文件管理)
一. Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示. 1. 文件查看类命令cat,tac, head, tail, more, less, ls ,file: -ls : l ...
- 在Centos6.5上部署kvm虚拟化技术
KVM是什么? KVM 全称是 基于内核的虚拟机(Kernel-based Virtual Machine),它是一个 Linux 的一个内核模块,该内核模块使得 Linux 变成了一个 Hyperv ...
- 3-2 LInux文件管理
LInux文件管理 文件系统目录结构 Linux中目录结构是有一定的约定的FHS /bin:存放二进制程序 /boot:启动相关 /dev:设备文件 /etc:配置文件 /home:用户家目录 /li ...
- Linux安装LAMP开发环境及配置文件管理
Linux主要分为两大系发行版,分别是RedHat和Debian,lamp环境的安装和配置也会有所不同,所以分别以CentOS 7.1和Ubuntu 14.04做为主机(L) Linux下安装软件,最 ...
随机推荐
- 扭曲效果 效率优化 GrapPass,CommandBuffer对比
屏幕图像捕捉: Shader的GrabPass GrabPass可以很方便地捕获当前渲染时刻的FrameBuffer中的图像. 其原理就是从当前FrameBuffer中copy一份纹理,通过SetTe ...
- 第三篇(那些JAVA程序BUG中的常见单词)
illegal modifier for parameter xxx; only final is permitted 参数xxx的修饰符非法:只允许final illegal 非法的 modifie ...
- 【原创】《从0开始学Elasticsearch》—初识Elasticsearch
目录 1. Elasticsearch 是什么2. Elasticsearch 中基本概念3. Elasticsearch 安装4. 访问 Elasticsearch 1. Elasticsearch ...
- python之排序算法-冒泡、选排、快排
影响内排序算法性能的三个因素: 时间复杂度:即时间性能,高效率的排序算法应该是具有尽可能少的关键字比较次数和记录的移动次数 空间复杂度:主要是执行算法所需要的辅助空间,越少越好. 算法复杂性.主要是指 ...
- python正则表达式_总结
正则表达式: 作用:正则表达式是用来查找字符串的. 之前:使用正则表达式首先要导入re模块(import re) re.match -- 从字符串的第一个单词开始匹配字符串.如果匹配到则返回一个对象: ...
- [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]间可以连一条边. 现要求在边与边不相交的情 ...
- Coins HDU - 2844 POJ - 1742
Coins HDU - 2844 POJ - 1742 多重背包可行性 当做一般多重背包,二进制优化 #include<cstdio> #include<cstring> in ...
- 数学 SCU 4436 Easy Math
题目传送门 /* 数学题:当有一个数开根号后是无理数,则No */ #include <cstdio> #include <algorithm> #include <cs ...
- Python multiprocessing相关疑问
1. multiprocessing 和 threading有什么区别? threading module并没有真正利用多核.而multiprocessing 利用subprocess避开了pytho ...
- D. Green and Black Tea 贪心 + 构造
http://codeforces.com/contest/746/problem/D 首先说下一定是NO的情况. 假设a > b 那么,b最多能把a分成b + 1分,如果每份刚好是k的话,那么 ...