当前位置:首页 > 有云笔记 > Linux > 正文内容

linux常用配置文件"/etc"详细解释

小白2年前 (2021-12-16)Linux259230

linux常用配置文件"/etc"详细解释


一、/etc/fstab #开机自动挂载的配置文件  

vim /etc/fstab
# Created by anaconda on Mon Dec 13 09:16:03 2021
#
# 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
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
/dev/vda1              /boot                   xfs     defaults        0 0
/dev/mapper/centos-swap swap                    swap    defaults        0 0
/dev/cdrom  /mydvd                    iso9660    defaults        0 0
~                                                                                           

输入  :quit<Enter>  退出 Vim                                              8,1          底端


二、/etc/exports #编辑NFS共享文件配置文件  

vim /etc/exports

/public *(ro)    #将/public只读共享给所有用户
/opt *(ro)      #将/opt只读共享给所有用户   
~                                                                        

-- 插入 --                                             1,25-24      全部

三、/etc/auto.master #触发挂载的主配置文件

vim /etc/auto.master
#
# Sample auto.master file
# This is a 'master' automounter map and it has the following format:
# mount-point [map-type[,format]:]map [options]
# For details of the format look at auto.master(5).
#
/misc   /etc/auto.misc
/myssrauto      /opt/ssr.txt
#
# NOTE: mounts done from a hosts map will be mounted with the
#       "nosuid" and "nodev" options unless the "suid" and "dev"
#       options are explicitly given.
#
/net    -hosts
#
# Include /etc/auto.master.d/*.autofs
# The included files must conform to the format of this file.
#
+dir:/etc/auto.master.d
#
# Include central master map if it can be found using
# nsswitch sources.
#
# Note that if there are entries for /net or /misc (as
# above) in the included master map any keys that are the
# same will not be seen as the first read key seen takes
# precedence.
#
+auto.master
~                                                                        
"/etc/auto.master" 29L, 819C                           8,1          全部

四、 /etc/yum.repos.d/ #yum配置文件目录

vim /etc/yum.repos.d/centos7.repo
[centos7]
name=centos7
baseurl=file:///mydvd
enabled=1
gpgcheck=0
~                                                                        

"/etc/yum.repos.d/centos7.repo" 5L, 66C                1,1          全部

五、/etc/hosts #本地dns解析文件优先级高

vim /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
~                                                                               

"/etc/hosts" 2L, 158C                                         1,1          全部

六、/etc/httpd/conf/httpd.conf #http主配置文件

vim /etc/httpd/conf/httpd.conf

/etc/httpd/conf.d/*.conf #http调用配置文件

vim /etc/httpd/conf.d/*.conf

七、/etc/named.conf #设置负责解析的域名

vim /etc/named.conf
options {
        directory       "/var/named";
        allow-transfer  { 192.168.4.207; };
};
zone "tedu.cn" IN {
        type master;
        file "tedu.cn.zone";
};
zone "lol.com" IN {
        type master;
        file "lol.com.zone";
};

"/etc/named.conf" 13L, 194C                                   1,1          全部

八、/etc/resolv.conf #是DNS域名解析的配置文件

vim /etc/resolv.conf

nameserver #定义DNS服务器的IP地址
domain #定义本地域名
search #定义域名的搜索列表
sortlist #对返回的域名进行排序
/etc/resolv.conf的一个示例:
domain test.com
search www.test.com test.com
nameserver 202.96.128.86
nameserver 202.96.128.166
最主要是nameserver关键字,如果没指定nameserver就找不到DNS服务器,其它关键字是可选的。

九、/etc/dhcp/dhcp.conf #DHCP服务配置文件

vim /etc/dhcp/dhcpd.conf
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.example
#   see dhcpd.conf(5) man page
subnet 192.168.4.0 netmask 255.255.255.0 {
  range 192.168.4.100  192.168.4.200;
  option domain-name-servers 192.168.4.7;
  option routers 192.168.4.254;
  default-lease-time 600;
  max-lease-time 7200;
}
~                                                                                                  

"/etc/dhcp/dhcpd.conf" 11L, 320C                                                 8,3          全部

十、/etc/chrony.conf#NTP时间服务器配置文件

vim /etc/chrony.conf
1 # Use public servers from the pool.ntp.org project.
  2 # Please consider joining the pool (http://www.pool.ntp.org/join.html).
  3 server 0.centos.pool.ntp.org iburst #与谁同步时间
  4 server 1.centos.pool.ntp.org iburst #iburst表示快速同步
  5 server 2.centos.pool.ntp.org iburst
  6 server 3.centos.pool.ntp.org iburst
  7 
  8 # Record the rate at which the system clock gains/losses time.
  9 driftfile /var/lib/chrony/drift
 10 
 11 # Allow the system clock to be stepped in the first three updates
 12 # if its offset is larger than 1 second.
 13 makestep 1.0 3
 14 
 15 # Enable kernel synchronization of the real-time clock (RTC).
 16 rtcsync
 17 
 18 # Enable hardware timestamping on all interfaces that support it.
 19 #hwtimestamp *
 20 
 21 # Increase the minimum number of selectable sources required to adjust
 22 # the system clock.
 23 #minsources 2
 24 
 25 # Allow NTP client access from local network.
 26 #allow 192.168.0.0/16  #开头的#去掉,修改为允许所有客户端
 27 
 28 # Serve time even if not synchronized to a time source.
 29 #local stratum 10  #设置本机为第10层的时间服务器
 30 
 31 # Specify file containing keys for NTP authentication.
 32 #keyfile /etc/chrony.keys
 33 
 34 # Specify directory for log files.
 35 logdir /var/log/chrony
 36 
 37 # Select which information is logged.
 38 #log measurements statistics tracking

十一、/etc/sysconfig/network-scripts/ifcfg-eth0

#修改配置文件直接修改网卡”eth0”的ip地址信息

vim /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eth0
UUID=3e3caba5-e965-441f-862f-f58b48de9c7f
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.4.2 #ip地址
PREFIX=24 #子网掩码
GATEWAY=192.168.4.200 #默认网关
18L, 329C 16,18 全部
ifdown  eth0          #停用设备
成功断开设备 'eth0'。
ifup  eth0              #启用设备
连接已成功激活

十二、/etc/shells #查看所有解释权

cat /etc/shells
[root@cloudreve ~]# cat /etc/shells
/bin/sh
/bin/bash
/usr/bin/sh
/usr/bin/bash
/bin/tcsh
/bin/csh


十三、/etc/rc.d/rc.local #编辑开机自动启动服务  


cat /etc/rc.d/rc.local

如开机自启动开启Nginx服务在该配置文件后累计添加即可

echo ‘/usr/local/nginx/sbin/nginx’ >> /etc/rc.d/rc.local

[root@zabbixserver ~]# cat /etc/rc.d/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.
#
LANG=en growpart /dev/vda  1
xfs_growfs /dev/vda1
# 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
/usr/local/nginx/sbin/nginx


十四、/etc/sudoers #修改普通用户为管理员

vim /etc/sudoers
.......
99 ## Allow root to run any commands anywhere 
100 root    ALL=(ALL)       ALL
101 putong ALL=(ALL)       ALL
102 
103 ## Allows members of the 'sys' group to run networking, software,




LOADING………..

未完待续



linux常用配置文件"/etc"详细解释  您阅读本篇文章共花了: 

分享到:

    扫描二维码推送至手机访问。

    版权声明:本文由有云转晴发布,如需转载请注明出处。

    本文链接:https://www.yyzq.cf/?id=38

    分享给朋友:

    发表评论

    访客

    ◎欢迎参与讨论,请在这里发表您的看法和观点。