在CentOS系統中,配置技巧涉及多個方面,包括網絡配置、環境變量設置、軟件包管理、安全配置等。以下是一些常見的配置技巧:
低版本CentOS/RHEL系列:
/etc/sysconfig/network-scripts/ifcfg-<interface_name>
DEVICE=eth0
:指定網卡名稱BOOTPROTO=static
:設置為靜態IPIPADDR=192.168.1.100
:設置IP地址NETMASK=255.255.255.0
:設置子網掩碼GATEWAY=192.168.1.1
:設置網關ONBOOT=yes
:設置開機自啟systemctl restart network
高版本CentOS/RHEL系列及Fedora:
/etc/NetworkManager/system-connections/<connection_name>
[ipv4]
部分設置address
和gateway
systemctl restart NetworkManager
export PATH=$PATH:/path/to/new/directory
~/.bashrc
文件,添加 export PATH=$PATH:/path/to/new/directory
/etc/profile
或 /etc/bashrc
文件,添加 export PATH=$PATH:/path/to/new/directory
sudo dnf update
更新到最新版本sudo yum install httpd php mysql
安裝Apache、PHP和MySQL/etc/sysconfig/iptables
文件,添加規則打開所需端口,例如:*filter :INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
sudo service iptables restart
sestatus
命令chmod +x Anaconda3-2024.10-1-Linux-x86_64.sh
./Anaconda3-2024.10-1-Linux-x86_64.sh
export PATH=/home/conda/conda/bin:$PATH
~/.bashrc
文件以永久保存環境變量以上技巧涵蓋了CentOS系統配置的多個方面,希望對你有所幫助。