Linux的根文件系統(tǒng)
linux的文件系統(tǒng)就像一個倒置的樹根一樣,是從"/"開始的發(fā)散式層級系統(tǒng).在這個系統(tǒng)中有許多已經(jīng)被規(guī)定的功能的目錄.首先我們介紹這些目錄.
/boot: 引導(dǎo)文件存放目錄, 內(nèi)核文件(vmlinux),引導(dǎo)加載器(bootloader,grub)都存放于此目錄
/bin: 供所有用戶使用的基本命令; 不能關(guān)聯(lián)至獨立分區(qū),OS啟動即會用到的程序
/sbin: 管理類的基本命令; 不能關(guān)聯(lián)至獨立分區(qū),OS啟動即會用到
/lib: 基本共享庫文件, 以及內(nèi)核模塊文件(/lib/modules)
/lib64: 專用于x86_64系統(tǒng)上的輔助共享庫文件存放位置
/etc: 配置文件目錄(多數(shù)為純文本文件)
/home/USERNAME: 普通用戶的家目錄
/root: 管理員的家目錄
/media: 便攜式移動設(shè)備掛載點
/mnt: 臨時文件系統(tǒng)掛載點
/dev: 塊設(shè)備文件及特殊文件的存放位置
b: block device 可隨機訪問的設(shè)備
c: character device 線性訪問設(shè)備
/opt: 第三方應(yīng)用程序的安裝位置
/srv: 系統(tǒng)上運行的服務(wù)用到的數(shù)據(jù)
/temp: 臨時文件存儲位置
/usr: universal shared read-only date
bin: 保證系統(tǒng)擁有完整功能而提供的應(yīng)用程序
sbin:
lib:
lib64:
include: C程序的頭文件(header files);
share: 結(jié)構(gòu)化獨立的數(shù)據(jù),例如doc, man
local: 第三方應(yīng)用程序安裝的位置
bin, sbin, lib, lib64, etc, share
/var: variable data files
cache: 應(yīng)用程序緩存數(shù)據(jù)目錄
lib: 應(yīng)用程序狀態(tài)信息數(shù)據(jù)
local: 專用于為/usr/local下的應(yīng)用程序存儲可變數(shù)據(jù)
lock: 鎖文件
log: 日志目錄及文件
opt: 專用于/opt下的應(yīng)用程序存儲可變數(shù)據(jù)
run: 運行中的進程相關(guān)的數(shù)據(jù),通常用于存儲進程的pid文件
spool: 應(yīng)用程序數(shù)據(jù)池
tmp: 保存系統(tǒng)兩次重啟之間產(chǎn)生的臨時數(shù)據(jù)
/proc: 用于輸出內(nèi)核與進程信息相關(guān)的虛擬文件系統(tǒng)
/sys: 用于輸出當(dāng)前系統(tǒng)上硬件設(shè)備相關(guān)信息的虛擬文件系統(tǒng)
/selinux: security enhanced linux,selinux 相關(guān)的安全策略等信息的存儲位置
cd命令
cd (change directory): 用于切換目錄
cd [ARGUMENT]
argument:
dircetory
..: 上一目錄
[centos@localhost ~]$ ls
Desktop Documents Downloads Music Pictures Public Templates Videos
[centos@localhost ~]$ cd Downloads/
[centos@localhost Downloads]$ cd ..
[centos@localhost ~]$ ls
Desktop Documents Downloads Music Pictures Public Templates Videos
~: 當(dāng)前用戶家目錄 = 直接cd
[centos@localhost ~]$ cd /
[centos@localhost /]$ cd
[centos@localhost ~]$ ls
Desktop Documents Downloads Music Pictures Public Templates Videos
~USERNAME: 切換至指定用戶的主目錄
[root@localhost centos]# useradd test
[root@localhost centos]# cd ~test
[root@localhost test]#
-: 在上一個目錄和當(dāng)前目錄之間來回切換
[root@localhost test]# cd -
/home/centos
[root@localhost centos]# cd -
/home/test
ls命令
ls (list): 顯示指定路徑下的所有文件列表
ls [OPTIONS].... [DIRECTORY]
options:
-a, --all: 顯示所有文件, 包括隱藏文件
-l: 詳細(xì)顯示
-h: 文件大小的單位換算
-d: 顯示工作目錄自身的相關(guān)屬性,通常要與-l一同使用才有意義
-r, --reverse: 倒序顯示
-R, --recursive: 遞歸顯示
pwd命令
pwd (print working directory): 打印工作目錄
$ pwd
/home/centos
mkdir命令
mkdir (making directory): 創(chuàng)建目錄
mkdir [OPTIONS] /PATH/TO/SOMEWHERE
options: -p: 不再報錯, 若父目錄不存在則自動創(chuàng)建
-v: 顯示詳細(xì)信息
-m MODE: 創(chuàng)建目錄時直接指定權(quán)限
rmdir命令
rmdir (remove directory): 刪除目錄
rmdir [OPTIONS] /PATH/TO/SOMEWHERE
options: -v: 顯示過程