1.网卡配置文件
[root@testcentos7 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33 | |
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="ens33" | |
UUID="4cf09cae-5418-44e9-8450-422230bd68fc" | |
DEVICE="ens33" | |
ONBOOT="yes" | |
IPADDR="192.168.52.130" | |
PREFIX="24" | |
GATEWAY="192.168.52.2" | |
DNS1="119.29.29.29" | |
解释每个字段的含义: | |
TYPE="Ethernet":指定网络接口类型为以太网。 | |
PROXY_METHOD="none":不使用代理方法。 | |
BROWSER_ONLY="no":不仅限于浏览器。 | |
BOOTPROTO="none":手动配置 IP 地址,不使用 DHCP。 | |
DEFROUTE="yes":将此接口设置为默认路由。 | |
IPV4_FAILURE_FATAL="no":IPv4 连接失败不会导致系统失败。 | |
IPV6INIT="yes":启用 IPv6。 | |
IPV6_AUTOCONF="yes":启用 IPv6 自动配置。 | |
IPV6_DEFROUTE="yes":将此接口设置为 IPv6 默认路由。 | |
IPV6_FAILURE_FATAL="no":IPv6 连接失败不会导致系统失败。 | |
IPV6_ADDR_GEN_MODE="stable-privacy":使用稳定的隐私地址生成模式。 | |
NAME="ens33":接口名称为 ens33。 | |
UUID="4cf09cae-5418-44e9-8450-422230bd68fc":接口的唯一标识符。 | |
DEVICE="ens33":接口设备名称为 ens33。 | |
ONBOOT="yes":在系统引导时自动启用该接口。 | |
IPADDR="192.168.52.130":指定 IPv4 地址为 192.168.52.130。 | |
PREFIX="24":IPv4 子网掩码前缀为 24,即 255.255.255.0。 | |
GATEWAY="192.168.52.2":指定默认网关为 192.168.52.2。 | |
DNS1="119.29.29.29":指定首选 DNS 服务器为 119.29.29.29。 |
2./etc/hosts
系统文件,用于配置主机名与 IP 地址的映射关系。当系统需要解析主机名时,会首先查找 /etc/hosts 文件,如果在该文件中找到了相应的映射关系,则直接使用对应的 IP 地址进行通信,而不需要进行 DNS 查询。
[root@testcentos7 ~]# cat /etc/hosts | |
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 | |
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 | |
127.0.0.1 localhost:将 localhost 主机名映射到回环地址 127.0.0.1,即本地主机。 | |
::1 localhost:将 IPv6 的 localhost 主机名映射到回环地址 ::1,即本地主机。 |
3./etc/hostname
主机名称配置文件
3.1.修改主机名称的三种方法
1.重启后生效
[root@testcentos7 ~]# vim /etc/hostname | |
hehe |
2.临时修改
临时修改主机名称 重启系统失效 退出重新连接即可生效 | |
[root@hehe ~]# hostname web | |
[root@hehe ~]# exit |
3.临时加永久修改主机名称
临时+永久 同时修改了配置文件 重启会读取主机名的配置文件 重点 | |
[root@web ~]# hostnamectl set-hostname nihaoshuai | |
[root@web ~]# cat /etc/hostname | |
nihaoshuai |
4./etc/resolv.conf
用于 DNS 解析的配置信息。DNS 解析是将主机名转换为 IP 地址的过程,在 Linux 中,通常使用 resolver 库提供的函数来进行 DNS 解析。该文件由网络管理程序根据网络配置自动生成,但也可以手动编辑此文件以更改 DNS 解析配置。
[root@testcentos7 ~]# cat /etc/resolv.conf | |
# Generated by NetworkManager | |
nameserver 119.29.29.29 | |
search localdomain |
注意事项 1.如果网卡配置了DNS,resolv.conf会被覆盖 2.网卡配置DNS必须重启才能生效 3.如果网卡没有配置DNS不影响resolv.conf 4.resolv.conf配置DNS直接生效不需要重启 建议在resolv.conf配置不在网卡配置
[root@testcentos7 ~]# cat /etc/resolv.conf Generated by NetworkManager nameserver 223.5.5.5 nameserver 114.114.114.114 nameserver 8.8.8.8
5.安装查询IP
[root@testcentos7 ~]# yum -y install bind-utils | |
[root@testcentos7 ~]# nslookup www.baidu.com | |
Server:119.29.29.29 | |
Address:119.29.29.29#53 | |
Non-authoritative answer: | |
www.baidu.comcanonical name = www.a.shifen.com. | |
Name:www.a.shifen.com | |
Address: 220.181.38.150 | |
Name:www.a.shifen.com | |
Address: 220.181.38.149 | |
Name:www.a.shifen.com | |
Address: 240e:83:205:5a:0b05f:346b | |
Name:www.a.shifen.com | |
Address: 240e:83:205:58:0b09f:36bf | |
6./etc/fstab
系统文件,用于配置在系统启动时自动挂载的文件系统。它定义了文件系统的挂载点、设备、文件系统类型、挂载选项等信息。
[root@testcentos7 ~]# cat /etc/fstab | |
# | |
# /etc/fstab | |
# Created by anaconda on Wed Jan 10 1704 2024 | |
# | |
# 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 | |
UUID=dbee441f-bdcd-41db-824c-3f461eb48952 /boot xfs defaults 0 0 | |
/dev/mapper/centos-swap swap swap defaults 0 0 | |
/dev/mapper/centos-root:指定要挂载的设备或文件系统。 | |
/:指定文件系统的挂载点,即根目录。 | |
xfs:指定文件系统的类型。 | |
defaults:指定挂载选项,表示使用 |
7./etc/rc.local
在早期版本的 Linux 中,/etc/rc.local 是一个可执行脚本文件,用于在系统引导过程中作为最后一个启动脚本运行。它允许用户在系统启动时自定义一些额外的命令或脚本。 然而,在现代的 Linux 发行版中,使用 systemd 作为初始化系统,因此 /etc/rc.local 文件可能已不再被使用。相反,可以使用 systemd 的单元文件来管理启动和运行服务。
[root@testcentos7 ~]# cat /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 |
8./etc/profile
系统级别的 Bash shell 配置文件,它包含了所有用户的全局 shell 配置。当用户登录时,该文件会被加载并执行。 在 /etc/profile 文件中可以定义全局的环境变量、设置 PATH 环境变量、配置系统的默认语言等。
[root@testcentos7 ~]# cat /etc/profile | |
# /etc/profile | |
# System wide environment and startup programs, for login setup | |
# Functions and aliases go in /etc/bashrc | |
# It's NOT a good idea to change this file unless you know what you | |
# are doing. It's much better to create a custom.sh shell script in | |
# /etc/profile.d/ to make custom changes to your environment, as this | |
# will prevent the need for merging in future updates. | |
pathmunge () { | |
case ":${PATH}:" in | |
*:"$1":*) | |
;; | |
*) | |
if [ "$2" = "after" ] ; then | |
PATH=$PATH:$1 | |
else | |
PATH=$1:$PATH | |
fi | |
esac | |
} | |
if [ -x /usr/bin/id ]; then | |
if [ -z "$EUID" ]; then | |
# ksh workaround | |
EUID=`/usr/bin/id -u` | |
UID=`/usr/bin/id -ru` | |
fi | |
USER="`/usr/bin/id -un`" | |
LOGNAME=$USER | |
MAIL="/var/spool/mail/$USER" | |
fi | |
# Path manipulation | |
if [ "$EUID" = "0" ]; then | |
pathmunge /usr/sbin | |
pathmunge /usr/local/sbin | |
else | |
pathmunge /usr/local/sbin after | |
pathmunge /usr/sbin after | |
fi | |
HOSTNAME=`/usr/bin/hostname 2>/dev/null` | |
HISTSIZE=1000 | |
if [ "$HISTCONTROL" = "ignorespace" ] ; then | |
export HISTCONTROL=ignoreboth | |
else | |
export HISTCONTROL=ignoredups | |
fi | |
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL | |
# By default, we want umask to get set. This sets it for login shell | |
# Current threshold for system reserved uid/gids is 200 | |
# You could check uidgid reservation validity in | |
# /usr/share/doc/setup-*/uidgid file | |
if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then | |
umask 002 | |
else | |
umask 022 | |
fi | |
for i in /etc/profile.d/*.sh /etc/profile.d/sh.local ; do | |
if [ -r "$i" ]; then | |
if [ "${-#*i}" != "$-" ]; then | |
. "$i" | |
else | |
. "$i" >/dev/null | |
fi | |
fi | |
done | |
unset i | |
unset -f pathmunge |
9./etc/motd
远程连接提示配置文件
10./var/log/messages
系统日志文件,记录了系统的各种事件、错误和警告信息。它是许多 Linux 发行版中常见的日志文件之一,用于存储系统级别的日志数据。在 /var/log/messages 文件中,您可以找到诸如系统启动消息、网络连接信息、硬件故障报告、登录和注销事件等系统事件的记录。这些日志可以帮助系统管理员和用户跟踪问题、分析故障和监视系统状况。
[root@testcentos7 ~]# cat /var/log/messages | |
Jan 10 1745 localhost journal: Runtime journal is using 6.0M (max allowed 48.6M, trying to leave 72.9M free of 480.0M available → current limit 48.6M). | |
Jan 10 1745 localhost kernel: Initializing cgroup subsys cpuset | |
Jan 10 1745 localhost kernel: Initializing cgroup subsys cpu | |
Jan 10 1745 localhost kernel: Initializing cgroup subsys cpuacct | |
Jan 10 1745 localhost kernel: Linux version 3.10.0-1160.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Mon Oct 19 1659 UTC 2020 | |
Jan 10 1745 localhost kernel: Command line: BOOT_IMAGE=/vmlinuz-3.10.0-1160.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet LANG=zh_CN.UTF-8 | |
Jan 10 1745 localhost kernel: [Firmware Bug]: TSC doesn't count with P0 frequency! | |
Jan 10 1745 localhost kernel: e820: BIOS-provided physical RAM map: | |
Jan 10 1745 localhost kernel: BIOS-e820: [mem 0x0000000000000000-0x000000000009ebff] usable | |
Jan 10 1745 localhost kernel: BIOS-e820: [mem 0x000000000009ec00-0x000000000009ffff] reserved | |
Jan 10 1745 localhost kernel: BIOS-e820: [mem 0x00000000000dc000-0x00000000000fffff] reserved | |
Jan 10 1745 localhost kernel: BIOS-e820: [mem 0x0000000000100000-0x000000003fedffff] usable | |
Jan 10 1745 localhost kernel: BIOS-e820: [mem 0x000000003fee0000-0x000000003fefefff] ACPI data | |
Jan 10 1745 localhost kernel: BIOS-e820: [mem 0x000000003feff000-0x000000003fefffff] ACPI NVS | |
Jan 10 1745 localhost kernel: BIOS-e820: [mem 0x000000003ff00000-0x000000003fffffff] usable | |
Jan 10 1745 localhost kernel: BIOS-e820: [mem 0x00000000f0000000-0x00000000f7ffffff] reserved | |
Jan 10 1745 localhost kernel: BIOS-e820: [mem 0x00000000fec00000-0x00000000fec0ffff] reserved | |
Jan 10 1745 localhost kernel: BIOS-e820: [mem 0x00000000fee00000-0x00000000fee00fff] reserved | |
Jan 10 1745 localhost kernel: BIOS-e820: [mem 0x00000000fffe0000-0x00000000ffffffff] reserved | |
Jan 10 1745 localhost kernel: NX (Execute Disable) protection: active | |
Jan 10 1745 localhost kernel: SMBIOS 2.7 present. | |
Jan 10 1745 localhost kernel: DMI: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 11/12/2020 | |
Jan 10 1745 localhost kernel: Hypervisor detected: VMware | |
Jan 10 1745 localhost kernel: vmware: TSC freq read from hypervisor : 3193.910 MHz |
11./var/log/secure
系统日志文件,记录了与系统安全相关的事件、错误和警告信息。它是许多 Linux 发行版中常见的日志文件之一,用于存储与安全相关的日志数据。在 /var/log/secure 文件中,您可以找到诸如登录和注销事件、使用 sudo 的记录、认证失败尝试以及其他与系统安全相关的事件的记录。这些日志可以帮助系统管理员和用户跟踪安全问题、分析入侵尝试和监视系统安全状况
[root@testcentos7 ~]# cat /var/log/secure | |
Jan 10 17:26:51 localhost polkitd[956]: Loading rules from directory /etc/polkit-1/rules.d | |
Jan 10 17:26:51 localhost polkitd[956]: Loading rules from directory /usr/share/polkit-1/rules.d | |
Jan 10 17:26:51 localhost polkitd[956]: Finished loading, compiling and executing 2 rules | |
Jan 10 17:26:51 localhost polkitd[956]: Acquired the name org.freedesktop.PolicyKit1 on the system bus | |
Jan 10 17:26:55 localhost sshd[1521]: Server listening on 0.0.0.0 port 22. | |
Jan 10 17:26:55 localhost sshd[1521]: Server listening on :: port 22. | |
Jan 10 17:28:51 localhost login: pam_unix(login session opened for user root by LOGIN(uid=0) | |
Jan 10 17:28:51 localhost login: ROOT LOGIN ON tty1 | |
Jan 10 18:03:54 localhost polkitd[956]: Registered Authentication Agent for unix-process:1868:222974 (system bus name :1.25 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) | |
Jan 10 18:03:55 localhost polkitd[956]: Unregistered Authentication Agent for unix-process:1868:222974 (system b |
审核编辑:黄飞
评论
查看更多