Linux常用的基础命令笔记
Linux 目录相关的命令
ls (列出目录)
- -a:全部的文件,连同隐藏文件(开头为.的文件)一起列出来
- -l:长数据串列出,包含文件的属性与权限等等(常用)。
cd 命令
-
绝对路径 /
-
相对路径 相对于当前路径 cd…
-
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-IVYrSZNn-1596786838645)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20200807100505817.png)]
pwd 显示当前所在目录
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-oH4ExpxL-1596786838652)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20200807101815340.png)]
mkdir 创建一个目录
[root@centos7 /]# cd home #创建目录 [root@centos7 home]# ls csl cslstudy csl.txt test [root@centos7 home]# mkdir test1 [root@centos7 home]# ls csl cslstudy csl.txt test test1 [root@centos7 home]# mkdir test2/test3/test4/ mkdir: cannot create directory ‘test2/test3/test4/’: No such file or directory [root@centos7 home]# mkdir -p test2/test3/test4 ##创建多级目录 [root@centos7 home]# ls csl cslstudy csl.txt test test1 test2 [root@centos7 home]# cd test2 [root@centos7 test2]# ls test3 [root@centos7 test2]# cd test3 [root@centos7 test3]# ls test4 [root@centos7 test3]#
rmdir 删除一个目录
[root@centos7 test3]# cd /home [root@centos7 home]# ls csl cslstudy csl.txt test test1 test2 [root@centos7 home]# rmdir test1 [root@centos7 home]# ls csl cslstudy csl.txt test test2 [root@centos7 home]# rmdir test2 rmdir: failed to remove ‘test2’: Directory not empty [root@centos7 home]# rmdir test2/test3/test4 [root@centos7 home]# ls csl cslstudy csl.txt test test2 [root@centos7 home]# rmdir -p test2/test3/test4 rmdir: failed to remove ‘test2/test3/test4’: No such file or directory [root@centos7 home]# mkdir test2/test3/test4 [root@centos7 home]# rmdir -p test2/test3/test4 [root@centos7 home]# ls csl cslstudy csl.txt test
rmdir仅能删除空的目录,如果下面存在文件,需要删除文件,递归删除多个目录 -p参数即可
cp 复制文件或者目录
[root@chendashuai test]# cd ..
[root@chendashuai home]# ls
csl cslstudy csl.txt