Linux目录标准

根据Unix FHS(Filesystem Hierarchy Standard)的建议,类Unix的文件系统遵循一定的标准,此只作为参考,而不是让编程人员当做手册。

root fs中的内容必须能够启动,恢复和修复系统。为了启动系统,需要在root分区装有足够的工具来挂载其他的文件系统,这些包括utilities, configuration, boot loader information等。

一级目录

root fs由于以下几点原因会被保持得比较小

1.偶尔会mount到非常小的设备上

2.root fs包含许多系统定制化的配置文件。比如定制化到某个系统的kernel等。意味着root fs通常不能再网络文件系统中共享。所以在网络系统中让它尽量小,可以姐还是呢过不共享文件占用的空间。

如下的目录和符号链接需要放入 /

DirectoryDescription
binEssential command binaries
bootStatic files of the boot loader
devDevice files
etcHost-specific system configuration
libEssential shared libraries and kernel modules
mediaMount point for removeable media
mntMount point for mounting a filesystem temporarily
optAdd-on application software packages
sbinEssential system binaries
srvData for services provided by this system
tmpTemporary files
usrSecondary hierarchy
varVariable data
如果下面的目录存在,也必须放入/中

DirectoryDescription
homeUser home directories (optional)
lib<qual>Alternate format essential shared libraries (optional)
rootHome directory for the root user (optional)


/bin

目的:当系统中没有其他文件系统被挂载时(如single user模式),包含着管理员和普通用户需要用到的命令。通常也被脚本间接地调用。

要求:/bin目录下不能含有子目录

如下需要放入/bin目录

CommandDescription
catUtility to concatenate files to standard output
chgrpUtility to change file group ownership
chmodUtility to change file access permissions
chownUtility to change file owner and group
cpUtility to copy files and directories
dateUtility to print or set the system data and time
ddUtility to convert and copy a file
dfUtility to report filesystem disk space usage
dmesgUtility to print or control the kernel message buffer
echoUtility to display a line of text
falseUtility to do nothing, unsuccessfully
hostnameUtility to show or set the system's host name
killUtility to send signals to processes
lnUtility to make links between files
loginUtility to begin a session on the system
lsUtility to list directory contents
mkdirUtility to make directories
mknodUtility to make block or character special files
moreUtility to page through text
mountUtility to mount a filesystem
mvUtility to move/rename files
psUtility to report process status
pwdUtility to print name of current working directory
rmUtility to remove files or directories
rmdirUtility to remove empty directories
sedThe `sed' stream editor
shThe Bourne command shell
sttyUtility to change and print terminal line settings
suUtility to change user ID
syncUtility to flush filesystem buffers
trueUtility to do nothing, successfully
umountUtility to unmount file systems
unameUtility to print system information
如果下面文件存在,也必须放入/bin目录下

CommandDescription
cshThe C shell (optional)
edThe `ed' editor (optional)
tarThe tar archiving utility (optional)
cpioThe cpio archiving utility (optional)
gzipThe GNU compression utility (optional)
gunzipThe GNU uncompression utility (optional)
zcatThe GNU uncompression utility (optional)
netstatThe network statistics utility (optional)
pingThe ICMP network test utility (optional)

/boot:包含boot loader的静态文件

目的:此目录包含了启动过程中需要的一切。因此/boot目录存放的数据被使用时,kernel还没有运行用户态程序。

要求:操作系统内核必须放入/boot中。


/dev:存放设备文件

目的:


/etc:主机系统配置文件目录

目的:存放了配置文件。一个配置文件控制一个程序的操作,它必须是static,且不是可执行文件。

如果安装了如下子系统,如下的配置文件必须放入/etc中。

FileDescription
csh.loginSystemwide initialization file for C shell logins (optional)
exportsNFS filesystem access control list (optional)
fstabStatic information about filesystems (optional)
ftpusersFTP daemon user access control list (optional)
gatewaysFile which lists gateways for routed (optional)
gettydefsSpeed and terminal settings used by getty (optional)
groupUser group file (optional)
host.confResolver configuration file (optional)
hostsStatic information about host names (optional)
hosts.allowHost access file for TCP wrappers (optional)
hosts.denyHost access file for TCP wrappers (optional)
hosts.equivList of trusted hosts for rlogin, rsh, rcp (optional)
hosts.lpdList of trusted hosts for lpd (optional)
inetd.confConfiguration file for inetd (optional)
inittabConfiguration file for init (optional)
issuePre-login message and identification file (optional)
ld.so.confList of extra directories to search for shared libraries (optional)
motdPost-login message of the day file (optional)
mtabDynamic information about filesystems (optional)
mtools.confConfiguration file for mtools (optional)
networksStatic information about network names (optional)
passwdThe password file (optional)
printcapThe lpd printer capability database (optional)
profileSystemwide initialization file for sh shell logins (optional)
protocolsIP protocol listing (optional)
resolv.confResolver configuration file (optional)
rpcRPC protocol listing (optional)
securettyTTY access control for root login (optional)
servicesPort names for network services (optional)
shellsPathnames of valid login shells (optional)
syslog.confConfiguration file for syslogd (optional)

/home:用户根目录


/lib:必要的共享库和内核模块

目的: 此目录包含的libvrary images是启动系统时和在root fs运行命令时需要的,比如/bin 和/sbin

要求:下类文件需要放入此目录。

FileDescription
libc.so.*The dynamically-linked C library (optional)
ld*The execution time linker/loader (optional)

/media:可且在媒体设备的挂载点

目的:此目录中的子目录是作为各种可卸载设备的挂载点,如floppy disks, cdroms .


/mnt:临时文件系统的挂载点

目的:做临时挂载用,此目录不能被安装程序使用,应该使用系统中空闲的目录作为替换。


/opt:附加的应用程序软件包,用于自行安装软件的位置,不过一般都安装在/usr/local中

目的:A package to be installed in /opt must locate its static files in a separate /opt/<package> or /opt/<provider> directory tree, where <package> is a name that describes the software package and <provider> is the provider's LANANA registered name.


/root:root user的Home目录


/sbin:系统二进制文件

目的:Utilities used for system administration (and other root-only commands) are stored in /sbin/usr/sbin, and /usr/local/sbin. root用户的命令都是/sbin目录下的

/sbin contains binaries essential for booting, restoring, recovering, and/or repairing the system in addition to the binaries in /bin[18] Programs executed after /usr is known to be mounted (when there are no problems) are generally placed into /usr/sbin. Locally-installed system administration programs should be placed into /usr/local/sbin.


如下执行文件应放入该目录下

CommandDescription
fastbootReboot the system without checking the disks (optional)
fasthaltStop the system without checking the disks (optional)
fdiskPartition table manipulator (optional)
fsckFile system check and repair utility (optional)
fsck.*File system check and repair utility for a specific filesystem (optional)
gettyThe getty program (optional)
haltCommand to stop the system (optional)
ifconfigConfigure a network interface (optional)
initInitial process (optional)
mkfsCommand to build a filesystem (optional)
mkfs.*Command to build a specific filesystem (optional)
mkswapCommand to set up a swap area (optional)
rebootCommand to reboot the system (optional)
routeIP routing table utility (optional)
swaponEnable paging and swapping (optional)
swapoffDisable paging and swapping (optional)
updateDaemon to periodically flush filesystem buffers (optional)


/srv:系统提供的service data


/tmp:临时文件,


二级目录

/usrs shareable, read-only data.

 is the second major section of the filesystem. /usr is shareable, read-only data. That means that /usr should be shareable between various FHS-compliant hosts and must not be written to. Any information that is host-specific or varies with time is stored elsewhere.

Large software packages must not use a direct subdirectory under the /usr hierarchy.


要求:

DirectoryDescription
binMost user commands
includeHeader files included by C programs
libLibraries
localLocal hierarchy (empty after main installation)
sbinNon-vital system binaries
shareArchitecture-independent data

/usr/bin: Most user commands

目的:这时系统中最主要的可执行命令

The following files, or symbolic links to files, must be in /usr/bin, if the corresponding subsystem is installed:

CommandDescription
perlThe Practical Extraction and Report Language (optional)
pythonThe Python interpreted language (optional)
tclshSimple shell containing Tcl interpreter (optional)
wishSimple Tcl/Tk windowing shell (optional)
expectProgram for interactive dialog (optional)

/usr/include: Directory for standard include files.

目的:This is where all of the system's general-use include files for the C programming language should be placed.


/usr/lib: Libraries for programming and packages

目的:/usr/lib includes object files, libraries, and internal binaries that are not intended to be executed directly by users or shell scripts.


/usr/local: is for use by the system administrator when installing software locally. 

The following directories, or symbolic links to directories, must be in /usr/local

DirectoryDescription
binLocal binaries
etcHost-specific system configuration for local binaries
gamesLocal game binaries
includeLocal C header files
libLocal libraries
manLocal online manuals
sbinLocal system binaries
shareLocal architecture-independent hierarchy
srcLocal source code

/usr/sbin:Non-essential standard system binaries


/var:此目录包含的是可变数据文件。包括spool directory, log file等。

其下应包含如下目录:
DirectoryDescription
cacheApplication cache data
libVariable state information
localVariable data for /usr/local
lockLock files
logLog files and directories
optVariable data for /opt
runData relevant to running processes
spoolApplication spool data
tmpTemporary files preserved between system reboots

一般还包含如下特殊目录:
DirectoryDescription
accountProcess accounting logs (optional)
crashSystem crash dumps (optional)
gamesVariable game data (optional)
mailUser mailbox files (optional)
ypNetwork Information Service (NIS) database files (optional)
/var/cache  is intended for cached data from applications. Such data is locally generated as a result of time-consuming I/O or calculation. The application must be able to regenerate or restore the data. Unlike  /var/spool , the cached files can be deleted without data loss. The data must remain valid between invocations of the application and rebooting the system.

/var/chash:
This directory holds system crash dumps. As of the date of this release of the standard, system crash dumps were not supported under Linux but may be supported by other systems which may comply with the FHS.

/var/lib:
This hierarchy holds state information pertaining to an application or the system. State information is data that programs modify while they run, and that pertains to one specific host. Users must never need to modify files in  /var/lib  to configure a package's operation.

State information is generally used to preserve the condition of an application (or a group of inter-related applications) between invocations and between different instances of the same application. State information should generally remain valid after a reboot, should not be logging output, and should not be spooled data.


/var/log: 日志文件和目录
This directory contains miscellaneous log files. Most logs must be written to this directory or an appropriate subdirectory.
FileDescription
lastlogrecord of last login of each user
messagessystem messages from syslogd
wtmprecord of all logins and logouts

/var/spool:
/var/spool represents work to be done in the future (by a program, user, or administrator); often data is deleted after it has been processed









  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值