linux /etc目錄下的重要配置文件day06.day07.

linux /etc目錄的下的配置文件

1.網(wǎng)卡配置文件

/etc/sysconfig/network-scripts/ifcfg-eth0或ens33

[root@linux59-moban ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 
TYPE="Ethernet"                         ###    以太網(wǎng)
BOOTPROTO="none"                 
DEFROUTE="yes"
NAME="eth0"
DEVICE="eth0"
ONBOOT="yes"
IPADDR="10.0.0.203"
PREFIX="24"
GATEWAY="10.0.0.254"
DNS1="10.0.0.254"
DNS2="223.5.5.5"
網(wǎng)卡配置文件.png

systemctl restart network
start 開啟
stop 關(guān)閉
status 查看狀態(tài)
restart重啟
系統(tǒng)控制命令 重啟 所有網(wǎng)卡

2.解析 DNS

/etc/resolv.conf

[root@linux59-moban ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 10.0.0.254
nameserver 223.5.5.5

網(wǎng)卡里面配置DNS VS /etc/resolv.conf配置DNS

網(wǎng)卡配置DNS使用的是 (網(wǎng)卡里面永久生效 )
DNS1="10.0.0.254"
DNS2="223.5.5.5"

/etc/resolv.conf里面是 (立即生效,臨時生效,重啟網(wǎng)卡后會被網(wǎng)卡里面的DNS覆蓋)
nameserver 223.5.5.5
nameserver 223.6.6.6

3.主機(jī)名的配置文件

/etc/hostname

[root@linux59-moban ~]# cat /etc/hostname 
linux59-moban

Linux如何修改主機(jī)名:

通用:cenos6 7 都可以使用

1# hostname命令修改主機(jī)名(臨時 重啟服務(wù)器之后失效)
[root@oldboyedu59 ~]# hostname
oldboyedu59
[root@oldboyedu59 ~]# hostname oldboyedu59-lnb

2# 修改文件內(nèi)容(寫合同 永久 重啟服務(wù)器之后生效)
vim /etc/hostname

3# 檢查
[root@oldboyedu59 ~]# hostname
oldboyedu59-lnb
[root@oldboyedu59 ~]# cat /etc/hostname
oldboyedu59-lnb

CentOS 7特有:

一條命令,同時修改臨時+永久
[root@oldboyedu59-lnb ~]# hostnamectl set-hostname oldboyedu59
同時修改臨時+永久
[root@oldboyedu59-lnb ~]# hostname
oldboyedu59
[root@oldboyedu59-lnb ~]# cat /etc/hostname
oldboyedu59

4.域名與ip地址解析關(guān)系

/etc/hosts

[root@linux59-moban ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

網(wǎng)站更新過程(程序代碼更新)
1.在開發(fā)人員自己電腦進(jìn)行測試
2.公司內(nèi)部機(jī)房進(jìn)行測試
3.在IDC機(jī)房(數(shù)據(jù)中心) 測試
4.程序代碼放在用戶使用的環(huán)境(生產(chǎn)環(huán)境/線上環(huán)境)

5.配置開機(jī)設(shè)備自動掛載的文件 || 把蘋果掛載到樹枝 掛載表

/etc/fstab

#
# /etc/fstab
# Created by anaconda on Tue Mar 26 11:38:44 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=35ee4728-c5d4-43be-8a05-989df0217956 /                       xfs     defaults        0 0
UUID=0765cf05-6253-4adb-8903-d1bca9a3551f /boot                   xfs     defaults        0 0
UUID=411ec0c6-4cf4-4a73-b12e-bd350affc74a swap                    swap    defaults        0 0

6.開機(jī)自啟動程序命令的地方 文件

/etc/rc.local

[root@linux59-moban ~]# 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
[root@linux59-moban ~]# ll -d /etc/rc.local
lrwxrwxrwx. 1 root root 13 Mar 26 11:41 /etc/rc.local -> rc.d/rc.local

centos7版本要賦予chmod +x /etc/rc.d/rc.local文件x權(quán)限就可以使用了.

7.系統(tǒng)運(yùn)行級別與加載相關(guān)的級別對應(yīng)啟動文件。配置文件(6版本)

/etc/inittab

0    ###  關(guān)機(jī)
1    ###  單用戶模式
2    ###  多用戶模式 但沒有 NFS    沒網(wǎng)
3    ###  多用戶模式 命令模式(默認(rèn) 有網(wǎng))
4    ###  沒有使用
5    ###  圖像界面模式 桌面模式
6    ###  重啟

centos6版本啟動流程

image.png

centos7版本啟動流程

image.png

centos6 7 版本對比

image.png

8.別名,環(huán)境變量的配置文件

/etc/profile

查看系統(tǒng)環(huán)境變量 env

[root@linux59-moban ~]# env
XDG_SESSION_ID=38
HOSTNAME=linux59-moban
TERM=linux
SHELL=/bin/bash
HISTSIZE=1000
SSH_CLIENT=10.0.0.1 14430 22
SSH_TTY=/dev/pts/1
USER=root

查看系統(tǒng)別名 alias


[root@linux59-moban ~]# alias 
alias cp='cp -i'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

9.別名的配置文件

/etc/bashrc

10.用戶登錄后顯示的內(nèi)容

/etc/motd

11.用戶登錄前顯示的內(nèi)容

/etc/issue

12.CentOS 6下面系統(tǒng)管理命令(腳本)存放的位置 || CentOS 7下面只有network服務(wù)

/etc/init.d

7版本只有network服務(wù)

[root@linux59-moban ~]# ll /etc/init.d/
total 40
-rw-r--r--. 1 root root 18281 Aug 24  2018 functions
-rwxr-xr-x. 1 root root  4569 Aug 24  2018 netconsole
-rwxr-xr-x. 1 root root  7923 Aug 24  2018 network
-rw-r--r--. 1 root root  1160 Oct 31 07:31 README


?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容