The simplest directory structure to understand

Posted by mysty on Sun, 08 Sep 2019 04:12:19 +0200

1. Common directories and explanations in Linux
Where to save the 1 bin command file
2 SBIN Commands that only root users can use
3 boot (know it) Directory where information is saved when a Linux program starts
4 Directory where dev device files exist
Directory where 5 etc file configuration information and service configuration information exist
6 Home User Directory (Ordinary User Home Directory)
7 Root user directory (super administrator home directory)
8 selinux: Save SELinux program profile information and system security related programs
9 lib library file
10 MNT Temporary Mount Directory
11 opt stores information generated by third-party software
12/usr/local stores information about software installation
13 The data in the proc directory is stored in memory, process information and kernel file information
14 TMP temporary storage of files, equivalent to a recycle bin
15 var Saves files that frequently change data (log files)
1.1.linux Common Directory Structure Diagram

2./etc directory explanation
2.1 Network Card Profile Details

vim /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet                       Network Connection Type
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none                 Whether the network connection mode is dhcp(none:No connection set;static:Static Connection)
DEFROUTE=yes                     Whether the default route is on
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eth0                
                                //Device Name
DEVICE=eth0               
UUID=0ea55b05-db81-4dd0-a145-fa476c8b6045          Server Hardware Identifier
ONBOOT=yes                                       Is Network Card Activated
IPADDR=10.0.0.200                                Network IP address
PREFIX=24                                         Subnet Mask,Set how many hosts a LAN can have
GATEWAY=10.0.0.254                               Can I surf the Internet?
DNS1=223.5.5.5                                      Resolve domain names
IPV6_PRIVACY=no

2.1.1 Network Card Configuration Notes
Network card configuration must be restarted once it is modified
centos 7:systemctl restart network
centos:6:/etc/init.d/network restart
Restart a single network card: ifdown eth0 && ifup eth0
ifdown eth0;ifup eth0
2.1.2 Why IP is required, explained in schematic diagram

2.1.3 Why DNS is required, explained in schematic diagrams

2.1.4 Why a gateway is needed, explained in the schematic diagram

2.2 DNS Domain Name Resolution Configuration

[root@oldboy666 ~]# vi /etc/resolv.conf
# Generated by NetworkManager    
nameserver 223.5.5.5                       Service name DNS address

2.2.1 DNS domain name resolution and DNS sequence of network card configuration
Before restarting the network card: DNS domain name resolution configuration, the configuration file inside DNS domain name resolution is loaded first
After restarting the network card: DNS domain name resolution configuration, the files inside the network card configuration are loaded first

Configuration of 2.3 Host Name
Permanent configuration paths for 2.3.1 9.3.3.1 centos6 and centos7

centos6.9 Permanent Configuration Path for
[root@oldboy666 ~]# cat /etc/sysconfig/network

# Created by anaconda
centos7.6 Permanent Configuration Path for
[root@oldboy666 ~]# cat /etc/hostname 
oldboy666
[root@oldboy666 ~]# 
[root@oldboy666 ~]# 
[root@oldboy666 ~]#

Advantages of 2.3.2 centos7 hostname configuration

[root@oldboy666 ~]# hostnamectl set-hostname oldboy6666
[root@oldboy666 ~]#
[root@oldboy6666 ~]#

2.4 Configuration of permanent mount files

[root@oldboy6666 ~]# vim /etc/fstab 
# /etc/fstab
# Created by anaconda on Fri Aug 30 12:11:39 2019
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=27114df9-3f54-4b94-acb7-0890b452e99f /                       xfs     defaults        0 0
UUID=4260ed75-aad2-4389-b24a-2be6362c2597 /boot                   xfs     defaults        0 0
UUID=8e7004ef-83c2-4b8d-b9db-b85768271eb2 swap                    swap    defaults        0 0
#UUID=2018-11-25-23-54-16-00   /mnt          iso9660      defaults         0 0

2.4.1 Profile Details
Column 1: Hardware identifier information, which indicates a mounted hardware device, can also be written as/dev/??
Column 2: Directories where disks need to be mounted
Column 3: Type of partition file
Column 4: Mounted parameters
Column 5: Backup settings (1 for backup, 0 for no backup)
Column 6: Disk check, 0 is never check; /Directory partition 1, other partition directories 2
2.5 Local Parsing Profile
2.5.1 How to Parse

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

format
IP Address Host Name
2.6 Boot-up self-start profile details

[root@oldboy6666 ~]# vim /etc/rc.local 
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local
mount /dev/cdrom /mnt'

The reason why 2.6.1 centos7 file joining boot-up self-start item will not take effect

Boot-up cannot take effect because it does not have permission to execute

[root@oldboy6666 ~]# ls -l /etc/rc.local 
lrwxrwxrwx. 1 root root 13 Aug 30 12:12 /etc/rc.local -> rc.d/rc.local   This is a linked file, you need to see the real file
[root@oldboy6666 ~]#
[root@oldboy6666 ~]# ls -l /etc/rc.d/rc.local 
-r--------. 1 root root 495 Sep  6 19:13 /etc/rc.d/rc.local          This real file has read access only
[root@oldboy6666 ~]#
[root@oldboy6666 ~]# Chmod 777/etc/rc.d/rc.local Modify File Permissions
[root@oldboy6666 ~]# ls -l /etc/rc.d/rc.local 
-rwxrwxrwx. 1 root root 495 Sep  6 19:13 /etc/rc.d/rc.local             Execution rights now available,Can turn on normally
[root@oldboy6666 ~]#

2.7 System Environment Variable Profile
2.7.1 What are environment variables
Is the variable set by the system model
System variable names are capitalized, for example: PATH
2.7.2 How to modify environment variables
(1). Temporary modifications

export PATH=$PATH
[root@oldboy6666 ~]# echo $PATH to see which paths the current system environment variables can match
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@oldboy6666 ~]# Mv/bin/cp/tmp moves/bin/cp commands inside TMP
[root@oldboy6666 ~]# ls
1.txt  anaconda-ks.cfg  passwd
[root@oldboy6666 ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@oldboy6666 ~]# touch aa.txt Create a file
[root@oldboy6666 ~]# Cp-rf aa.txt/opt/Start copying files
-bash: cp: command not found                             find cp Command not found
[root@oldboy6666 ~]# export PATH=$PATH:/tmp temporarily adds the TMP directory to the environment variable
[root@oldboy6666 ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/tmp       Added Successfully 
[root@oldboy6666 ~]# Cp-rf aa.txt/opt/Replication discovery succeeded
[root@oldboy6666 ~]#

(2). Permanent modification
[root@oldboy 6666 ~]# echo PATH=$PATH:/tmp >>/etc/profile >> This is an append, don't write as > this will empty the file
2.7.3 Command Execution Principle
(1). Executing commands
(2). Execute environment variable PATH=(/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
(3). Look at the variables being executed, are they inside these environment variables?
(4) If it is in one of the paths, you can use the command; otherwise, the command will be reported as missing (the temporary modification environment variable mentioned above is because the cp command is moved below the TMP directory, causing the cp to be missing, and then the / tmp path can be added to the PATH environment variable)

Topics: Linux network DNS vim Anaconda