六. 绝对路径和相对路径
七. ls和常用参数
八. cd和pwd命令
九. rm命令
十. cp命令
实验操作
//建立空的文件夹test
[root@VM_0_15_centos home]# mkdir test
[root@VM_0_15_centos home]# cd test
[root@VM_0_15_centos test]# ls
//文件夹中建立hello.txt这个文件
[root@VM_0_15_centos test]# touch hello.txt
[root@VM_0_15_centos test]# ls
hello.txt
//情况一: cp 要拷贝的文件(file) file1(不存在)
//结果:创建file1,并将file的内容拷贝到file1
[root@VM_0_15_centos test]# cp hello.txt target
[root@VM_0_15_centos test]# ls
hello.txt target
//情况二: cp 要拷贝的文件(file) file1(存在)
//结果:file的内容覆盖file1的内容
[root@VM_0_15_centos test]# cp hello.txt target
[root@VM_0_15_centos test]# vi target
//情况三: cp file dir(存在)
//结果:拷贝file到dir目录
[root@VM_0_15_centos test]# mkdir son
[root@VM_0_15_centos test]# ls
hello.txt son target
[root@VM_0_15_centos test]# cp hello.txt son
[root@VM_0_15_centos test]# ls
hello.txt son target
[root@VM_0_15_centos test]# cd son
[root@VM_0_15_centos son]# ls
hello.txt
//情况四: cp dir(存在)dir1(存在)
//结果:将dir目录拷贝到dir1,包括dir目录
[root@VM_0_15_centos son]# cd ..
[root@VM_0_15_centos test]# ls
hello.txt son target
[root@VM_0_15_centos test]# mkdir son2
[root@VM_0_15_centos test]# cp son son2 -r
[root@VM_0_15_centos test]# ls
hello.txt son son2 target
[root@VM_0_15_centos test]# cd son2
[root@VM_0_15_centos son2]# ls
son
[root@VM_0_15_centos son2]# cd ..
[root@VM_0_15_centos test]# tree son2
son2
`-- son
`-- hello.txt
//情况五: cp dir(存在)dir1(不存在)
//结果:创建dir1,将dir目录拷贝到dir1,不包括dir目录
1 directory, 1 file
[root@VM_0_15_centos test]# ls
hello.txt son son2 target
[root@VM_0_15_centos test]# cp son a
cp: omitting directory ‘son’
[root@VM_0_15_centos test]# cp son a -r
[root@VM_0_15_centos test]# ls
a hello.txt son son2 target
[root@VM_0_15_centos test]# tree a
a
`-- hello.txt