Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux技術

Linux 系統資訊與已安裝套件查詢指令整理

在 Linux 日常運維中,快速掌握系統版本、資源使用、網路狀態與套件安裝情況,是排查問題的基礎。以下依情境整理常用指令。

系統資訊

uname -a
head -n 1 /etc/issue
cat /proc/cpuinfo
hostname
lspci -tv
lsusb -tv
lsmod
env

資源與效能

free -m
df -h
du -sh 目錄名
grep MemTotal /proc/meminfo
grep MemFree /proc/meminfo
uptime
cat /proc/loadavg

磁碟與分區

mount | column -t
fdisk -l
swapon -s
hdparm -i /dev/hda
dmesg | grep IDE

網路狀態

ifconfig
iptables -L
route -n
netstat -lntp
netstat -antp
netstat -s

進程與用戶

ps -ef
top
w
id 用戶名
last
cut -d: -f1 /etc/passwd
cut -d: -f1 /etc/group
crontab -l

服務與套件

chkconfig --list
chkconfig --list | grep on
rpm -qa

RPM 套件管理

RPM 是 Red Hat 系列常用的套件管理工具,功能類似 Windows 的「新增或移除程式」,但更適合命令列環境。

rpm -qpi 套件.rpm
rpm -qpl 套件.rpm
rpm -ivh 套件.rpm
rpm -ivh -replacepkgs 套件.rpm
rpm -e 套件名
rpm -uvh 套件.rpm
rpm -Va
rpm -qf 檔案名

APT-GET 套件管理

在 Debian 或 Ubuntu 系列中,apt-get 是常見的套件管理工具。

apt-get update
apt-get install 套件名
apt-get remove 套件名
apt-get --purge remove 套件名
apt-get autoclean
apt-get clean
apt-get upgrade
apt-get dist-upgrade
apt-cache search 字串
dpkg -l 模式
aptitude
apt-cache showpkg 套件
apt-cache show 套件
dpkg -S 檔案
dpkg -L 套件
apt-file search 檔案名

掌握這些指令,可以快速定位系統狀態、套件依賴與檔案歸屬,也能提升日常排錯效率。

Copyright © Linux教程網 All Rights Reserved