ls
列出目录
1 2 [root@VM-16-9-centos /]# ls [-aAdfFhilnrRSt]目录文件
-a:全部的文件,连同隐藏文件( 开头为 . 的文件) 一起列出来
-l :长数据串列出,包含文件的属性与权限等等数据
1 [root@VM-16-9-centos www]# ls -al
将目录下的所有文件列出来(含属性与隐藏档)
cd
切换目录 Change Directory
1 2 3 4 5 6 [root@VM-16-9-centos /]# cd ~ [root@VM-16-9-centos ~]# cd / [root@VM-16-9-centos /]# cd ..
pwd
显示目前所在目录 Print Working Directory
1 2 [root@VM-16-9-centos ~]# pwd /root
-P:显示出确实的路径,而非使用连接(link) 路径
1 2 3 4 5 6 [root@VM-16-9-centos bin]# pwd /bin [root@VM-16-9-centos bin]# pwd -P /usr/bin
mkdir
创建新目录 make directory
-m :配置文件的权限。直接配置,不需要看默认权限 (umask) 的脸色
-p :直接将所需要的目录(包含上一级目录)递归创建起来!
1 2 3 4 5 6 [root@VM-16-9-centos /]# mkdir -p zhang/zhang/zhang [root@VM-16-9-centos home]# mkdir -m 711 test2 [root@VM-16-9-centos home]# ls -l drwx--x--x 2 root root 4096 Mar 12 21:58 test2
rmdir
删除空目录
cp
复制文件或目录
1 2 [root@www ~]# cp [-adfilprsu] 来源档(source ) 目标档(destination) [root@www ~]# cp [options] source1 source2 source3 .... directory
**-i:**若目标档(destination)已经存在时,在覆盖时会先询问动作的进行(常用)
rm
移除文件或目录
-f :force,忽略不存在的文件,不会出现警告信息;
-i :互动模式,在删除前会询问使用者是否动作
-r :递归删除,非常危险
1 2 3 4 5 [root@kuangshen home]# rm -i install.sh rm : remove regular file ‘install.sh’? y
mv
移动文件或目录,或修改名称
1 2 [root@www ~]# mv [-fiu] source destination [root@www ~]# mv [options] source1 source2 source3 .... directory
-f :force 强制的意思,如果目标文件已经存在,不会询问而直接覆盖;
-i :若目标文件 (destination) 已经存在时,就会询问是否覆盖!
-u :若目标文件已经存在,且 source 比较新,才会升级 (update)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 [root@kuangshen home]# cp /root/install.sh /home [root@kuangshen home]# mkdir test [root@kuangshen home]# mv install.sh test [root@kuangshen home]# ls test [root@kuangshen home]# cd test [root@kuangshen test ]# ls install.sh [root@kuangshen test ]# cd .. [root@kuangshen home]# mv test mvtest [root@kuangshen home]# ls mvtest