Linux -- 目录基本操做(1)

cd 切换目录html

1.切换到指定目录下bash

#cd 相对/绝对目录
[root@localhost ~]# cd /home/tom/demo
[root@localhost demo]# 

2.切换到某个用户的主文件夹spa

[root@localhost /]# cd ~tom
[root@localhost tom]#

3.切换到本身的主文件夹htm

[root@localhost tom]# cd ~
[root@localhost ~]# 
或者
[root@localhost demo]# cd
[root@localhost ~]# 

4.返回上级目录blog

[root@localhost demo]# cd ..
[root@localhost tom]# 

5.回到刚才在的目录get

[root@localhost tom]# cd -
/home/tom/demo
[root@localhost demo]# 

6.切换到系统根目录class

[tom@localhost ~]$ cd /

pwd 显示当前路径test

 

[root@localhost demo]# pwd
/home/tom/demo

 

mkdir 新建目录权限

1.简单建立一个目录 mkdir 目录名demo

[root@localhost demo]# mkdir work
[root@localhost demo]# ls
work

2.建立目录时同时赋予目录权限

[root@localhost demo]# mkdir -m 777 test
[root@localhost demo]# ll
总用量 8
drwxrwxrwx 2 root root 4096 2月  12 20:15 test
drwxr-xr-x 2 root root 4096 2月  12 20:09 work

3.建立多层目录

[root@localhost demo]# mkdir -p test1/test2/test3
[root@localhost demo]# cd test1/test2/test3/
[root@localhost test3]# pwd
/home/tom/demo/test1/test2/test3

rmdir 删除文件夹

只能删除没有文件的目录,若是删除有文件的目录可使用 rm -r 目录名

[root@hs-192-168-33-206 tom]# rmdir demo/
rmdir: 删除 "demo/" 失败: 目录非空
#清除文件后,再次删除可成功
[root@hs-192-168-33-206 tom]# rmdir demo/

  

Linux-- 目录基本操做(2)
http://www.javashuo.com/article/p-bugvnstd-cx.html

相关文章
相关标签/搜索