linux_02_文件crud

0.文件类型与颜色

白色 一般文件
蓝色 文件夹
红色 压缩文件
绿色 可执行文件

    
 

1.创建文件

touch myfile

    
 

2.创建文件夹

mkdir a
mkdir -p a/b/c

    
 

3.复制文件/文件夹

cp myfile myfile2
cp -r a a2
scp myfile [email protected]:home/liang

    
   

4.剪切/重命名 文件/文件夹

mv myfile myfile_new
mv a a_new

    
 

 5.查看

扫描二维码关注公众号,回复: 1166816 查看本文章
cat 
more
tail

    
 

6.1.编辑 > >>

echo "弹指红颜老" > myfile
echo  "刹那芳华" >> myfile

    
 

6.2编辑vim

菜单栏键 esc

插入 i o a 
行号(先esc) :set nu   :set nonu
定位(先esc) ^ $ gg GG
撤销(先esc) alt+u
删除字符(先esc) x
删除行(先esc) dd 10dd
复制行(先esc) yy yyp
替换(先esc) :%s#a#M#g (a替换为M)
退出(先esc) :wq q!

    
 

 7.1 压缩解压 tar

tar -zcvf a.tar.gz a
tar -zxvf a

    
  

7.2 压缩解压zip

zip -r a.zip a
unzip a.zip

    
 

8.查看文件列表

ls -hl
ls -hls(S) 文件大小排序
ls -hlt 时间排序
ls -l /home/ | wc -l (普通用户数)

    
 

9.查找

whereis ifconfig
find / -size +100M (硬盘上大于100M的文件)
find / -iname \*my\* (硬盘上文件名含有my的文件)

    
 

10.删除文件文件夹

rm -rf myfile
rm -rf a

    
 

猜你喜欢

转载自chenliang9908.iteye.com/blog/2007058