吴忠躺衫网络科技有限公司

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

Linux系統(tǒng)中一些重要的配置文件介紹

馬哥Linux運維 ? 來源:博客園 ? 2024-02-19 17:39 ? 次閱讀

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"
解釋每個字段的含義:
TYPE="Ethernet":指定網(wǎng)絡(luò)接口類型為以太網(wǎng)
PROXY_METHOD="none":不使用代理方法。
BROWSER_ONLY="no":不僅限于瀏覽器。
BOOTPROTO="none":手動配置 IP 地址,不使用 DHCP。
DEFROUTE="yes":將此接口設(shè)置為默認路由。
IPV4_FAILURE_FATAL="no":IPv4 連接失敗不會導(dǎo)致系統(tǒng)失敗。
IPV6INIT="yes":啟用 IPv6。
IPV6_AUTOCONF="yes":啟用 IPv6 自動配置。
IPV6_DEFROUTE="yes":將此接口設(shè)置為 IPv6 默認路由。
IPV6_FAILURE_FATAL="no":IPv6 連接失敗不會導(dǎo)致系統(tǒng)失敗。
IPV6_ADDR_GEN_MODE="stable-privacy":使用穩(wěn)定的隱私地址生成模式。
NAME="ens33":接口名稱為 ens33。
UUID="4cf09cae-5418-44e9-8450-422230bd68fc":接口的唯一標識符。
DEVICE="ens33":接口設(shè)備名稱為 ens33。
ONBOOT="yes":在系統(tǒng)引導(dǎo)時自動啟用該接口。
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":指定默認網(wǎng)關(guān)為 192.168.52.2。
DNS1="119.29.29.29":指定首選 DNS 服務(wù)器為 119.29.29.29。

2./etc/hosts

系統(tǒng)文件,用于配置主機名與 IP 地址的映射關(guān)系。當(dāng)系統(tǒng)需要解析主機名時,會首先查找 /etc/hosts 文件,如果在該文件中找到了相應(yīng)的映射關(guān)系,則直接使用對應(yīng)的 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 主機名映射到回環(huán)地址 127.0.0.1,即本地主機。
::1 localhost:將 IPv6 的 localhost 主機名映射到回環(huán)地址 ::1,即本地主機。

3./etc/hostname

主機名稱配置文件

3.1.修改主機名稱的三種方法

1.重啟后生效

[root@testcentos7 ~]# vim /etc/hostname
hehe

2.臨時修改

臨時修改主機名稱 重啟系統(tǒng)失效 退出重新連接即可生效
[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 解析是將主機名轉(zhuǎn)換為 IP 地址的過程,在 Linux 中,通常使用 resolver 庫提供的函數(shù)來進行 DNS 解析。該文件由網(wǎng)絡(luò)管理程序根據(jù)網(wǎng)絡(luò)配置自動生成,但也可以手動編輯此文件以更改 DNS 解析配置。

[root@testcentos7 ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 119.29.29.29
search localdomain

注意事項

1.如果網(wǎng)卡配置了DNS,resolv.conf會被覆蓋

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)啟動時自動掛載的文件系統(tǒng)。它定義了文件系統(tǒng)的掛載點、設(shè)備、文件系統(tǒ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)的掛載點,即根目錄。
xfs:指定文件系統(tǒng)的類型。
defaults:指定掛載選項,表示使用

7./etc/rc.local

在早期版本的 Linux 中,/etc/rc.local 是一個可執(zhí)行腳本文件,用于在系統(tǒng)引導(dǎo)過程中作為最后一個啟動腳本運行。它允許用戶在系統(tǒng)啟動時自定義一些額外的命令或腳本。 然而,在現(xiàn)代的 Linux 發(fā)行版中,使用 systemd 作為初始化系統(tǒng),因此 /etc/rc.local 文件可能已不再被使用。相反,可以使用 systemd 的單元文件來管理啟動和運行服務(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)級別的 Bash shell 配置文件,它包含了所有用戶的全局 shell 配置。當(dāng)用戶登錄時,該文件會被加載并執(zhí)行。 在 /etc/profile 文件中可以定義全局的環(huán)境變量、設(shè)置 PATH 環(huán)境變量、配置系統(tǒng)的默認語言等。

[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

系統(tǒng)日志文件,記錄了系統(tǒng)的各種事件、錯誤和警告信息。它是許多 Linux 發(fā)行版中常見的日志文件之一,用于存儲系統(tǒng)級別的日志數(shù)據(jù)。在 /var/log/messages 文件中,您可以找到諸如系統(tǒng)啟動消息、網(wǎng)絡(luò)連接信息、硬件故障報告、登錄和注銷事件等系統(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)的事件、錯誤和警告信息。它是許多 Linux 發(fā)行版中常見的日志文件之一,用于存儲與安全相關(guān)的日志數(shù)據(jù)。在 /var/log/secure 文件中,您可以找到諸如登錄和注銷事件、使用 sudo 的記錄、認證失敗嘗試以及其他與系統(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





審核編輯:劉清

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • 以太網(wǎng)
    +關(guān)注

    關(guān)注

    40

    文章

    5460

    瀏覽量

    172741
  • Linux系統(tǒng)
    +關(guān)注

    關(guān)注

    4

    文章

    595

    瀏覽量

    27510
  • DNS
    DNS
    +關(guān)注

    關(guān)注

    0

    文章

    219

    瀏覽量

    19927

原文標題:Linux系統(tǒng)中一些重要的配置文件

文章出處:【微信號:magedu-Linux,微信公眾號:馬哥Linux運維】歡迎添加關(guān)注!文章轉(zhuǎn)載請注明出處。

收藏 人收藏

    評論

    相關(guān)推薦

    linux下的一些文件的簡單操作

    Linux 應(yīng)用編程中最需要掌握的基礎(chǔ)就是文件 I/O的操作,學(xué)習(xí)過linux或者有過了解的應(yīng)該都會聽過句話:linux
    發(fā)表于 01-11 15:40 ?595次閱讀
    <b class='flag-5'>linux</b>下的<b class='flag-5'>一些</b><b class='flag-5'>文件</b>的簡單操作

    基于libconfig進行配置文件解析

    本文介紹基于libconfig進行配置文件解析
    的頭像 發(fā)表于 06-08 10:18 ?1525次閱讀
    基于libconfig進行<b class='flag-5'>配置文件</b>解析

    ICD配置文件的詳細介紹配置內(nèi)容的詳細概述

    配置文件配置文件是利用SCL語言描述變電站設(shè)備對象模型后生成的文件,用于在不同廠商的配置工具之間交換配置信息。
    的頭像 發(fā)表于 06-02 11:16 ?1.8w次閱讀
    ICD<b class='flag-5'>配置文件</b>的詳細<b class='flag-5'>介紹</b>和<b class='flag-5'>配置</b>內(nèi)容的詳細概述

    Linux教程之網(wǎng)絡(luò)配置文件配置方法及常用網(wǎng)絡(luò)操作命令

    本文檔的主要內(nèi)容詳細介紹的是Linux教程之網(wǎng)絡(luò)配置文件配置方法及常用網(wǎng)絡(luò)操作命令詳細資料免費下載主要目標是1.掌握網(wǎng)絡(luò)配置文件
    發(fā)表于 11-07 11:49 ?9次下載
    <b class='flag-5'>Linux</b>教程之網(wǎng)絡(luò)<b class='flag-5'>配置文件</b>與<b class='flag-5'>配置</b>方法及常用網(wǎng)絡(luò)操作命令

    需要了解的Linux 系統(tǒng)中一些針對文件系統(tǒng)的節(jié)能技巧

    文件系統(tǒng)Linux 系統(tǒng)重要組成部分,文件系統(tǒng)配置和使用對整個
    發(fā)表于 04-27 19:22 ?689次閱讀

    SHARC音頻模塊:配置文件對裸機框架進行配置重要

    詳細介紹如何從配置文件配置裸機框架的重要方面。
    的頭像 發(fā)表于 06-27 06:02 ?2431次閱讀
    SHARC音頻模塊:<b class='flag-5'>配置文件</b>對裸機框架進行<b class='flag-5'>配置</b>的<b class='flag-5'>重要</b>性

    Keil的黑色界面配置文件配置方法

    本文檔的主要內(nèi)容詳細介紹的是Keil的黑色界面配置文件配置方法。
    發(fā)表于 12-03 15:05 ?26次下載

    ARM Linux中一些重要的宏及地址定義

    ARM Linux中一些重要的宏及地址定義
    的頭像 發(fā)表于 06-22 17:02 ?2774次閱讀

    linux修改網(wǎng)卡ip配置文件

    Linux種開源的操作系統(tǒng),因此,它給用戶提供了很高的自由度,可以根據(jù)個人需要進行各種定制和配置。其中,修改網(wǎng)絡(luò)接口配置文件是常見的操作
    的頭像 發(fā)表于 11-17 10:51 ?2380次閱讀

    Linux網(wǎng)絡(luò)基本配置與管理

    Linux種開源操作系統(tǒng),被廣泛用于服務(wù)器和網(wǎng)絡(luò)設(shè)備中。在Linux中,網(wǎng)絡(luò)配置和管理是
    的頭像 發(fā)表于 11-27 16:51 ?1077次閱讀

    springboot的全局配置文件有幾種

    Spring Boot是種快速開發(fā)框架,其通過提供配置文件來實現(xiàn)對應(yīng)用程序的配置。全局配置文件在Spring Boot中起著非常重要的作用
    的頭像 發(fā)表于 12-03 15:28 ?1652次閱讀

    zookeeper的核心配置文件是什么

    Zookeeper是個常用的分布式協(xié)調(diào)服務(wù),它被廣泛應(yīng)用于大型分布式系統(tǒng)中。Zookeeper的核心配置文件是zoo.cfg,它包含了Zookeeper服務(wù)器的各種配置參數(shù),可以通過
    的頭像 發(fā)表于 12-04 10:33 ?887次閱讀

    php的配置文件是什么

    配置文件的名稱默認為php.ini。該文件通常位于PHP安裝目錄下的conf文件夾中。當(dāng)PHP解釋器啟動時,會自動加載php.ini文件,并根據(jù)其中的
    的頭像 發(fā)表于 12-04 15:55 ?1611次閱讀

    oracle配置文件類型關(guān)聯(lián)

    Oracle是種業(yè)界領(lǐng)先的關(guān)系型數(shù)據(jù)庫管理系統(tǒng),它在大型企業(yè)中被廣泛使用。Oracle的配置文件對于數(shù)據(jù)庫的穩(wěn)定運行和性能優(yōu)化至關(guān)重要。在這篇文章中,我們將詳細討論Oracle的
    的頭像 發(fā)表于 12-06 10:17 ?522次閱讀

    linux網(wǎng)卡配置文件

    網(wǎng)卡配置文件 ? ? 網(wǎng)卡目錄[root@localhost opt]# ls /etc/sysconfig/network-scripts/網(wǎng)卡文件名字,和我們ifconfig看到的
    的頭像 發(fā)表于 12-10 10:09 ?290次閱讀
    百家乐官网画面方法| 威尼斯人娱乐代理注测| 百家乐官网技术方式| 豪杰百家乐现金网| 博士娱乐| 网上现金棋牌| 赌博中百家乐官网什么意思| 百家乐真人游戏投注网| 新干县| 百家乐一直下注庄家| 百家乐平注常赢玩法| 联合百家乐官网的玩法技巧和规则 | 大发888下载安装包| 百家乐官网国际娱乐场| 大发888娱乐城注册| 澳门百家乐官网娱乐城送体验金| 最佳场百家乐的玩法技巧和规则| 百家乐官网直杀| 大发888娱乐官方下载| 淘金百家乐官网的玩法技巧和规则 | 棋牌银商| 百家乐投注法则| 德州扑克书| 属蛇和属猪做生意| 蓝盾百家乐| 百家乐那里玩| 百家乐官网注册18元体验金| 洛克百家乐的玩法技巧和规则 | 包头市| 木棉百家乐的玩法技巧和规则| 百家乐官网压分技巧| 百家乐娱乐网真钱游戏| 金博士百家乐官网娱乐城| 百家百家乐官网网站| 缅甸百家乐官网玩假吗| 大发888娱乐吧| 百家乐不倒翁缺点| 百家乐官网里面的奥妙| 新全讯网3| 赌百家乐的方法| 七乐百家乐官网现金网|