可执行文件搜索
which ls
先alias->$PATH
whereis +相关配置及帮助
slocate
slocate 查找文件及文件夹
先将当前目录结构做成一个数据库,
locate
find
find [路径][参数][表达式]:find /etc -name test
参数:-user根据文件拥有者 -group -name -type -size -nouser -nogroup 没有拥有者及群组的 perm根据文件权限
find /etc -size +1000K(大于1000K的文件)
find /etc -type f(一般文件)b(块文件)l(链接文件)
find /etc -perm 0644 (+6000 只要有一个1相同 -6000所有1都有)
操作找到的文件
find [路径][参数][表达式] -exec {} \; {}表示find找到的文件 \禁止转义
find /etc -perm 6000 -exec chown npp.npp {} \;
常用的文件操作指令
wc 统计文件的行、词、字数
grep 根据关键字查找
sort 排序
wc abc (-l 查找行)
行 字符 字符数 内容
grep -n "a" abc (含a的行数及行)
grep -v "a" abc (除a以外的)
sort -t: -k3 /etc
常用的文件操作指令(二)
diff 报告文件差异内容: diff abc ABC
comp 报告文件差异位置
uniq 去除文件重复内容(只是显示、不对原文件操作)
cut 显示文件中的某一列:cut -f3 test.txt(显示第3栏文件)
paste 将文本按列拼接 paste abc ABC > test.txt 区别于cat abc ABC > test.txt
压缩
gzip,gunzip linux标准压缩工具 gzip -d test.gz也可以解压 zcat查看
compress,uncompress 旧Unix压缩工具
bzip2,bunzip2 更新的linux压缩工具 bzcat查看
tar
c将文件备份出来
v将过程输出
x从文件
z使用gzip压缩
f 后面接tar名字
打包(备份):tar cvf test.tar test1 test2 tar zcvf 、dev/floate test
解包:tar xvf test.tar
列出文件内容:tar tf test.tar
tar cvf test.tar test1 test2 -C /home(生成的包放在home)
tar zcvf test.tar.gz test 打包并gzip压缩
tar zxvpf test.tar.gz 解压
tar jcvf test.tar.bz2 test 打包并bzip2压缩
tar jxvf test.tar.bz2
dump/restore
备份与还原ext2/3文件系统
完全备份(0)、增量备份
dump -0u -f /var/tmp/hda2dump /dev/hdal
u表示顶层目录,子目录时不能使用
restore -rf /var/tmp/hda2dump t查看 r还原操作
/etc/dumpdates备份记录(有u的参数才会)
















