Use Linux also has more than a year has recently also been maintaining the site system host Below is the Linux directory structure description I am using CentOS system, long time no blog posts a will organize the recent own use of the knowledge of the point, published in Linux related articles, record your Linux bit by bit.
linux directory structure
/: Root directory, generally only the root storage directory, do not store the file, / etc, / bin, / dev, / lib, / sbin should be placed in the root directory of a partition
/ Bin: / usr / bin: executable binary files directory, commonly used commands such as ls, tar, mv, cat and so on.
/ Boot: put some linux file system used at startup. / Boot / vmlinuz for the linux kernel files, and / boot / gurb. It suggested a separate partition, the partition size to 100M
/ Dev: file storage device linux system to access a file in the directory, which is equivalent to access a device commonly used to mount the CD mount / dev / cdrom / mnt.
/ Etc: system configuration file directory is not recommended to store the executable file in this directory, there are important configuration files /etc/inittab,/etc/fstab,/etc/init.d,/etc/X11,/etc remember to backup before /sysconfig,/etc/xinetd.d modify the configuration file. NOTE: / etc / X11 store and x windows related settings.
/ Home: the default user's home directory, create a new user account, the user's home directory are stored in this directory, ~ represents the current user's home directory, ~ test indicates that the user's home directory test. It recommends a separate partition, and a larger set of disk space to store user data
Requires the system to use the library catalog, the program in the implementation process, need to call some additional parameters to assist libraries, the more important the directory / lib /: / lib: / usr / lib: / usr / local / lib modules.
/ Lost + fount: the system generates an exception error, will some of the lost fragments placed here directory, usually this directory will automatically appear in the installation directory. Such as a hard disk to load / disk, and this directory will automatically generated directory / disk / lost + found
/ Mnt: / media: CD default mount point, usually disc mounted at / mnt / cdrom, not necessarily, you can choose any location to mount.
/ Opt: to install additional software to the host display directory. Such as: Fedora community development software FC4 use if you want to install the new KDE desktop software, you can install the software in the directory. Previous Linux system, used to stand at / usr / local directory
/ Proc: The data in this directory are in memory, such as the core of the system, peripherals, network status, since the data are stored in memory, so do not take up disk space, the more important the directory / proc / cpuinfo, / proc / interrupts , / proc / dma, / proc / ioports, / proc / net / * etc.
/ Root: the system administrator root's home directory, the system first boot partition for /, so it's best to / root and / or placed in a partition.
/ Sbin: / usr / sbin: / usr / local / sbin: executable commands placement system administrators, such as fdisk, shutdown, mount and so on. And / bin is different is that these directories are commands to the system administrator root to use, the average user can only "view" and can not set up and use.
/ Tmp: general user or program being executed temporary file storage directory, anyone can access the important data can not be placed in this directory
/ Srv: the service started need to access the data directory, such as the need to visit the website www service data stored in / srv / www within
/ Usr: application store directory, / usr / bin storage applications, / usr / share to store shared data, / usr / lib store can not be run directly, but some library files required to run many programs. / Usr / local: storage software upgrade package. / Usr / share / doc: system description file storage directory. / Usr / share / man: Program description file storage directory, the query will use man ls /usr/share/man/man1/ls.1.gz content suggestions separate partition, set up large amount of disk space
/ Var: execution place systems frequently changing files, log files, such as to change the / var / log, / var / log / message: All of the log file storage directory, / var / spool / mail: e-mail stored in the directory, / var / run: after the program or service is started, its PID is stored in the directory. It recommends a separate partition, set up large amount of disk space
/ Dev: directory
dev is the device (device) abbreviation. / Dev directory for all users is very important. Because this directory contains all Linux external devices used in the system. But this is not the driver put the external device, and this is Windows, dos operating system is not the same. It is actually a port to access these external devices. We can be very easy to access these external devices, and access a file, a directory without any distinction.
Linux Unix followed the style, all equipment is recognized as a file.
Device files are divided into two types: block device file (b) and character device files (c)
Device files are typically stored in the / dev directory, device file as follows for common explanation:
/ Dev / hd [a-t]: IDE device
/ Dev / sd [a-z]: SCSI devices
/ Dev / fd [0-7]: Standard floppy
/ Dev / md [0-31]: soft raid device
/ Dev / loop [0-7]: local loopback device
/ Dev / ram [0-15]: Memory
/ Dev / null: Unlimited data receiving device, the equivalent of a black hole
/ Dev / zero: zero unlimited resources
/ Dev / tty [0-63]: Virtual Terminal
/ Dev / ttyS [0-3]: Serial
/ Dev / lp [0-3]: Parallel
/ Dev / console: Console
/ Dev / fb [0-31]: framebuffer
/ Dev / cdrom => / dev / hdc
/ Dev / modem => / dev / ttyS [0-9]
/ Dev / pilot => / dev / ttyS [0-9]
/ Dev / random: random number of devices
/ Dev / urandom: random number of devices
(PS: random number of devices, later I will write blog articles summarize)
Node / dev directory is how to create?
devf or udev will automatically help you create, too.
kobject sysfs file system is the basis, udev by monitoring, detecting sysfs to acquire new equipment created.
/ Etc: Directory
It contains many files, many network configuration files are in / etc.
/ Etc / rc or /etc/rc.d or /etc/rc*.d start or change the operating level when running scripts or scripts directory.
/ Etc / passwd
User database, which gives the user the domain name, additional information real name, home directory, encrypted password and user.
/ Etc / fstab
mount -a command to start (in the / etc / rc or equivalent startup file) automatically mount the file system list. Linux, it is also includes information enabled with swapon -a swap area.
/ Etc / group
Similar to / etc / passwd, but the description instead of the user group.
/ Etc / inittab
init configuration file.
/ Etc / issue
getty output before the login prompt usually include a short description of the system or welcome information content determined by the system administrator.
/ Etc / motd
Message Of The Day, automatically output after a successful login. Content determined by the system administrator. Regular information such as planned shutdown time for a warning notice.
/ Etc / mtab
List of file systems currently installed by the initialization scripts, automatically updated by the mount command. Need to use a list of currently installed file system, for example, the df command.
/ Etc / shadow
Shadow password file is installed on the system's shadow password software. Shadow password file / etc / passwd file encrypted password to move to the / etc / shadow, whereas the latter only readable by root. This makes it more difficult to decipher passwords.
Profile login command.
/ Etc / printcap
Similar to / etc / termcap, but Different syntax for the printer.
/ Etc / profile, /etc/csh.login, /etc/csh.cshrc
Bourne login or startup file C shells or executed. This allows the system administrator to establish global default environment for all users.
/ Etc / securetty
Confirm the safety terminal, that terminal which allows root to log in. Usually only the virtual consoles are listed, so it is impossible (or at least very difficult) to break into the system via modem or network and get superuser privileges.
/ Etc / shells
It is listed trusted shell.chsh command allows the user to change the login shell in this document specified range. Providing a machine FTP service ftpd server process checks the user's shell is listed in / etc / shells file, will not be permitted if it is not User login.
/ Etc / sysconfig
Network Configuration Related Category
/ Proc: directory
Contents of the file filename
/ Proc / kernel when loading the issued cmdline parameters! Check out this document to learn how the system is started!
Information / proc / cpuinfo CPU of the machine, that contains a clock, and the type of operation functions
/ Proc / devices This file records the main unit code means all the major systems, and mknod about it!
/ Proc / filesystems current system has been mounted filesystem Lo!
/ Proc / interrupts the current state of the system above the IRQ assignments.
/ Proc / ioports currently above each device system configured I / O address.
/ Proc / kcore this is the memory size of it! A big right! But do not read him!
/ Proc / loadavg remember the top and uptime, right? Yes! The average value of the top three is recorded here!
/ Proc / meminfo memory information using free lists, hey! Now here it is possible to!
/ Proc / modules list of modules currently loaded our Linux has to be thought of as drivers for it!
/ Proc / mounts data system has been mounted, the call is out of the mount command data with it!
Where / proc / swaps linked to the system in the end is loaded in memory? Ha ha! Use out partition will be recorded in this matter!
fdisk -l will appear all current partition / proc / partitions to use it? In this document which is also a record Oh!
/ Proc / pci PCI bus in the above, the details of each device! Lspci can be used to look up!
/ Proc Information / uptime uptime is to use the time, there will be friends!
/ Proc / version kernel version uname -a is to use the content displayed it!
/ Proc / bus / * number of bus devices, as well as U disk device is also recorded in this oh!
/ Usr: directory
/ Usr filesystem is often large, since all programs installed here / usr all files from the general Linux distribution;.. Program and other things locally installed in / usr / local This may upgrade when the new system or a new distribution no need to reinstall all programs.
/ Usr / etc to store the settings file
/ Usr / games store games and teaching files
/ Usr / include is for C header files Development Tools
Separate / usr / share data storage structure
/ Usr / bin
Almost all user commands. Some commands in / bin or / usr / local / bin in.
/ Usr / sbin
Root file system unnecessary system management commands, such as most services program.
/ Usr / share / man, / usr / share / info, / usr / share / doc
Manual pages, GNU info documentation, and a variety of other document files.
/ Usr / include
C programming language header file. For consistency this should actually be in / usr / lib, but the name has traditionally supported.
/ Usr / lib
Invariant program or data file subsystems, including some site-wide configuration file name lib comes from library (library); stock at original programming / usr / lib Lane.
/ Usr / local
Software and other files installed locally on here.
/ Usr / src store program's source code
/ Var: directory
/ Var including the general operation of the system to be changed when data is specific to each system, that is not shared with other computers over a network.
/ Var / catman
When the source file cache.man page to format the man page when there is generally / usr / man / man * in; and some man pages may have a pre-formatted version, the presence of / usr / man / cat * in the other the man page for the first time to see the need to format, complete formatted version exists / var / man so that others would not have to wait to look the same when formatting the page. (/ var / catman is often cleared as clear as the temporary directory.)
/ Var / lib
To change the file system during normal operation.
/ Var / local
Variable data program / usr / local installed (that is, the system administrator installed programs). Note that, if necessary, even locally installed programs should use the other / var directory, such as / var / lock.
/ Var / lock
Lock files. Many programs follow a lock file in / var / lock in the agreement, to support that they are using a particular device or file. Other programs will notice the lock file and will not attempt to use the device or file.
/ Var / log
Log files of various programs, especially login (/ var / log / wtmp log all login and logout to the system) and syslog (/ var / log / messages in all core storage systems and program information. / Var / log Lane files often grow indefinitely, should be regularly removed.
/ Var / run
Save the file effective information about the system before the next boot. For example, / var / run / utmp contains information about people currently logged in.
/ Var / spool
mail, news, print queues, and the queue directory other work. Each different spool has its own subdirectory in / var / spool, for example, the user's mailbox in / var / spool / mail in.
/ Var / tmp
Than / tmp or allowed large temporary files need to exist a long time. (Although the system administrator might not allow / var / tmp has a very old one.)
More important directory
In the Linux system, there are several directories is important to note, here are several directories need to pay attention, and preset related purposes:
/ Etc: this directory is very important, as mentioned earlier, you boot the system data files are under this directory, so when the catalog is damaged, then your system probably also about the dead! In the next document, you will find that we often use /etc/rc.d/init.d this subdirectory under this directory, because the init.d subdirectory is open scripts some Linux systems and services (can think into a batch file) place. This file is in /etc/rc.d/rc.local boot executable file.
/ Bin, / sbin, / usr / bin, / usr / sbin: This directory is placed by default executable file, for example userconf root is often used, netconf, perl, gcc, c ++, and so the data are placed in this several directories, so when an executable file if you can not find the character at the prompt, you can check out these four directory! Wherein, / bin, / usr / bin is the instruction to the system used by the user, and / sbin, / usr / sbin is the instruction to the system administrators!
/ Usr / local: this is the system default later let you install your upgrade kit directory. For example, when you find an updated Web kit (such as Apache) can be installed, and you do not want to upgrade your way rpm package, then you can apache install this package under / usr / local. Installed here has the advantage, because the current system we are about the same, so if you want someone else to take over the system, it is relatively easy to use it! Also relatively easy to find data to Oh! So, if you need it, I usually will / usr / local / bin is added to this path in my path.
/ Home: This is a system where there will be an account of the population's home directory settings.
/ Var: This path to important! Regardless of where the record is signed in, all kinds of services when the problem occurred, and the normality of the service records, etc. Records catalog, so when your system has a problem, you need to record this directory file data View La problem ! The default placement mail is here, so he is very important
/ Usr / share / man, / usr / local / man: these two directories for the place where all types of gear described kits, for example, if you execute man man, the system will automatically find all the documentation for the two directory
After the talk over file format, come to talk about the so-called document type it! We mentioned just in the front of the property described flags (d or -) may represent the file or directory that different file types it! Linux file types are mainly under
Regular file (regular file): is the general type of file, by ls -al displayed by the terms of attributes, the first property is [-]. In addition, in accordance with the contents of the file, and it can be roughly divided into two types of documents:
Text File (ascii): This is one of the most Unix systems Hello, almost as long as we can use to set the files belong to this one;
Binary files (binary): In addition to the usual executable scripts (Text batch file), which is a file format;
Directory (directory): is the directory! The first property is [d];
Link file (link): is similar to Windows shortcuts under it! The first property is [l];
Device files (device): Some documents and systems related peripheral, usually concentrated in the under / dev directory! Usually divided into two types:
Block (block) device files: that some of the stored data to provide access to the system interface device, it simply means that the hard disk! One example, your hard disk code is / dev / hda1, etc. files it! The first property is [b];
Character (character) device file: that is, some of the serial port interface devices such as a keyboard, mouse, and so on! The first property is [c].
Linux file system (inode):
Among the Linux system, every file has more than the contents of the data file, including various attributes of the file, for example: their group, belongs to the user, the ability to execute, file creation time, file attributes, and so special. We contents of each file is divided into two parts store, is a property of a file, the other is the content of the document.
To cope with these two different outrageous, so ext2 inode planning out and stored separately to Block attributes of the file (on the inode among) the contents of the file (which is placed in the Block area). When we want a partition format (format) as ext2 when it is necessary to specify the size of the inode and Block for the job, that is, when the partition is formatted as ext2 file system, and he must have inode table block area of these two regions.
Block has said before, he is the smallest unit of data storage. So what inode that? ! Simply put, Block is a record "data file content" area, as inode is a record "related attributes of the file, and the file contents placed in which Block of" information. Simply put, inode addition to the properties of the log file, but also must have the point (pointer) function, that points to the file contents placed among the blocks, so that the operating system can be made to correct the contents of the file ah
The file owner and group (owner / group);
The file access mode;
Type of the file;
Creation date of the file (ctime), read a recent time (atime), last modification time (mtime);
The capacity of the document;
Definition file feature flag (flag), as SetUID ...;
The actual contents of the file point (pointer);