「Linux系列」3-文件目录指令篇

关键字:Linux学习路线、工具、常识、目录结构等
摘要:包含linux的学习路线和前要基础知识。
文件目录常用指令
1、dir——新建/删除文件夹
1 | //新建名为box1的空文件夹 |
- 删除指令rmdir指令
1 | rmdir box1 |
2、cp——文件/文件夹复制
1 | [root@localhost animals]# cp cat_2.txt cats //将目录中一个文件复制到另一个文件 |
例:将animals中的cats目录复制到human目录中)
1 | cp -r cats/ ../human //把cats文件夹复制到human文件夹 |
3、rm——删除
- 将/home/hello.txt 单文件删除
1 | rm -r /home/test1.txt |

- 将/home/test_box整个文件夹删除
1 | rm -rf /home/test_box |
//-r会一个个问是否删除,在文件较多时不合适;-rf则不用
![]()
4、mv——移动/重命名
mv指令用户移动文件/目录、重命名
- 重命名
1 | //重新命名txt文件 |

- 移动(剪切)
1 | //将home中的txt移动到test_box文件夹中 |

5、cat——查看
cat指令用于查看文件内容信息
- 查看文件
1 | cat hello.txt |

6、less——大文件查看
less指令用于分屏查看文件内容,相较于vim全部读取,less可以更高效的查看较大的文件信息
less指令下,空格用来翻页
操作 | 功能说明 |
---|---|
空格键 | 向下翻页 |
/hello! | 查看hello!单词(n向下,N向上找) |
q | 退出less模式 |

7、echo——输出
echo指令用于输出内容,类似printf

8、history——查看历史命令
查看所有历史命令
1
[root@localhost home]# history
查看最近10条命令
1
[root@localhost home]# history 10
【问题汇总】
在相对路径、绝对路径,那些有/(斜杠),哪些没有/(斜杠)。还不是很掌握!!!