chattr添加隐藏权限

lsattr查看隐藏权限

参数 a文件内容不能删除,只能追加 >>

  1. [root@mysql tmp]# chattr +a 1.txt
  2. [root@mysql tmp]# lsattr 1.txt
  3. -----a-------e- 1.txt
  4. [root@mysql tmp]# echo aaaa >> 1.txt
  5. [root@mysql tmp]# cat 1.txt
  6. 1234
  7. aaaa
  8. [root@mysql tmp]# echo bbbb > 1.txt
  9. -bash: 1.txt: Operation not permitted

删除原来内容报错

参数 i无法删除文件

  1. [root@mysql tmp]# chattr +i 1.txt
  2. [root@mysql tmp]# lsattr 1.txt
  3. ----ia-------e- 1.txt
  4. [root@mysql tmp]# rm 1.txt
  5. rm: remove regular file `1.txt'? y
  6. rm: cannot remove `1.txt': Operation not permitted

删除文件内容报错

find寻找文件或者目录

find 目录 类型 名字

参数:

-type f 普通文件

-name 文件名字或者类型

  1. [root@mysql tmp]# find / -type f -name "1.txt"
  2. /usr/bin/1.txt
  3. /tmp/1.txt
  4. /home/koorey/1.txt

-type d 目录文件

  1. [root@mysql /]# find / -type d -name ""
  2. /mnt/123

- mtime 根据时间找出文件

+7 7天之前

  1. [root@mysql /]# find /var/log -type f -mtime +7
  2. /var/log/rsyncd.log
  3. /var/log/samba/log.smbd.old
  4. /var/log/samba/log.pc201710111954
  5. /var/log/samba/log.10.0.0.1
  6. /var/log/samba/log.smbd
  7. /var/log/messages-20171001

- 7 七天之内

  1. [root@mysql /]# find /var/log -type f -mtime -7
  2. /var/log/lastlog
  3. /var/log/wtmp
  4. /var/log/yum.log
  5. /var/log/secure
  6. /var/log/ConsoleKit/history
  7. /var/log/dmesg
  8. /var/log/messages
  9. /var/log/mysqld.log
  10. /var/log/boot.log

-maxdepth 目录最大深度

  1. [root@mysql /]# find /var -type d -maxdepth 1
  2. find: warning: you have specified the -maxdepth option after a non-option argument -type, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it). Please specify options before other arguments.
  3.  
  4. /var
  5. /var/cvs
  6. /var/db
  7. /var/run
  8. /var/lib
  9. /var/account
  10. /var/log
  11. /var/local

*号 任意文件

  1. [root@mysql /]# find / -type f -name "*.txt"
  2. /lib/firmware/ivtv-firmware-license-oemihvisv.txt
  3. /lib/firmware/ivtv-firmware-license-end-user.txt
  4. /var/cache/yum/x86_64/6/timedhosts.txt
  5. /usr/lib/python2.6/site-packages/argparse-1.2.1-py2.6.egg-info/SOURCES.txt
  6. /usr/lib/python2.6/site-packages/argparse-1.2.1-py2.6.egg-info/top_level.txt
  7. /usr/lib/python2.6/site-packages/argparse-1.2.1-py2.6.egg-info/dependency_links.txt
  8. /usr/lib/python2.6/site-packages/paramiko-1.7.5-py2.6.egg-info/SOURCES.txt
  9. /usr/lib/python2.6/site-packages/paramiko-1.7.5-py2.6.egg-info/top_level.txt
  10. /usr/lib/python2.6/site-packages/paramiko-1.7.5-py2.6.egg-info/requires.txt
  11. /usr/lib/python2.6/site-packages/paramiko-1.7.5-py2.6.egg-info/dependency_links.txt

!取反

  1. [root@mysql mnt]# find -type f ! -name "1.txt"
  2. ./6.txt
  3. ./5.txt
  4. ./4.txt
  5. ./3.txt
  6. ./2.txt

xargs 管道 (执行命令)

  1. [root@mysql tmp]# find -type f -name "1.txt" | xargs cat
  2. 1234
  3. aaaa

cat 查看文件内容

xargs 先找到文件然后执行 查看命令

-inum + inode号 查找inode号所属的文件

inode号 文件软链接

  1. [root@mysql /]# find / -inum 267356
  2. /tmp/1.txt

-exec 跟管道命令差不多

  1. [root@mysql /]# find / -type f -inum 267356 -exec cat {} \;
  2. 1234
  3. aaaa

rm 删除命令

  1. [root@mysql tmp]# rm 1.txt
  2. rm: remove regular file `1.txt'? y
  3. [root@mysql tmp]# ls
  4. yum_save_tx-2017-10-12-23-03CsKn4P.yumtx yyy

-r 递归 删除 目录

  1. [root@mysql tmp]# ls
  2. ttt yum_save_tx-2017-10-12-23-03CsKn4P.yumtx yyy
  3. [root@mysql tmp]# rm -r ttt
  4. rm: remove directory `ttt'? y
  5. [root@mysql tmp]# ls
  6. yum_save_tx-2017-10-12-23-03CsKn4P.yumtx yyy

-f 不提示删除

  1. [root@mysql tmp]# rm -rf yyy
  2. [root@mysql tmp]# ls
  3. yum_save_tx-2017-10-12-23-03CsKn4P.yumtx

tree查看目录

-d 查看文件目录

  1. [root@mysql sysconfig]# tree -d
  2. .
  3. ├── cbq
  4. ├── console
  5. ├── modules
  6. ├── networking
  7. │?? ├── devices
  8. │?? └── profiles
  9. │?? └── default
  10. └── network-scripts

-L 查看几层目录

  1. [
  2. .
  3. ├── acpid
  4. ├── atd
  5. ├── auditd
  6. ├── authconfig
  7. ├── cbq
  8. │ ├── avpkt
  9. │ └── cbq-0000.example

查看 2层目录

Linux 150命令之 文件和目录操作命令 chattr lsattr find的更多相关文章

  1. Linux 150命令之 文件和目录操作命令 ls

    文件和目录操作命令 ls 查看文件和目录查看显示详信息 ls 工具的参数 ls -l 查看文件详细信息 ls -h 查看文件的大小 ls -ld 只查看目录信息 ls –F 给不同文件加上不同标记 l ...

  2. Linux 150命令之 文件和目录操作命令 cd pwd cp mv touch

    cd 切换目录 cd 目录 [root@mysql ~]# cd / [root@mysql /]# ls application bin class dev home lib64 media nfs ...

  3. Linux常用命令之文件和目录操作命令

    以下是linux操作系统常用的文件和目录操作命令: cd /home 进入 '/ home' 目录'  cd .. 返回上一级目录  cd ../.. 返回上两级目录  cd 进入个人的主目录  cd ...

  4. Linux常用命令之文件和目录处理命令

    目录 1.Linux命令的普遍语法格式 2.目录处理命令 一.显示目录文件命令:ls 二.创建目录命令:mkdir 三.切换目录命令:cd 四.shell内置命令和外部命令的区别 五.显示当前目录命令 ...

  5. Linux系列教程(四)——Linux常用命令之文件和目录处理命令

    这个系列教程的前面我们讲解了如何安装Linux系统,以及学习Linux系统的一些方法.那么从这篇博客开始,我们就正式进入Linux命令的学习.学习命令,首先要跟大家纠正的一点就是,我们不需要记住每一条 ...

  6. 【Linux命令】文件和目录操作命令

    本文主要用于常用命令的备忘,具体用法可用man查看,或查询其他资料. cd:改变工作目录 ls:列出目录的内容 mkdir:创建一个目录 cat:连接并显示指定的一个和多个文件的有关信息 cp:将给出 ...

  7. Linux基础命令之文件和目录操作(一)

    pwd print working directory的缩写,作用是显示当前工作目录的绝对路径,一般进行频繁切换路径时使用. -L 显示逻辑路径(或略软链接文件),不常用. -P 显示物理路径,不常用 ...

  8. Linux常用命令:文件与目录

    目录与路径 cd:切换目录 例如:cd ~willhua,则回到用户willhua的主文件夹  cd ~或者cd,则表示回到自己的的主文件夹  cd -,则表示回到上个目录 pwd:显示目前所在目录 ...

  9. Linux基础命令之文件和目录操作(二)

    . find 用于查找目录下的文件,也可以调用其他命令使用 find [-H] [-L] [-P] [-D debugopts] [-Olevel] [path...] [expression] fi ...

随机推荐

  1. 设置PL/SQL Developer 字符集

    本文转自:http://blog.itpub.net/26613085/viewspace-765429/ 适用于:客户端和服务端不一致的情况,或者客户端某个字段的值乱码

  2. No MyBatis mapper was found in '[com.wuji.springboot]' package. Please check your configuration

    No MyBatis mapper was found in '[com.wuji.springboot]' package. Please check your configuration. 这个原 ...

  3. 【CSU 1803】2016 (数学)

    Description 给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量: 1. 1≤a≤n,1≤b≤m; 2. a×b 是 2016 的倍数. Input 输入包含不超过 30 ...

  4. mysql千万级数据量根据索引优化查询速度

    (一)索引的作用 索引通俗来讲就相当于书的目录,当我们根据条件查询的时候,没有索引,便需要全表扫描,数据量少还可以,一旦数据量超过百万甚至千万,一条查询sql执行往往需要几十秒甚至更多,5秒以上就已经 ...

  5. HBase的详细安装部署

    一.部署 1.Zookeeper正常部署,并且启动 2.Hadoop正常部署,并且启动 3.Hbase的解压 解压HBase到指定目录 tar -xvf  /HBase.tar.gz -C /airP ...

  6. linux打patch简单示例

    在项目中,有些模块是开源的,没有源码或者不能改动源码,想要修复.优化里面的Bug,这时就需要用到patch了. 1.    生成patch 制作补丁有两种法法,diff和quilt. 1.1   di ...

  7. C语言中的if与else if

    今天发现一个比较不理解的代码,是关于else if这个判断语句的代码.代码如下 #include<stdio.h> ; int main(void) { ) { printf(" ...

  8. C语言实现选择排序算法

    新人新气象,我又来了,C语言实现选择排序.很基础的东西,原理什么的就不扯了. #include <stdio.h> #include <stdlib.h> #include & ...

  9. 基于FPGA的DDS设计(二)

    在DDS设计中,如果相位累加器每个时钟周期累加1,就会输出频率为195.313KHz的波形.如果每个时钟周期累加2,就会输出频率为2*195.313KHz的波形·······,如果每两个时钟周期累加1 ...

  10. C#——数据库取数据,DataGridView显示数据

    使用未封装的方法连接数据库 步骤: 一.确定连接方式(以SqlServer为例): ①Windows身份验证. string ConnectionType = "server=.;datab ...