`
mylxiaoyi
  • 浏览: 327676 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

The Linux filesystem explained

阅读更多
By Mayank Sarup <mayank@freeos.com>
 Posted: ( 2001-01-03 10:08:44 EST by  )
 The first thing that most new users shifting from Windows will find
 confusing is navigating the Linux filesystem. The Linux filesystem
 does things a lot more differently than the Windows filesystem.
 This article explains the differences and takes you through the
 layout of the Linux filesystem.
For starters, there is only a single hierarchal directory structure.
Everything starts from the root directory, represented by '/', and then
expands into sub-directories. Where DOS/Windows had various partitions and
then directories under those partitions, Linux places all the partitions
under the root directory by 'mounting' them under specific directories.
Closest to root under Windows would be c:.
Under Windows, the various partitions are detected at boot and assigned a
drive letter. Under Linux, unless you mount a partition or a device, the
system does not know of the existence of that partition or device. This
might not seem to be the easiest way to provide access to your partitions
or devices but it offers great flexibility.
This kind of layout, known as the unified filesystem, does offer several
advantages over the approach that Windows uses. Let's take the example of
the /usr directory. This directory off the root directory contains most of
the system executables. With the Linux filesystem, you can choose to mount
it off another partition or even off another machine over the network. The
underlying system will not know the difference because /usr appears to be
a local directory that is part of the local directory structure! How many
times have you wished to move around executables and data under Windows,
only to run into registry and system errors? Try moving c:windowssystem
to another partition or drive.
Another point likely to confuse newbies is the use of the frontslash '/'
instead of the backslash '' as in DOS/Windows. So c:windowssystem would
be /c/windows/system. Well, Linux is not going against convention here.
Unix has been around a lot longer than Windows and was the standard a lot
before Windows was. Rather, DOS took the different path, using '/' for
command-line options and '' as the directory separator.
To liven up matters even more, Linux also chooses to be case sensitive.
What this means that the case, whether in capitals or not, of the
characters becomes very important. So this is not the same as THIS or ThIs
for that matter. This one feature probably causes the most problems for
newbies.
We now move on to the layout or the directory structure of the Linux
filesystem. Given below is the result of a 'ls -p' in the root directory.
bin/ dev/ home/ lost+found/ proc/ sbin/ usr/
boot/ etc/ lib/ mnt/ root/ tmp/ var/
/sbin - This directory contains all the binaries that are essential to the
working of the system. These include system administration as well as
maintenance and hardware configuration programs. Find lilo, fdisk, init,
ifconfig etc here. These are the essential programs that are required by
all the users. Another directory that contains system binaries is /usr/sbin.
This directory contains other binaries of use to the system administrator.
This is where you will find the network daemons for your system along with
other binaries that only the system administrator has access to, but which are
not required for system maintenance, repair etc.
/bin - In contrast to /sbin, the bin directory contains several useful
commands that are used by both the system administrator as well as
non-privileged users. This directory usually contains the shells like
bash, csh etc. as well as much used commands like cp, mv, rm, cat, ls.
There also is /usr/bin, which contains other user binaries. These binaries
on the other hand are not essential for the user. The binaries in /bin
however, a user cannot do without.
/boot - This directory contains the system.map file as well as the Linux
kernel. Lilo places the boot sector backups in this directory.
/dev - This is a very interesting directory that highlights one important
characteristic of the Linux filesystem - everything is a file or a
directory. Look through this directory and you should see hda1, hda2 etc,
which represent the various partitions on the first master drive of the
system. /dev/cdrom and /dev/fd0 represent your CDROM drive and your floppy
drive. This may seem strange but it will make sense if you compare the
characteristics of files to that of your hardware. Both can be read from
and written to. Take /dev/dsp, for instance. This file represents your
speaker device. So any data written to this file will be re-directed to
your speaker. Try 'cat /etc/lilo.conf > /dev/dsp' and you should hear some
sound on the speaker. That's the sound of your lilo.conf file! Similarly,
sending data to and reading from /dev/ttyS0 ( COM 1 ) will allow you to
communicate with a device attached there - your modem.
/etc - This directory contains all the configuration files for your system.
Your lilo.conf file lies in this directory as does hosts, resolv.conf and
fstab. Under this directory will be X11 sub-directory which contains the
configuration files for X. More importantly, the /etc/rc.d directory
contains the system startup scripts. This is a good directory to backup
often. It will definitely save you a lot of re-configuration later if you
re-install or lose your current installation.
/home - Linux is a multi-user environment so each user is also assigned a
specific directory which is accessible only to them and the system
administrator. These are the user home directories, which can be found
under /home/username. This directory also contains the user specific
settings for programs like IRC, X etc.
/lib - This contains all the shared libraries that are required by system
programs. Windows equivalent to a shared library would be a DLL file.
/lost+found - Linux should always go through a proper shutdown. Sometimes
your system might crash or a power failure might take the machine down.
Either way, at the next boot, a lengthy filesystem check using fsck will
be done. Fsck will go through the system and try to recover any corrupt
files that it finds. The result of this recovery operation will be placed
in this directory. The files recovered are not likely to be complete or
make much sense but there always is a chance that something worthwhile is
recovered.
/mnt - This is a generic mount point under which you mount your filesystems
or devices. Mounting is the process by which you make a filesystem
available to the system. After mounting your files will be accessible
under the mount-point. This directory usually contains mount points or
sub-directories where you mount your floppy and your CD. You can also
create additional mount-points here if you want. There is no limitation to
creating a mount-point anywhere on your system but convention says that
you do not litter your file system with mount-points.
/opt - This directory contains all the software and add-on packages that
are not part of the default installation. Generally you will find KDE and
StarOffice here. Again, this directory is not used very often as it's
mostly a standard in Unix installations.
/proc - This is a special directory on your system. We have a more detailed
article on this one here.
/root - We talked about user home directories earlier and well this one is
the home directory of the user root. This is not to be confused with the
system root, which is directory at the highest level in the filesystem.
/tmp - This directory contains mostly files that are required temporarily.
Many programs use this to create lock files and for temporary storage of
data. On some systems, this directory is cleared out at boot or at
shutdown.
/usr - This is one of the most important directories in the system as it
contains all the user binaries. X and its supporting libraries can be
found here. User programs like telnet, ftp etc are also placed here.
/usr/doc contains useful system documentation. /usr/src/linux contains the
source code for the Linux kernel.
/var - This directory contains spooling data like mail and also the output
from the printer daemon. The system logs are also kept here in
/var/log/messages. You will also find the database for BIND in /var/named
and for NIS in /var/yp.
This was a short and basic look at the Linux filesystem. You do need to
have at least this basic knowledge of the layout of the filesystem to
fully utilize its potential. One good place to read about the filesystem
is this detailed document at www.pathname.com/fhs/1.2/fsstnd-toc.html that
specifies the standard structure of the Linux filesystem.
分享到:
评论

相关推荐

    Linux Filesystem & Storage Tuning.pdf

    Linux文件系统和存储调优是系统管理中的一个重要部分,其涉及对Linux环境中存储设备和文件系统进行优化配置,以达到更好的性能表现和可靠性。本文档中的内容涉及了多个与Linux文件系统调优相关的知识点。 首先,...

    Linux_Create_FileSystem

    在Linux操作系统中,创建文件系统是一项基础且重要的任务,它涉及到对磁盘分区的管理和格式化,以便系统能够识别和管理存储空间。本教程将详细解释如何在Linux中创建标准的Linux分区以及逻辑卷管理(LVM)分区,并...

    Linux-Filesystem-Hierarchy.

    Linux-Dictionary.pdf GNU-Linux-Tools-Summary.pdf Bash-Beginners-Guide.pdf abs-guide.pdf 博文链接:https://detox.iteye.com/blog/1882849

    linux_filesystem.rar_linux_linux 文件系统_linux_filesystem

    在这个"linux_filesystem.rar"压缩包中,包含的资源可能是对Linux文件系统的一些源代码或文档的注释,帮助我们深入理解其工作原理。让我们一起探索Linux文件系统的一些关键知识点。 1. **文件系统层次结构标准 (FHS...

    Linux Filesystem Hierarchy

    在 Linux 操作系统中,文件系统层次结构(Filesystem Hierarchy Standard, FHS)是一项重要的标准,它定义了如何组织文件和目录,以确保不同发行版之间的兼容性和一致性。本文档根据 FSSTND v2.3 最终版本(2004 年 ...

    yaffs-src.tar.gz_NAND_linux filesystem_yaffs_yaffs.tar.gz

    在嵌入式系统和Linux平台中,YAFFS被广泛应用于各种设备,如智能手机、路由器、数字媒体播放器等,因为它能有效地管理和优化NAND闪存的特性。 NAND闪存是一种非易失性存储技术,它没有机械运动部件,因此读取速度快...

    linux mount报错:you must specify the filesystem type的解决方法

    mount: you must specify the filesystem type 先执行:mkfs.ext3 /dev/vdb # mkfs.ext3 /dev/vdb mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 ...

    filesystem

    File system.PDF

    Learning.Embedded.Linux.using.the.Yocto.Project.1784397393

    This book will go through Linux kernel features and source code, present information on how to build a kernel source, modules, and the Linux root filesystem. You'll be given an overview of the ...

    Tegra_Linux_Sample-Root-Filesystem_R24.2.1_aarch64.tbz2

    ShieldTV刷机系统文件,Tegra_Linux_Sample-Root-Filesystem_R24.2.1_aarch64.tbz2。 来自于Jetpack3.0的系统样本文件,包含系统根目录

    linux_fileSystem.zip_linux 文件系统_linux文件系统_sum3xd

    Linux 文件系统是操作系统的核心组成部分,它负责管理存储设备上的数据,提供...通过阅读并理解“linux_fileSystem.cpp”,开发者可以深入了解Linux系统如何处理文件操作,并有可能学习到如何实现自己的文件系统模块。

    《Embedded Linux》(嵌入式Linux)英文版

    『下载说明』 这里提供的是《Embedded Linux》(嵌入式Linux)一书的英文版下载。此为高清PDF格式。 &lt;br&gt; 【内容提要】 本书适合嵌入式系统和信息设备设计人员阅读,也可作为普通Linux程序员的参考...

    The Linux Kernel API

    ### Linux内核API详解 #### 一、Linux VFS(虚拟文件系统) **1.1 目录缓存** 在 Linux 内核中,目录缓存(Directory Cache)是用于加速目录查找操作的一种机制。它通过缓存最近访问过的目录条目来减少磁盘 I/O ...

    the sysfs filesystem.pdf

    **Sysfs** 是 Linux 2.6 内核中的一个特性,它允许内核代码通过内存中的文件系统向用户进程导出信息。该文件系统的目录层次组织非常严格,并且基于内核数据结构的内部组织方式。在文件系统中创建的文件通常是 ASCII ...

    ARM linux的交叉开发环境,kernel, filesystem, bootloder安装

    这个过程涉及到kernel、filesystem以及bootloader的构建与安装。本文将详细解释如何在Ubuntu系统上设置这个环境。 首先,我们需要创建一个方便开发的目录结构。通过以下命令在/home下创建名为`armnfs`的目录,并...

    Linux_Root_filesystem.rar_ROOT_filesystem包_linux root system_mkr

    `Linux_Root_filesystem.rar` 是一个压缩包,其中包含了一个预构建的根文件系统以及一个用于制作根文件系统的脚本`mkrootfs.sh`。这个包特别适合于进行交叉编译,即在一种架构的计算机上构建适用于另一种架构的Linux...

    深入理解linux内核(第三版).rar

    The Virtual Filesystem and the Second Extended Filesystem Process creation and scheduling Signals, interrupts, and the essential interfaces to device drivers Timing Synchronization in the kernel ...

    13.docx The Virtual Filesystem

    只有通过现代操作系统,如 Linux,通过虚拟接口抽象对文件系统的访问,才有可能实现这样的互操作性和通用访问。 虚拟文件系统(VFS)是Linux内核的一个关键组成部分,它提供了一个统一的接口,使得用户空间的应用...

    [HTML5] Using the HTML5 Filesystem API (英文版)

    [奥莱理] Using the HTML5 Filesystem API (英文版) [奥莱理] Using the HTML5 Filesystem API (E-Book) ☆ 出版信息:☆ [作者信息] Eric Bidelman [出版机构] 奥莱理 [出版日期] 2011年08月02日 [图书页数] ...

    linux_filesystem.rar_linux 文件系统

    在嵌入式linux系统中,文件系统是一个非常重要的组成部分,如果根文件系统工 作不正常,则整个系统将无法工作,系统启动的时候会出现kernel pannic的大故障报警。 首先简要的介绍一下建立嵌入式的文件系统所需要的...

Global site tag (gtag.js) - Google Analytics