1.Linux文件的目录结构
- 根目录 /
- 家目录 /home (~波浪号表示当前用户的家目录,这里表示home家目录下有好几个小用户,如root,user等)
- 临时目录 /tmp
- 配置目录 /etc
- 用户程序目录 /usr
2.文件基本操作
- ls 查看目录下的文件
- touch 新建文件
- mkdir 新建文件夹
- cd 进入目录
- rm 删除文件和目录
- cp 复制
- mv 移动(剪切链接)
- pwd 显示当前路径
3.一些实用命令的举例
1)ls -al 表示以列表形式展示当前目录文件
ls -al 等同于 ll
2)循环创建文件夹
[[email protected] tmp]# mkdir -p test1_dir/test2/test3
[[email protected] tmp]# cd test1_dir/test2/test3
[[email protected] test3]# ls
[[email protected] test3]# ll
total 0
创建test1_dir文件夹,同时在test1_dir文件夹里面创建test2文件夹,
同时在test2文件夹中创建test3文件夹
3)循环删除
[[email protected] tmp]# rm test1_dir
rm: cannot remove ‘test1_dir’: Is a directory
[[email protected] tmp]# rm -r test1_dir
rm: descend into directory ‘test1_dir’? y
rm: descend into directory ‘test1_dir/test2’? y
rm: remove directory ‘test1_dir/test2/test3’? y
rm: remove directory ‘test1_dir/test2’? y
rm: remove directory ‘test1_dir’? y
[[email protected] tmp]#
4)强制删除,不在询问和循环删除
[[email protected] tmp]# mkdir -p test1_dir/test2/test3
[[email protected] tmp]# rm -rf test1_dir/
[[email protected] tmp]#