一、文件管理
一、文件管理
1.创建文件
touch file1.txt
touch f{1..5}.txt 集合式操作文件
vi file1.txt
2.删除文件
rm
rm -rf file1.txt
rm -rf * 全部强制删除
3.修改文件
vi file.txt
(x)yy 复制
(x)dd 删除
(x)p 粘贴
:x 保存退出
:wq 强制保存退出
:X 为文件设置密码
:set key= 清除密码
:q! 强制退出
4.文件查看
vi file.txt
cat file.txt|more
head file.txt 查看文件前十行
tail file.txt 查看文件后十行
head -n file.txt 前n行
tail -n file.txt 后n行
5.复制文件
cp file.txt /mnt/
6.移动文件
mv file.txt /mnt/
7.文件重命名
mv file.txt file1.txt
8.查找文件
which ls //查找文件
ls file* //查找file开头的文件
find /etc -name httpd* //精确模糊都可以
locate //查找一个精确的文件,前提先执行updatedb 快
9.内容查找
cat /etc/passwd |grep root
cat /etc/passwd |grep ^root ^以...开头
cat /etc/passwd |grep -E "^user|^root" 查找以user开头的或以root开头的