一、 查看文件类型
[root@VMredhat6 ~]#ls -l #第一位字符代表文件类型
total 108
-rw-------. 1 root root 1555 Jul 13 17:38 anaconda-ks.cfg
drwxr-xr-x. 2 root root 4096 Jul 13 10:24 Desktop
[root@VMredhat6 ~]#file anaconda-ks.cfg
anaconda-ks.cfg: ASCII English text
[root@VMredhat6 ~]#file Desktop/
Desktop/: directory
二、文件操作
1、查看
cat:将文本连接起来显示在标准输出上
-E --show-ends 显示结束符$
[root@VMredhat6 test]# cat -E 1.txt
one$
two$
three$
-e:等于-vE
-v:显示非打印符
-n:显示每行按顺序编号
[root@VMredhat6 test]# cat -n 1.txt
1 one
2 two
3 three
-s:将多个连续的空白行合并显示一个空白行
moe 只支持向后翻
less 支持前后翻
head 默认显示前10行
tail 默认显示后10行
tac 逆序显示文件
2、复制
cp
-r:递归
[root@VMredhat6 test]# cp -r /tmp/test/ /tmp/yx/ 将test文件目录复制到yx目录下
[root@VMredhat6 test]# cp -r /tmp/test/* /tmp/yx/将test文件目录所有文件复制到yx目录下
-i:提示,交互
-f:强制覆盖
-a: -dr 复制后保留所有的文件信息,包括属主和属组
-d:当源为连接文件时,复制链接文件本身,而非指向的源文件
-p:保持原有属性,同 –a 功能类似
3、移动、剪切
mv
[root@VMredhat6 test]# mv /home/test01/test.txt . 把test.txt文件移动到当前目录
4、删除
rm
默认会有交互提示
[root@VMredhat6 test]# rm 1.txt
rm: remove regular file `1.txt'? y #你输入y确认删除,输入n否定删除
-rf:强制删除非空文件目录或文件
[root@VMredhat6 test]# rm -rf 1.txt
5、创建
touch 创建空文件,修改时间戳
[root@VMredhat6 test]# touch testfile.txt
-t:指定时间戳
-a:仅修改访问时间
m:仅修改修改时间
[root@VMredhat6 test]# touch -at 201905050505.05 1.txt
[root@VMredhat6 test]# touch -mt 201905050505.05 1.txt
6、文本编辑器
nano 功能类似windows文本编辑器,操作简单
vi 功能强大文本编辑器,操作复杂
vim vi升级版本