一个小白学习Linux的艰辛路程day7

day07学习笔记

1.文件命名规则

1.要见名知意    就是说你的文件名取得要让人一眼能看出来文件类型,要根据文件的真实属性来命名
2.文件名最好不要带特殊符号
3.文件名需要分割时,使用下划线_
4.要严格区分文件名的大小写

2.文件管理命令

touch  创建文件
mkdir  创建文件夹
vim  vi  创建文件
rmdir  删除文件夹
echo  >  =创建文件
>是重定向符号   将符号左边的内容写进符号右边

2.Linux命令

1.删除(慎用)

命令  rm
参数
rm   只删除一个文件或同级下的多个文件         [root@linux ~]# rm   /tmp/yjy/yjy.txt    Yjy.txt

-r   递归删减   删除指定目录里的所有子目录和文件    [root@linux ~]# rm  -r  /tmp/yjy/
-i   删除文件前需要确认    [root@linux ~]# rm  -i  /tmp/春晓.txt
                        rm: remove regular file ‘/tmp/春晓.txt’? 
-f   强制删除,不提示任何信息(删除前一定要确定路径)
-rf  递归强制删除 (******)注意删除前再三确认

2.拷贝

命令   cp
拷贝文件并且改名   cp+文件(路径)+目标路径(文件名) [root@linux tmp]# cp  春晓.txt   /root/nihao/冬至.txt
拷贝文件不改名   cp+文件名(路径)   [root@linux tmp]# cp  春晓.txt +目标路径[root@linux tmp]# cp   春晓.txt    /home/       [root@linux /]# cp   /tmp/春晓.txt    /opt/

-r  递归拷贝文件夹  cp   -r+原文件夹路径+目标文件夹路径(目标文件夹没有同名的正常拷贝)(目标文件夹有同名文件夹,则拷贝的文件夹最后回到该文件夹里面)
 

3.移动、剪切、重命名

命令   mv
移动单个文件    mv+原文件路径+目标文件夹路径  [root@linux tmp]# mv  春晓.txt   /home/叶金阳/
文件重命名      mv+原文件名+修改文件名       [root@linux tmp]# mv  春晓.txt   yjyj.txt
移动文件且重命名 mv+原文件路径+目标文件路径(修改的文件名)[root@linux tmp]# mv  ./春晓.txt                                                                            /home/叶金阳/yjyj.txt

4.打包(不论解压还是打包参数必须-f)

命令tar
-c    打包     tar  -cf   文件名+需要打包进去的内容    [root@linux tmp]# tar  -cf  nihao.tar.gz    春晓.txt

-v    显示打包过程      [root@linux tmp]# tar  -cvf  nihao.tar.gz    春晓.txt
-f    指定打包的文件名,只要使用tar命令,就必须加上-f参数,并且要放在参数最后一个
-u    更新原打包文件中的内容   tar  -uf
-t    查看打包的文件内容      tar   -tf   [root@linux tmp]# tar   -tf  nihao.tar.gz
春晓.txt
-z    压缩为tar.gz格式    tar   -zcvf  
-j    压缩为bz2格式       tar   -jcvf
-J    压缩为xz格式        tar   -Jcvf

-x  解压
tar  -xvf 

5.压缩

命令   zip   
不加参数   zip  压缩包名+需要压缩的文件 [root@linux tmp]# zip   nihao   春晓.txt

6.补充

1.alias
[root@linux /]# ls
bin          etc       media  run   test_tar  wangyiyun_music  网易云
boot         filename  mnt    sbin  test_vim  wangyiyun_songs
data         home      opt    srv   tmp       xusong_songs
dev          lib       proc   sys   usr       抖音神曲
Eason_songs  lib64     root   test  var       王者荣耀
[root@linux /]# alias   la='ls'
[root@linux /]# ls
bin          etc       media  run   test_tar  wangyiyun_music  网易云
boot         filename  mnt    sbin  test_vim  wangyiyun_songs
data         home      opt    srv   tmp       xusong_songs
dev          lib       proc   sys   usr       抖音神曲
Eason_songs  lib64     root   test  var       王者荣耀
[root@linux /]# la
bin          etc       media  run   test_tar  wangyiyun_music  网易云
boot         filename  mnt    sbin  test_vim  wangyiyun_songs
data         home      opt    srv   tmp       xusong_songs
dev          lib       proc   sys   usr       抖音神曲
Eason_songs  lib64     root   test  var       王者荣耀

2.unzip解压缩
先安装   yum  install   unzip -y
解压缩并指定一个地方-d 
[root@linux ~]# unzip  /tmp/nihao.zip  -d   /etc
Archive:  /tmp/nihao.zip
 extracting: /etc/春晓.txt         
[root@linux ~]# ls   /etc

3.{}   花括号的用法
可以连续创建多个连续的、有规律性的文件,   花括号中间注意两个 . .
[root@linux ~]# 
[root@linux ~]# touch   {1..1000}.txt   /ddfsd
[root@linux ~]# ls  /ddfsd
/ddfsd
[root@linux ~]# ls
-         251.txt  404.txt  558.txt  710.txt  864.txt
1         252.txt  405.txt  559.txt  711.txt  865.txt
1000.txt  253.txt  406.txt  55.txt   712.txt  866.txt
100.txt   254.txt  407.txt  560.txt  713.txt  867.txt
101.txt   255.txt  408.txt  561.txt  714.txt  868.txt
102.txt   256.txt  409.txt  562.txt  715.txt  869.txt
103.txt   257.txt  40.txt   563.txt  716.txt  86.txt
104.txt   258.txt  410.txt  564.txt  717.txt  870.txt
105.txt   259.txt  411.txt  565.txt  718.txt  871.txt
106.txt   25.txt   412.txt  566.txt  719.txt  872.txt
107.txt   260.txt  413.txt  567.txt  71.txt   873.txt
108.txt   261.txt  414.txt  568.txt  720.txt  874.txt
109.txt   262.txt  415.txt  569.txt  721.txt  875.txt
10.txt    263.txt  416.txt  56.txt   722.txt  876.txt
110.txt   264.txt  417.txt  570.txt  723.txt  877.txt

3.虚拟机快照

在你使用linux中要提前在虚拟机中添加一个或多个快照
如果因为操作失误导致系统崩盘或是重要文件删除等情况时,可以回退到你添加的某一个快照中,相当于时光倒流
posted @ 2022-03-15 18:24  小叶4444  阅读(67)  评论(0)    收藏  举报