Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> 關於Linux

Linux 常用小指令 25 則:系統資訊、網路、服務與 X Window

系統與核心

uname -a                       # 系統版本
lsb_release -a                 # RedHat 發行版本
getconf -a                     # 系統參數
sysctl -a                      # 核心參數(設定檔為 /etc/sysctl.conf)
sysctl -w kernel.shmmax=2147483648
sysctl -w kernel.sem="250 32000 128 100"
ulimit -a                      # 系統資源限制,可改 /etc/security/limits.conf

主機與網路

vi /etc/sysconfig/i18n        # 字元集:LANG / SUPPORTED / SYSFONT
vi /etc/sysconfig/network     # 主機名:NETWORKING / HOSTNAME
setup 或 netconfig            # 或編輯 ifcfg-eth0 設定 IP、遮罩、閘道
vi /etc/resolv.conf           # DNS:nameserver 202.106.0.20
netstat -nal                  # 顯示網路連線
ifconfig                      # 網路設定
lsof -i:<port>                 # 查某服務用了哪個埠
ldd                           # 程式相依關係

啟動方式與 X Window

vi /etc/inittab               # id:3 為多使用者模式,id:5 為 X Window
init 3 / init 5               # 即時切換

要讓 XManager 能登入,需依序修改:/etc/inittab 設為 5 並加上 prefdm 行;/etc/X11/gdm/gdm.conf 的 [xdmcp] 段 Enable=true;/etc/X11/xdm/Xaccess 去掉「# * #any host can get a login window」的註解;/etc/X11/xdm/xdm-config 在 DisplayManager.requestPort: 0 前加 !;/etc/sysconfig/iptables 加入放行 udp 177 埠。

另外,redhat-config-xfree86 可重新設定螢幕,startx 或 init 5 可啟動 X Window。

防火牆與存取控制

service iptables stop
chkconfig iptables off        # 或直接刪除 /etc/sysconfig/iptables

要拒絕或允許特定 IP 登入,可用 iptables,也可修改 /etc/hosts.allow 與 /etc/hosts.deny。

效能與服務管理

top / vmstat / free / sar / ps -auxm    # 資源使用情況
watch 命令                               # 重複執行並監控狀態
service service_name {start|stop|restart}
chkconfig service_name {on|off}

一些實用小技巧

sqlplus 中 backspace 變成 ^H,可在 .bash_profile 加入 stty erase ^H;想關掉主控台的 PC 喇叭,編輯 /etc/inputrc 並去掉「#set bell style none」的註解;只列出目錄不含檔案,用 ls -d */ 或 ls -l |grep ^d。

Copyright © Linux教程網 All Rights Reserved