chattr添加隱藏權限
lsattr查看隱藏權限
參數 a文件內容不能刪除,只能追加 >>
-
[root@mysql tmp]# chattr +a 1.txt
-
[root@mysql tmp]# lsattr 1.txt
-
-----a-------e- 1.txt
-
[root@mysql tmp]# echo aaaa >> 1.txt
-
[root@mysql tmp]# cat 1.txt
-
1234
-
aaaa
-
[root@mysql tmp]# echo bbbb > 1.txt
-
-bash: 1.txt: Operation not permitted
刪除原來內容報錯
參數 i無法刪除文件
-
[root@mysql tmp]# chattr +i 1.txt
-
[root@mysql tmp]# lsattr 1.txt
-
----ia-------e- 1.txt
-
[root@mysql tmp]# rm 1.txt
-
rm: remove regular file `1.txt'? y
-
rm: cannot remove `1.txt': Operation not permitted
刪除文件內容報錯
find尋找文件或者目錄
find 目錄 類型 名字
參數:
-type f 普通文件
-name 文件名字或者類型
-
[root@mysql tmp]# find / -type f -name "1.txt"
-
/usr/bin/1.txt
-
/tmp/1.txt
-
/home/koorey/1.txt
-type d 目錄文件
-
[root@mysql /]# find / -type d -name "123"
-
/mnt/123
- mtime 根據時間找出文件
+7 7天之前
-
[root@mysql /]# find /var/log -type f -mtime +7
-
/var/log/rsyncd.log
-
/var/log/samba/log.smbd.old
-
/var/log/samba/log.pc201710111954
-
/var/log/samba/log.10.0.0.1
-
/var/log/samba/log.smbd
-
/var/log/messages-20171001
- 7 七天之內
-
[root@mysql /]# find /var/log -type f -mtime -7
-
/var/log/lastlog
-
/var/log/wtmp
-
/var/log/yum.log
-
/var/log/secure
-
/var/log/ConsoleKit/history
-
/var/log/dmesg
-
/var/log/messages
-
/var/log/mysqld.log
-
/var/log/boot.log
-maxdepth 目錄最大深度
-
[root@mysql /]# find /var -type d -maxdepth 1
-
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.
-
-
/var
-
/var/cvs
-
/var/db
-
/var/run
-
/var/lib
-
/var/account
-
/var/log
-
/var/local
*號 任意文件
-
[root@mysql /]# find / -type f -name "*.txt"
-
/lib/firmware/ivtv-firmware-license-oemihvisv.txt
-
/lib/firmware/ivtv-firmware-license-end-user.txt
-
/var/cache/yum/x86_64/6/timedhosts.txt
-
/usr/lib/python2.6/site-packages/argparse-1.2.1-py2.6.egg-info/SOURCES.txt
-
/usr/lib/python2.6/site-packages/argparse-1.2.1-py2.6.egg-info/top_level.txt
-
/usr/lib/python2.6/site-packages/argparse-1.2.1-py2.6.egg-info/dependency_links.txt
-
/usr/lib/python2.6/site-packages/paramiko-1.7.5-py2.6.egg-info/SOURCES.txt
-
/usr/lib/python2.6/site-packages/paramiko-1.7.5-py2.6.egg-info/top_level.txt
-
/usr/lib/python2.6/site-packages/paramiko-1.7.5-py2.6.egg-info/requires.txt
-
/usr/lib/python2.6/site-packages/paramiko-1.7.5-py2.6.egg-info/dependency_links.txt
!取反
-
[root@mysql mnt]# find -type f ! -name "1.txt"
-
./6.txt
-
./5.txt
-
./4.txt
-
./3.txt
-
./2.txt
xargs 管道 (執行命令)
-
[root@mysql tmp]# find -type f -name "1.txt" | xargs cat
-
1234
-
aaaa
cat 查看文件內容
xargs 先找到文件然后執行 查看命令
-inum + inode號 查找inode號所屬的文件
inode號 文件軟鏈接
-
[root@mysql /]# find / -inum 267356
-
/tmp/1.txt
-exec 跟管道命令差不多
-
[root@mysql /]# find / -type f -inum 267356 -exec cat {} \;
-
1234
-
aaaa
rm 刪除命令
-
[root@mysql tmp]# rm 1.txt
-
rm: remove regular file `1.txt'? y
-
[root@mysql tmp]# ls
-
yum_save_tx-2017-10-12-23-03CsKn4P.yumtx yyy
-r 遞歸 刪除 目錄
-
[root@mysql tmp]# ls
-
ttt yum_save_tx-2017-10-12-23-03CsKn4P.yumtx yyy
-
[root@mysql tmp]# rm -r ttt
-
rm: remove directory `ttt'? y
-
[root@mysql tmp]# ls
-
yum_save_tx-2017-10-12-23-03CsKn4P.yumtx yyy
-f 不提示刪除
-
[root@mysql tmp]# rm -rf yyy
-
[root@mysql tmp]# ls
-
yum_save_tx-2017-10-12-23-03CsKn4P.yumtx
tree查看目錄
-d 查看文件目錄
-
[root@mysql sysconfig]# tree -d
-
.
-
├── cbq
-
├── console
-
├── modules
-
├── networking
-
│?? ├── devices
-
│?? └── profiles
-
│?? └── default
-
└── network-scripts
-L 查看幾層目錄
-
[root@mysql sysconfig]# tree -L 2
-
.
-
├── acpid
-
├── atd
-
├── auditd
-
├── authconfig
-
├── cbq
-
│ ├── avpkt
-
│ └── cbq-0000.example
查看 2層目錄
