Linux system directory structure: a directory hierarchy standard, commonly used files and directories

1. Hierarchy Standard FHS

FHS (Filesystem Hierarchy Standard) standard directory hierarchy, is a Linux directory specifications.

 

FHS defines two specifications :

  • First layer: the "/" directory at the root of each should put any file data
    • Such as: / etc directory placement system configuration files
    • /etc/exports
    • /etc/hosts/
    • / Bin and / sbin placement programs and system commands
  • Second layer: for subdirectories / usr and / var two directories defined
    • / Var / log log file placement system
    • The / var partition separate category, on the hard disk is large enough. The remaining 20% ​​of the hard disk capacity warning

 

2. The role of commonly used directories

/bin

Essential user command binaries for use by all users

Directory commonly used binary command is located.

/ Bin directory and / usr / bin directory similar.

cat, ls, cp, mv ... store the most frequently used commands.

 

/boot

Static files of the boot loader

Linux kernel and boot the system needed to program files directory.
Storage of some core files at startup Linux, including some connection files and image files.

When installing the system partition generally divide a boot partition.
Common partitions: / boot 128M swap partition, 1.5 times the memory / full to.

 

/dev

Device files

Directory device files, such as sound cards, disk, CD-ROM ...

Stored in the directory of the external device is Linux, Linux in the way of access methods and devices to access the file is the same.

 

/etc

Host-specific system configuration

Binary packages yum, rpm's profile default path .

This directory is used to store configuration files and subdirectories all system management needs.

  • fstab boot automatically mount the disk device file
  • hosts file host name
  • inittab run level boot
  • issue pre-registration information, device information displayed
  • motd after login information, please, description and other settings, the default is empty
  • profile 
  • resolv.conf dns profile

Service startup command stored in the directory /etc/init.d/ 

  • /etc/init.d/sshd
  • /etc/init.d/iptables
 

/home

Average user's home directory.

The user's home directory, in Linux, each user has its own directory, the directory name is based on the general user account named.

 

/lib

This directory is stocked with a system capable of the most basic dynamic link shared libraries, it acts like windows inside the DLL file.
Almost all applications need to use these shared libraries.

 

/lost+found

Under normal circumstances this directory is empty, when the system illegal shutdown, some files stored here.

 

/media

Linux system will automatically identify some devices, for example: U disk, CD-ROM, etc., after the identification, the identification device Linux will mount this directory

 

/ mnt

The system provides this directory is to enable users to temporarily mount other file systems, we can drive mount / mnt /, and then enter the directory where you can view the contents of the CD-ROM drive.

 

/opt

This is for the host to install additional software placed in the directory. 

For example, you can install an Oracle database into this directory, the default is empty

 

/proc

Virtual directory, the system memory map. 

We can get direct access to this information system via directory. 

Contents of this directory is not on the hard disk, but in memory, we can also modify some files inside directly, for example, can be masked by the following command from the host ping command, so that others can not ping to your machine.

 

/root

System Administrator user's home directory

 

/sbin

Super User, storage hypervisor is used by system administrators.

 

/selinux

RedHat or CentOS is a unique directory, security mechanism, similar to the firewall.

 

/srv

Store some data to be extracted after the service starts

 

/sys

This is a big change Linux2.6 kernel.
The directory of a file system sysfs 2.6 kernel center appears to install. 

sysfs file system integrates information on the following three kinds of file systems:

  • Proc file system for process information
  • For devfs file system devices
  • Devpts file system for pseudo terminal

The file system is a visual reflection of kernel device tree. 

When a kernel object is created, the corresponding files and directories are created kernel object subsystem.

 
 

/tmp

Temporary files

 

/usr

Many applications and files are placed in the user directory, similar to the windows of the program files directory

 

/usr/sbin

More advanced management programs and system daemons use of super user

 

/usr/src

Kernel source code to place the default directory

 

/where

This directory is the stuff of expanding, we are used to modify those directories are often placed in this directory. Including various log files.

 

summary:

 
  • / Dev directory device
  • / Etc System configuration and service configuration file, start a command directory
  • / Proc virtual file system kernel and display process information
  • / Tmp temporary files directory, public toilets
  • / Home general user's home directory
  • / Root super administrator's home directory
  • / Var directory changes, usually the log files, cache directory
  • / Usr user programs and data, help files, binary commands directory
  • / Bin directory ordinary user command
  • / Sbin and / usr / sbin directory super user commands

 

3. important subdirectories

You must master the knowledge of Linux directory path

1. /etc/sysconfig/network-scripts/ifcfg-eth0

Configure the network address and GW, making the card entry into force:

  • Restart card /etc/init.d/network restart (affects all LAN) equivalent command: service network restart
  • ifdown eth0 && ifup eth0 only for eth0

Modify the network card is configured to modify this file in network configuration through setup.

 

NIC configuration information within the file eth0: Supplementary

  • DEVICE = eth0 # physical device name
  • HWADDR = 08: 00: 27: 10: a5: MAC address of the NIC # 56, 48
  • TYPE = Ethernet # Ethernet
  • Uniquely identifies UUID = e1aa5279-e4c6-45af-8cbc-a63e5fa2b35d # NIC, the equivalent of identity cards
  • ONBOOT = yes # control card is not boot
  • NM_CONTROLLED=yes 
  • BOOTPROTO=none # proto取【none, static, bootp, dhcp】。
    • none: boot protocol is not used;
    • static statically assigned address;
    • bootp using BOOTP;
    • DHCP, using the DHCP protocol, to automatically assign IP LAN
  • IPADDR = 10.0.0.7 # addr is the IP address
  • NETMASK = 255.255.255.0 # subnet mask, network and host bits divide
  • DNS2 = 202.106.0.20 # DNS to baidu.com become Baidu's server IP, DNS is the domain name and ip analytic tools
  • GATEWAY = 10.0.0.254 # gateway address, router address
  • DNS1 = 8.8.8.8 
  • USERCTL=no

 

2./etc/resolv.conf set up local Linux client DNS configuration files

DNS can be achieved with each other to resolve domain names and IP.

setup -> "network configuration" -> "DNS configuration"

 

The essence is to modify /etc/resolv.conf file set. 

 

Responsible for each other to resolve domain names and IP service is the DNS (Domain name System):
www.baidu.com  <==> 183.232.231.172

 

summary:

  • The client can set the DNS network card configuration file ifcfg-eth0
  • The client can also set the DNS in /etc/resolv.conf
  • NIC in the DNS settings take precedence over /etc/resolv.conf, restart the network card, network card in the DNS setting overrides /etc/resolv.conf

 

3. / etc / hosts set the user name and IP (or domain name) of the corresponding analytical table, corresponding to the local DNS local area network LAN

Similar to the C: \ Windows \ system32 \ drivers \ etc \ hosts, LAN within an IP domain name resolution file.
 

Development and testing to do temporary domain name resolution commonly used English hosts - The static table lookup for host names. 

 

host's resolution is also commonly used in the server room to call each other, as real case resolved portal:
taobao 

[root@oldboy ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
 
 

Role : 

  • Development, product testing and other personnel, through formal name for the test product
  • Calls between servers can use the domain name (internal DNS), to facilitate migration
 

Priority:
dns cache> hosts> dns service

 

4. / etc / sysconfig / network card can modify the machine name and start, gateway configuration

Permanently modify the host name:

  1. Modify / etc / sysconfig / network rid the HOSTNAME value
  2. Change the hostname of the entry into force of the new hostname temporary

Two were modified, logout and then log in exit you will find success. 

cat /etc/sysconfig/network
sed 's#oldboy#zoe#g' /etc/sysconfig/network
sed -i 's#oldboy#zoe#g' /etc/sysconfig/network
hostname zoe
logout
 

View Host Name: 

  • hostname
  • uname -n
 
hostname newname provisional entry into force, logout, user logout and login is newname, but due to the configuration file has not changed, after the system restart invalid. 
 

Boot record to a file 5./etc/fstab mounted file system

Once fstab configuration errors, cause the server to fail to start. 

 

How to fix?

[root@zoe ~]# blkid
/dev/sda1: UUID="e506ded8-c98f-44a0-aed9-8aee1596fc15" TYPE="ext4" 
/dev/sda2: UUID="64b1e144-7c58-45c2-99eb-5410d7b9ae5d" TYPE="swap" 
/dev/sda3: UUID="19261341-e730-45e9-b71b-42bf62cca6dc" TYPE="ext4" 

The first column mounted device, it can be a device name or UUID, or disk label.

 

6./etc/rc.local file used to store boot from the start of the program commands

chkconfig used to manage service yum / rpm installed programs boot from the start .   

 

/Etc/rc.local will boot when the contents of the execution again. 

 

Develop their own program, used to launch commands in /etc/rc.local, implement start-up of these programs, when Linux boot, before signing, the contents of the /etc/rc.local will perform again.

 

How enterprise:
chkconfig and /etc/rc.local will use to see personal habits.
Best to use /etc/rc.local, think of it as the file server.

 
 

7./etc/inittab set the system boot init process will set the system to run level runlevel what kind of load and boot files related to the level corresponding to the setting.

Linux boot process
# Default runlevel. The runlevels used are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
# 
id:3:initdefault:

 

8./etc/init.d storage system startup scripts

The directory to store the system startup scripts
 

9./etc/profile global system environment configuration variables

  • / Etc / bashrc global (all users)
  • / Etc / profile global (all users)
  • ~ / .Bashrc and ~ / .bash_profile local system environment configuration variables (current user)

 

10./etc/issue records show that before the user login system version and other information

 Security optimization, empty the / etc / system version information in the issue:
 
>/etc/issue

 

11./etc/motd Login reminder

[root@zoe ~]# echo "Welcome to CenOS.">/etc/motd
[root@zoe ~]# cat /etc/motd
Welcome to CenOS.

After logout logout and then log in to view.

 

Information 12./etc/redhat-release statement RedHat version number and name of

[root@zoe ~]# cat /etc/redhat-release
CentOS release 6.7 (Final)

 

13./usr/src source code, for example: the kernel source code and header files.

Third level of the local data, specific to this station host. Generally speaking there are further subdirectories, for example: bin /, lib /, share / which is available to the general user's / usr directory, where to install general application software;.
 

14./usr/local store user-compiled and installed software storage directory

Usually through source packages installed software, if not specified installation directory, usually installed in this directory.

Equivalent to C: \ Program files 

 

15./var/log/messages

dmesg command to see if the fault information system
 

Source code, for example: the kernel source code and header files.

Log files of various programs, especially login (/ var / log / wtmp log into the system all the logon and logoff) and syslog (/ var / log / messages in all core storage systems and program information. / Var / log Lane files often grow indefinitely, should be regularly cleared. 

 

16./var/log/secure security log

17./proc/cpuinfo information processor, such as: the type, manufacturer, model, and performance 

18./proc/meminfo view memory information

19./proc/loadavg load

Remember the top and uptime, right? Yes! The average value of the top three is recorded here!

 

20./proc/mounts

The system has been mounted data call is out of this with the mount command data it

 

Guess you like

Origin www.cnblogs.com/zoe233/p/11919052.html