Centos 7 基礎設置:
修改默認語言: 不再是修改 /etc/sysconfig/i18n, 而是要修改 /etc/locale.conf, 以及 /etc/yum/pluginconf.d/langpacks.conf
vi /etc/locale.conf
vi /etc/yum/pluginconf.d/langpacks.conf
修改啟動級別: 不再是修改 /etc/inittab, 而是通過systemctl配置, 如下
# 查看當前啟動級別 systemctl get-default # 設置啟動級別 systemctl set-default TARGET.target # TARGET 與舊版本的對應關系如下 init systemctl target 0 shutdown.target 1 emergency.target 2 rescure.target 3 multi-user.target 4 無 5 graphical.target 6 無
Centos 7 安裝ifconfig
Centos7 minimal install下不帶net-tools
先要連上網絡
修改/etc/sysconfig/network-scripts/ifcfg-ens123123 去掉其中ipv6相關的內容, 改為
TYPE=Ethernet BOOTPROTO=static DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=no NAME=ens160 UUID=65c09798-4a11-4dd8-8140-5b5ae60df409 DEVICE=ens160 ONBOOT=yes IPADDR=192.168.31.154 NETMASK=255.255.255.0 GATEWAY=192.168.31.1 DNS1=192.168.31.1 DNS2=8.8.8.8
其中UUID可以使用 uuidgen [interface] 命令獲得
uuidgen ens160
重啟network
systemctl restart network.service
查找, 安裝對應的包
# search it yum search ifconfig # found then install it yum install net-tools.x86_64
CentOS7中更改主機名
需要修改 /etc/hostname, 修改/etc/sysconfig/network配置文件可能起作用但是不推薦
修改CentOS7主機名的方法有以下幾種
- 在安裝操作系統的時候設定好主機名
- 直接使用文本編輯器修改/etc/hostname配置文件
- 使用hostnamectl命令, hostnamectl set-hostname name, 再通過hostname或者hostnamectl status命令查看更改是否生效
查看靜態, 瞬態或靈活主機名,分別使用--static, --transient 或 --pretty 選項
hostnamectl status [--static|--transient|--pretty]
Centos7 打開指定端口
不再使用iptables, 而是使用 firewall-cmd 管理
# 不要忘記 --permanent [root@osboxes java]# firewall-cmd --zone=public --add-port=8080/tcp --permanent # OR 添加一個地址段 [root@osboxes java]# firewall-cmd --zone=public --add-port=5060-5061/udp --permanent success # 需要reload后才啟用, 熱加載 [root@osboxes java]# firewall-cmd --reload # OR 冷加載 [root@osboxes java]# firewall-cmd --complete-reload success # 能看到新端口已經添加 [root@osboxes java]# firewall-cmd --zone=public --list-all public (default, active) interfaces: eno16777984 sources: services: dhcpv6-client mdns ssh ports: 8080/tcp masquerade: no forward-ports: icmp-blocks: rich rules: # 刪除一個端口 firewall-cmd --permanent --zone=public --remove-port=8080/tcp firewall-cmd --permanent --zone=public --remove-port=8080/udp
