CentOS 系統各個目錄的作用詳解

文件系統的類型:

LINUX有四種基本文件系統類型:普通文件、目錄文件、連接文件和特殊文件,可用file命令來識別。

普通文件:如文本文件、C語言元代碼、SHELL腳本、二進制的可執行文件等,可用cat、less、more、vi、emacs來察看內容,用mv來改名。

目錄文件:包括文件名、子目錄名及其指針。它是LINUX儲存文件名的唯一地方,可用ls列出目錄文件。

連接文件:是指向同一索引節點的那些目錄條目。用ls來查看是,連接文件的標誌用l開頭,而文件面後以”->”指向所連接的文件。

特殊文件:LINUX的一些設備如磁盤、終端、打印機等都在文件系統中表示出來,則一類文件就是特殊文件,常放在/dev目錄內。例如,軟驅A稱為/dev/fd0。LINUX無C:的概念,而是用/dev/had來自第一硬盤。

對於linux新手來說,最感到迷惑的問題之一就是文件都存在哪裡呢?特別是對於那些從windows轉過來的新手來說,linux的目錄結構看起來有些奇怪哦。所以,在這裡講一下linux下的主要目錄以及它們都是用來幹什麼的。

/

This is the root directory. The mothership. The home field. The one and only top directory for your whole computer. Everything, and I mean EVERYTHING starts here. When you type ‘/home’ what you’re really saying is “start at / and then go to the home directory.”

/

這就是根目錄。對你的電腦來說,有且只有一個根目錄。所有的東西,我是說所有的東西都是從這裡開始。舉個例子:當你在終端裡輸入“/home”,你其實是在告訴電腦,先從/(根目錄)開始,再進入到home目錄。

/root

This is where the root user lives. The root user is the god of your system. Root can do anything, up to and including removing your entire filesystem. So be careful using root.

/root

這是系統管理員(root user)的目錄。對於系統來說,系統管理員就好比是上帝,它能對系統做任何事情,甚至包括刪除你的文件。因此,請小心使用root帳號。

/bin

Here’s where your standard linux utilities(read programs) live — things like “ls” and “vi” and “more”. Generally this directory is included in your path. What this means is that if you type ‘ls’, /bin is one of the places your shell will look to see if ‘ls’ means anything.

/bin

這裡存放了標準的(或者說是缺省的)linux的工具,比如像“ls”、“vi”還有“more”等等。通常來說,這個目錄已經包含在你的“path”系 統變量裡面了。什麼意思呢?就是:當你在終端裡輸入ls,系統就會去/bin目錄下面查找是不是有ls這個程序。

/etc

Here’s where the administrative and system configuration stuff lives. For instance, if you have samba installed, and you want to modify the samba configuration files, you’d find them in /etc/samba.

/etc

這裡主要存放了系統配置方面的文件。舉個例子:你安裝了samba這個套件,當你想要修改samba配置文件的時候,你會發現它們(配置文件)就在/etc/samba目錄下。

/dev

Here’s where files that control peripherals live. Talking to a printer? Your computer is doing it from here. Same goes for disk drives, usb devices, and other such stuff.

/dev

這裡主要存放與設備(包括外設)有關的文件(unix和linux系統均把設備當成文件)。想連線打印機嗎?系統就是從這個目錄開始工作的。另外還有一些包括磁盤驅動、USB驅動等都放在這個目錄。

/home

Here’s where your data is stored. Config files specific to users, your Desktop folder(whick makes your desktop what it is), and any data related to your user. Each user will have their own /home/username folder, with the exception of the root user.

/home

這裡主要存放你的個人數據。具體每個用戶的設置文件,用戶的桌面文件夾,還有用戶的數據都放在這裡。每個用戶都有自己的用戶目錄,位置為:/home/用戶名。當然,root用戶除外。

/tmp

This is the Temporary folder. Think of it as a scratch directory for your Linux system. Files that won’t be needed by programs once their used once or twice are put here. Many Linux systems are set to automatically wipe the /tmp folder at certain intervals, so don’t put things you want to keep here.

/tmp

這是臨時目錄。對於某些程序來說,有些文件被用了一次兩次之後,就不會再被用到,像這樣的文件就放在這裡。有些linux系統會定期自動對這個目錄進行清理,因此,千萬不要把重要的數據放在這裡。

/usr

Here’s where you’ll find extra utilities that don’t fit under /bin or /etc. Things like games, printer utilities, and whatnot. /usr is divided into sections like /usr/bin for programs, /usr/share for shared data like sound files or icons, /usr/lib for libraries whick cannot be directly run but are essential for running other programs.Your package manager takes care of the things in /usr for you.

/usr

在這個目錄下,你可以找到那些不適合放在/bin或/etc目錄下的額外的工具。比如像遊戲阿,一些打印工具拉等等。/usr目錄包含了許多子目 錄: /usr/bin目錄用於存放程序;/usr/share用於存放一些共享的數據,比如音樂文件或者圖標等等;/usr/lib目錄用於存放那些不能直接 運行的,但卻是許多程序運行所必需的一些函數庫文件。你的軟件包管理器(應該是“新立得”吧)會自動幫你管理好/usr目錄的。

/opt

Here’s where optional stuff is put. Trying out the latest Firefox beta? Install it to /opt where you can delete it without affecting other settings. Programs in here usually live inside a single folder whick contains all of their data, libraries, etc.

/opt

這裡主要存放那些可選的程序。你想嘗試最新的firefox測試版嗎?那就裝到/opt目錄下吧,這樣,當你嘗試完,想刪掉firefox的時候, 你就可 以直接刪除它,而不影響系統其他任何設置。安裝到/opt目錄下的程序,它所有的數據、庫文件等等都是放在同個目錄下面。

舉個例子:剛才裝的測試版firefox,就可以裝到/opt/firefox_beta目錄下,/opt/firefox_beta目錄下面就包 含了運 行firefox所需要的所有文件、庫、數據等等。要刪除firefox的時候,你只需刪除/opt/firefox_beta目錄即可,非常簡單。

/usr/local

This is where most manually installed(ie. outside of your package manager) software goes. It has the same structure as /usr. It is a good idea to leave /usr to your package manager and put any custom>

/usr/local

這裡主要存放那些手動安裝的軟件,即不是通過“新立得”或apt-get安裝的軟件。它和/usr目錄具有相類似的目錄結構。讓軟件包管理器來管理/usr目錄,而把自定義的腳本(scripts)放到/usr/local目錄下面,我想這應該是個不錯的主意。

/media

Some distros use this folder to mount things like usb disks, cd or dvd drives and other filesystems.

/media

有些linux的發行版使用這個目錄來掛載那些usb接口的移動硬盤(包括U盤)、CD/DVD驅動器等等。


分享到:


相關文章: