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

相關文章
相關標籤/搜索