1.網(wǎng)卡配置文件
? | [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" |
? | ? |
? | ? |
? | 解釋每個(gè)字段的含義: |
? | ? |
? | TYPE="Ethernet":指定網(wǎng)絡(luò)接口類型為以太網(wǎng)。 |
? | PROXY_METHOD="none":不使用代理方法。 |
? | BROWSER_ONLY="no":不僅限于瀏覽器。 |
? | BOOTPROTO="none":手動(dòng)配置 IP 地址,不使用 DHCP。 |
? | DEFROUTE="yes":將此接口設(shè)置為默認(rèn)路由。 |
? | IPV4_FAILURE_FATAL="no":IPv4 連接失敗不會(huì)導(dǎo)致系統(tǒng)失敗。 |
? | IPV6INIT="yes":?jiǎn)⒂?IPv6。 |
? | IPV6_AUTOCONF="yes":?jiǎn)⒂?IPv6 自動(dòng)配置。 |
? | IPV6_DEFROUTE="yes":將此接口設(shè)置為 IPv6 默認(rèn)路由。 |
? | IPV6_FAILURE_FATAL="no":IPv6 連接失敗不會(huì)導(dǎo)致系統(tǒng)失敗。 |
? | IPV6_ADDR_GEN_MODE="stable-privacy":使用穩(wěn)定的隱私地址生成模式。 |
? | NAME="ens33":接口名稱為 ens33。 |
? | UUID="4cf09cae-5418-44e9-8450-422230bd68fc":接口的唯一標(biāo)識(shí)符。 |
? | DEVICE="ens33":接口設(shè)備名稱為 ens33。 |
? | ONBOOT="yes":在系統(tǒng)引導(dǎo)時(shí)自動(dòng)啟用該接口。 |
? | IPADDR="192.168.52.130":指定 IPv4 地址為 192.168.52.130。 |
? | PREFIX="24":IPv4 子網(wǎng)掩碼前綴為 24,即 255.255.255.0。 |
? | GATEWAY="192.168.52.2":指定默認(rèn)網(wǎng)關(guān)為 192.168.52.2。 |
? | DNS1="119.29.29.29":指定首選 DNS 服務(wù)器為 119.29.29.29。 |
2./etc/hosts
系統(tǒng)文件,用于配置主機(jī)名與 IP 地址的映射關(guān)系。當(dāng)系統(tǒng)需要解析主機(jī)名時(shí),會(huì)首先查找 /etc/hosts 文件,如果在該文件中找到了相應(yīng)的映射關(guān)系,則直接使用對(duì)應(yīng)的 IP 地址進(jìn)行通信,而不需要進(jìn)行 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 主機(jī)名映射到回環(huán)地址 127.0.0.1,即本地主機(jī)。 |
? | ::1 localhost:將 IPv6 的 localhost 主機(jī)名映射到回環(huán)地址 ::1,即本地主機(jī)。 |
3./etc/hostname
主機(jī)名稱配置文件
3.1.修改主機(jī)名稱的三種方法
1.重啟后生效
? | [root@testcentos7 ~]# vim /etc/hostname |
? | hehe |
2.臨時(shí)修改
? | 臨時(shí)修改主機(jī)名稱 重啟系統(tǒng)失效 退出重新連接即可生效 |
? | [root@hehe ~]# hostname web |
? | [root@hehe ~]# exit |
3.臨時(shí)加永久修改主機(jī)名稱
? | 臨時(shí)+永久 同時(shí)修改了配置文件 重啟會(huì)讀取主機(jī)名的配置文件 重點(diǎn) |
? | [root@web ~]# hostnamectl set-hostname nihaoshuai |
? | [root@web ~]# cat /etc/hostname |
? | nihaoshuai |
4./etc/resolv.conf
用于 DNS 解析的配置信息。DNS 解析是將主機(jī)名轉(zhuǎn)換為 IP 地址的過程,在 Linux 中,通常使用 resolver 庫提供的函數(shù)來進(jìn)行 DNS 解析。該文件由網(wǎng)絡(luò)管理程序根據(jù)網(wǎng)絡(luò)配置自動(dòng)生成,但也可以手動(dòng)編輯此文件以更改 DNS 解析配置。
? | [root@testcentos7 ~]# cat /etc/resolv.conf |
? | # Generated by NetworkManager |
? | nameserver 119.29.29.29 |
? | search localdomain |
注意事項(xiàng) 1.如果網(wǎng)卡配置了DNS,resolv.conf會(huì)被覆蓋 2.網(wǎng)卡配置DNS必須重啟才能生效 3.如果網(wǎng)卡沒有配置DNS不影響resolv.conf 4.resolv.conf配置DNS直接生效不需要重啟 建議在resolv.conf配置不在網(wǎng)卡配置
[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
系統(tǒng)文件,用于配置在系統(tǒng)啟動(dòng)時(shí)自動(dòng)掛載的文件系統(tǒng)。它定義了文件系統(tǒng)的掛載點(diǎn)、設(shè)備、文件系統(tǒng)類型、掛載選項(xiàng)等信息。
? | [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:指定要掛載的設(shè)備或文件系統(tǒng)。 |
? | /:指定文件系統(tǒng)的掛載點(diǎn),即根目錄。 |
? | xfs:指定文件系統(tǒng)的類型。 |
? | defaults:指定掛載選項(xiàng),表示使用 |
7./etc/rc.local
在早期版本的 Linux 中,/etc/rc.local 是一個(gè)可執(zhí)行腳本文件,用于在系統(tǒng)引導(dǎo)過程中作為最后一個(gè)啟動(dòng)腳本運(yùn)行。它允許用戶在系統(tǒng)啟動(dòng)時(shí)自定義一些額外的命令或腳本。 然而,在現(xiàn)代的 Linux 發(fā)行版中,使用 systemd 作為初始化系統(tǒng),因此 /etc/rc.local 文件可能已不再被使用。相反,可以使用 systemd 的單元文件來管理啟動(dòng)和運(yùn)行服務(wù)。
? | [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
系統(tǒng)級(jí)別的 Bash shell 配置文件,它包含了所有用戶的全局 shell 配置。當(dāng)用戶登錄時(shí),該文件會(huì)被加載并執(zhí)行。 在 /etc/profile 文件中可以定義全局的環(huán)境變量、設(shè)置 PATH 環(huán)境變量、配置系統(tǒng)的默認(rèn)語言等。
? | [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
遠(yuǎn)程連接提示配置文件
10./var/log/messages
系統(tǒng)日志文件,記錄了系統(tǒng)的各種事件、錯(cuò)誤和警告信息。它是許多 Linux 發(fā)行版中常見的日志文件之一,用于存儲(chǔ)系統(tǒng)級(jí)別的日志數(shù)據(jù)。在 /var/log/messages 文件中,您可以找到諸如系統(tǒng)啟動(dòng)消息、網(wǎng)絡(luò)連接信息、硬件故障報(bào)告、登錄和注銷事件等系統(tǒng)事件的記錄。這些日志可以幫助系統(tǒng)管理員和用戶跟蹤問題、分析故障和監(jiān)視系統(tǒng)狀況。
? | [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
系統(tǒng)日志文件,記錄了與系統(tǒng)安全相關(guān)的事件、錯(cuò)誤和警告信息。它是許多 Linux 發(fā)行版中常見的日志文件之一,用于存儲(chǔ)與安全相關(guān)的日志數(shù)據(jù)。在 /var/log/secure 文件中,您可以找到諸如登錄和注銷事件、使用 sudo 的記錄、認(rèn)證失敗嘗試以及其他與系統(tǒng)安全相關(guān)的事件的記錄。這些日志可以幫助系統(tǒng)管理員和用戶跟蹤安全問題、分析入侵嘗試和監(jiān)視系統(tǒng)安全狀況
? | [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 |
審核編輯:黃飛
?
評(píng)論
查看更多