文件系統(tǒng)是一個(gè)分區(qū)或磁盤上的文件的邏輯集合。分區(qū)是信息的容器,如果需要的話,可以跨越整個(gè)硬盤驅(qū)動(dòng)器。
你的硬盤驅(qū)動(dòng)器,可以有不同的分區(qū)通常只包含一個(gè)文件系統(tǒng),如一個(gè)文件系統(tǒng) / 文件系統(tǒng)或其他包含/home文件系統(tǒng)。
每個(gè)分區(qū)的一個(gè)文件系統(tǒng)允許不同的文件系統(tǒng)的維護(hù)和管理邏輯。
在Unix中的一切都被認(rèn)為是一個(gè)文件,包括物理設(shè)備,如DVD-ROM,USB設(shè)備,軟盤驅(qū)動(dòng)器,等等。
Unix 使用層次結(jié)構(gòu)的文件系統(tǒng)的結(jié)構(gòu),很象一個(gè)倒置的樹,在該文件系統(tǒng)的基礎(chǔ)上,并從那里擴(kuò)展的所有其他目錄的根目錄(/)。
UNIX 文件系統(tǒng)中的文件和目錄的集合,具有以下屬性:
它有一個(gè)根目錄(/),其中包含其他文件和目錄。
每個(gè)文件或目錄被唯一標(biāo)識(shí),它的名字,它的目錄,以及一個(gè)唯一的標(biāo)識(shí)符,通常被稱為一個(gè)inode。
按照慣例,根目錄下有一個(gè)inode號(hào)為2和3的lost + found目錄中有一個(gè)inode號(hào)。 inode編號(hào)0和1不使用。指定-i選項(xiàng)的ls命令可以看到文件的inode編號(hào)。
這是自包含的。沒有一個(gè)文件系統(tǒng),以及任何其他的之間的依賴關(guān)系。
目錄有特定的目的,普遍持相同類型的信息,輕松定位文件。以下是主要的Unix版本上存在的目錄:
目錄 | 描述 |
---|---|
/ | This is the root directory which should contain only the directories needed at the top level of the file structure. |
/bin | This is where the executable files are located. They are available to all user. |
/dev | These are device drivers. |
/etc | Supervisor directory commands, configuration files, disk configuration files, valid user lists, groups, ethernet, hosts, where to send critical messages. |
/lib | Contains shared library files and sometimes other kernel-related files. |
/boot | Contains files for booting the system. |
/home | Contains the home directory for users and other accounts. |
/mnt | Used to mount other temporary file systems, such as cdrom and floppy for the CD-ROM drive and floppy diskette drive, respectively |
/proc | Contains all processes marked as a file by process number or other information that is dynamic to the system. |
/tmp | Holds temporary files used between system boots |
/usr | Used for miscellaneous purposes, or can be used by many users. Includes administrative commands, shared files, library files, and others |
/var | Typically contains variable-length files such as log and print files and any other type of file that may contain a variable amount of data |
/sbin | Contains binary (executable) files, usually for system administration. For examplefdisk and ifconfig utlities. |
/kernel | Contains kernel files |
現(xiàn)在你了解基本的文件系統(tǒng),你就可以開始導(dǎo)航到你需要的文件。以下是您將使用瀏覽系統(tǒng)的命令:
命令 | 描述 |
---|---|
cat filename | Displays a filename. |
cd dirname | Moves you to the directory identified. |
cp file1 file2 | Copies one file/directory to specified location. |
file filename | Identifies the file type (binary, text, etc). |
find filename dir | Finds a file/directory. |
head filename | Shows the beginning of a file. |
less filename | Browses through a file from end or beginning. |
ls dirname | Shows the contents of the directory specified. |
mkdir dirname | Creates the specified directory. |
more filename | Browses through a file from beginning to end. |
mv file1 file2 | Moves the location of or renames a file/directory. |
pwd | Shows the current directory the user is in. |
rm filename | Removes a file. |
rmdir dirname | Removes a directory. |
tail filename | Shows the end of a file. |
touch filename | Creates a blank file or modifies an existing file.s attributes. |
whereis filename | Shows the location of a file. |
which filename | Shows the location of a file if it is in your PATH. |
您可以使用聯(lián)機(jī)幫助幫助這里提到的每個(gè)命令的語法檢查完成。
第一種方式來管理你的分區(qū)空間使用df(磁盤空閑)命令。命令df-K(可用磁盤)以KB為單位顯示磁盤空間使用情況,如下圖所示:
$df -k Filesystem 1K-blocks Used Available Use% Mounted on /dev/vzfs 10485760 7836644 2649116 75% / /devices 0 0 0 0% /devices $
一些目錄,如 /devices,顯示0字節(jié),使用和可用列的能力,以及0%。這些特殊的文件系統(tǒng)(或虛擬),雖然它們駐留在磁盤上/下,它們本身不占用磁盤空間。
df -k 輸出所有的Unix系統(tǒng)上大致相同。下面是它通常包括:
Column | 描述 |
---|---|
Filesystem | The physical file system name. |
kbytes | Total kilobytes of space available on the storage medium. |
used | Total kilobytes of space used (by files). |
avail | Total kilobytes available for use. |
capacity | Percentage of total space used by files. |
Mounted on | What the file system is mounted on. |
你可以使用-h(人類可讀的)選項(xiàng)顯示的輸出格式,顯示的大小更容易理解的符號(hào)。
使用du(磁盤使用率)命令使您能夠在一個(gè)特定的目錄指定目錄顯示磁盤空間使用情況。
此命令是有幫助的,如果你要確定一個(gè)特定的目錄多大的空間。下面的命令將顯示每個(gè)目錄所消耗的塊數(shù)。單塊可能需要512字節(jié)或1千字節(jié),這取決于你的系統(tǒng)。
$du /etc 10 /etc/cron.d 126 /etc/default 6 /etc/dfs ... $
-h選項(xiàng)使輸出更容易理解:
$du -h /etc 5k /etc/cron.d 63k /etc/default 3k /etc/dfs ... $
必須安裝的文件系統(tǒng),以便使用該系統(tǒng)。要看到什么是目前在您的系統(tǒng)上安裝(可以使用),使用這個(gè)命令:
$ mount /dev/vzfs on / type reiserfs (rw,usrquota,grpquota) proc on /proc type proc (rw,nodiratime) devpts on /dev/pts type devpts (rw) $
/ mnt目錄下,Unix的慣例,是位于臨時(shí)裝片(如CD-ROM驅(qū)動(dòng)器,遠(yuǎn)程網(wǎng)絡(luò)驅(qū)動(dòng)器,軟盤驅(qū)動(dòng)器)。如果您需要掛載文件系統(tǒng),可以使用mount命令的語法如下:
mount -t file_system_type device_to_mount directory_to_mount_to
例如,如果你想要的CD-ROM安裝到目錄 /mnt/cdrom,例如,您可以鍵入:
$ mount -t iso9660 /dev/cdrom /mnt/cdrom
假定您的CD-ROM設(shè)備名為 /dev/cdrom命令要掛載到 /mnt/cdrom。更具體的信息或幫助信息在命令行中鍵入mount -h ,請(qǐng)參閱安裝手冊(cè)頁。
安裝后,您可以使用cd 命令導(dǎo)航最新的文件系統(tǒng)掛載點(diǎn)。
從您的系統(tǒng)中卸載(刪除)文件系統(tǒng),使用umount命令識(shí)別掛載點(diǎn)或設(shè)備
例如,要卸載光驅(qū),使用下面的命令:
$ umount /dev/cdrom
mount 命令,使您能夠訪問您的文件系統(tǒng),但最現(xiàn)代的Unix系統(tǒng),自動(dòng)裝載功能,使這個(gè)過程對(duì)用戶不可見,無需干預(yù)。
用戶和組配額提供的機(jī)制,可以限制特定組內(nèi)的單個(gè)用戶或所有用戶使用的空間量由管理員定義的值。
配額圍繞兩個(gè)限制,允許用戶采取一些行動(dòng),如果量的空間或磁盤塊數(shù)開始超過管理員定義的限制:
Soft Limit: 如果用戶超過定義的限制,有一個(gè)寬限期,允許用戶騰出一些空間。
Hard Limit: 當(dāng)達(dá)到硬限制,無論在寬限期,沒有進(jìn)一步的文件或塊可以分配。
有一些命令來管理配額:
命令 | 描述 |
---|---|
quota | Displays disk usage and limits for a user of group. |
edquota | This is a quota editor. Users or Groups quota can be edited using this command. |
quotacheck | Scan a filesystem for disk usage, create, check and repair quota files |
setquota | This is also a command line quota editor. |
quotaon | This announces to the system that disk quotas should be enabled on one or more filesystems. |
上一篇:UNIX 管道和過濾器下一篇:Unix是什么?
|