Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> 電腦軟體教學 >> 伺服器技術 >> 關於伺服器

IDC 運維必備:Linux 伺服器核心技能全攻略

編輯:關於伺服器

一、各發佈版 Root 密碼重置(單用戶模式)

發行版Grub 編輯參數關鍵命令序列
Red Hat / CentOS / Fedorakernel 行尾加 single 或 Smount -t proc proc /proc
mount -o remount,rw /
passwd
sync; reboot
Debian / Ubuntu選 recovery mode → kernel 行 ro single 改 rw single init=/bin/bashmount -a
passwd root
reboot
SUSEkernel 行加 init=/bin/bashmount -n / -o remount,rw
passwd
mount -n / -o remount,ro
FreeBSD啟動選單選 4 進單用戶模式mount -a; fsck -y; passwd root; init 6
Solaris選 solaris failsafe → 掛載 /a 為讀寫passwd; init 6

二、常見壓縮格式解壓指令

  • .tar.bz2:tar jxvf file.tar.bz2
  • .tar.gz:tar zxvf file.tar.gz
  • .rpm:rpm -ivh file.rpm

三、SSH 服務啟用與管理

建議修改 /etc/ssh/sshd_config:PermitRootLogin no、Port 非22、PubkeyAuthentication yes、PasswordAuthentication no。

四、防火牆管理

  • 永久生效:chkconfig iptables on/off (RHEL6) / systemctl enable/disable firewalld (RHEL7+)
  • 即時生效:service iptables start/stop / systemctl start/stop firewalld
  • 開放常用埠(HTTP/HTTPS/SSH):
    iptables -A INPUT -p tcp --dport 80 -j ACCEPT
    iptables -A INPUT -p tcp --dport 443 -j ACCEPT
    iptables -A INPUT -p tcp --dport 22 -j ACCEPT
    service iptables save

五、網卡 IP 配置

  • 查看:ip addr show 或 ifconfig
  • RHEL/CentOS 永久配置:編輯 /etc/sysconfig/network-scripts/ifcfg-eth0
    BOOTPROTO=static
    IPADDR=192.168.1.100
    NETMASK=255.255.255.0
    GATEWAY=192.168.1.1
    DNS1=8.8.8.8
  • 生效:systemctl restart network 或 service network restart
  • FreeBSD:編輯 /etc/rc.conf,ifconfig_em0="inet 192.168.1.100 netmask 255.255.255.0"

六、運維黃金法則

  1. 所有變更先備份配置檔(cp file file.bak)
  2. 修改後語法檢查(apachectl -t, nginx -t, sshd -t)
  3. 關鍵服務變更安排維護窗口,並準備回滾方案
  4. 記錄操作日誌,包含時間、指令、現象、處理結果
Copyright © Windows教程網 All Rights Reserved
發行版安裝指令服務管理
Debianapt-get install openssh-server/etc/init.d/ssh restart
Ubuntusudo apt-get install openssh-serversudo /etc/init.d/ssh restart
FreeBSD預設安裝/etc/rc.d/sshd restart
RHEL/CentOSyum install openssh-serversystemctl restart sshd (7+)
/etc/init.d/sshd restart (6)