【Linux】Linux 常用命令匯總
查看軟件xxx安裝內容:dpkg -L xxx 查找軟件庫中的軟件:apt-cache search 正則表達式 查找軟件庫中的軟件:aptitude search 軟件包 查找文件屬於哪個包:dpkg -S filename 查找文件屬於哪個包:apt-file search filename 查詢軟件xxx依賴哪些包:apt-cache depends xxx 查詢軟件xxx被哪些包依賴:apt-cache rdepends xxx 增加一個光盤源:sudo apt-cdrom add 系統升級:sudo apt-get update;sudo apt-get dist-upgrade 清除已刪除包的殘餘配置文件:dpkg -l |grep ^rc|awk ‘{print $2}’ |sudo xargs dpkg -P 編譯時缺少h文件的自動處理:sudo auto-apt run ./configure 查看安裝軟件時下載包的臨時存放目錄:ls /var/cache/apt/archives 備份當前系統安裝的所有包的列表:dpkg –get-selections | grep -v deinstall > ~/somefile 從備份的安裝包的列表文件恢復所有包:dpkg –set-selections < ~/somefile;sudo dselect 清理舊版本的軟件緩存:sudo apt-get autoclean 清理所有軟件緩存:sudo apt-get clean 刪除系統不再使用的孤立軟件:sudo apt-get autoremove 查看包在服務器上面的地址:apt-get -qq –print-uris install ssh | cut -d\’ -f2 查看內核:uname -a 查看Ubuntu版本:cat /etc/issue 或 lsb_release -a 查看內核加載的模塊:lsmod 查看PCI設備:lspci 查看USB設備:lsusb -v 查看網卡狀態:sudo ethtool eth0 查看CPU信息:cat /proc/cpuinfo 顯示當前硬件信息:sudo lshw 顯示系統運行時間:uptime 查看硬盤的分區:sudo fdisk -l 硬盤分區:sudo fdisk /dev/sda 硬盤格式化:sudo mkfs.ext3 /dev/sda1 硬盤檢查(請不要檢查已經掛載的分區,否則容易損壞數據):sudo fsck /dev/sda1 分區掛載:sudo mount -t 文件系統類型 (-o nls=utf8 或 -o iocharset=utf8) 設備路經 訪問路經 分區卸載:sudo umount 目錄名或設備名 查看IDE硬盤信息:sudo hdparm -i /dev/hda 查看STAT硬盤信息 :sudo hdparm -I /dev/sda 或 sudo blktool /dev/sda id 查看硬盤剩餘空間:df 查看目錄占用空間:du -hs 目錄名 優盤沒法卸載:sync;fuser -km /media/usbdisk 查看硬盤當前讀寫情況:sudo iostat -x 2 查看當前的內存使用情況:free 動態顯示進程執行情況:top 查看當前有哪些進程:ps -A 查看當前進程樹:pstree 中止一個進程:kill 進程號 或 killall 進程名 強制中止一個進程:kill -9 進程號 或 killall -9 進程名 圖形方式中止一個程序:xkill 出現骷髏標誌的鼠標,點擊需要中止的程序即可 查看進程打開的文件:lsof -p 顯示開啟文件abc.txt的進程 :lsof abc.txt 顯示22端口現在運行什麽程序 :lsof -i :22 顯示nsd進程現在打開的文件 :lsof -c nsd 在後臺運行程序,退出登錄後,並不結束程序 :nohup 程序 & 詳細顯示程序的運行信息 :strace -f -F -o outfile 增加系統最大打開文件個數:ulimit -n 4096 或 echo 4096 > /proc/sys/fs/file-max 配置 ADSL :sudo pppoeconf ADSL手工撥號:sudo pon dsl-provider 激活 ADSL:sudo /etc/ppp/pppoe_on_boot 斷開 ADSL :sudo poff 查看撥號日誌:sudo plog 如何設置動態域名:w3m -no-cookie -dump ‘http://usere:[email protected]