Skip to Content

工具程式

下面是一些常用的指令

File/Directory Basics

  • lscd  / pwd -  List files / Change directory / Print current directory
  • cpmv / rmCopy filesRename filesDelete files
  • ln - (Link files) 檔案的連結主要的作用是讓檔案有其他的分身,而連結有分為 I. 硬式連結 Hard Link 以及 II. Soft Link
  • mkdir - (Create directory) 一次建立多個資料夾
  • rmdir Delete directory
  • dd - (conver and copy a file) dd 的功能是多用途,不管是備份還是硬碟的效能測試都可以.
  • cat / less / head / tail - 檢視檔案內容
  • nl Number lines
  • od View binnary data
  • xxd View binnary datagv View Postscript/PDF files
  • xdvi View TeX DVI files
  • Package Manager
  • 傳統的 Linux 下用來管理套件的是使用 rpm 但太多的相依性讓心的套件常常會因為套件的相依而無法使用,所以目前漸漸都改成為 yum 或是 apt-get

File Creation and Editing

  • emace Text editor
  • vim Text editor
  • umask - 檔案/目錄預設的權限

File Properties

  • stat - 顯示檔案的狀態
  • wc - 計算出檔案有多少個 bytes/words/lines
  • du - 計算目錄所使用的容量
  • file - 因為 Linux 不依據檔尾的名稱來判斷是什麼檔案,所以我們可以使用這個程式來判斷檔案的格式
  • touch Change file timestamps
  • chown / chgrp / chmod - 更改檔案的 owner 以及 group 以及檔案權限
  • chattr lsattr - ext2(3)的檔案系統除了一般的檔案權限管理外,還有一種叫做屬性 (attributes) 可以來設定.這些屬性可以幫助系統管理者更方便嚴謹的檔案權限問題.
  • ldd - Linux 上的每一個程式大部分是採用 Dynamical Link 的編譯,所以想知道這個程式使用了哪一些 Libary 就可以使用 ldd 來觀看.

File - Location

  • which - 會利用PATH參數來尋找所有位於PATH目錄下可執行檔案
  • find - 會根據所指定的範圍進行搜索
  • whereis - 不僅能尋找可執行檔案,還可以尋找manpage以及原始檔
  • (s)locate - 所搜尋的是updatedb所製成的資料庫

File Text Manipulation

  • grep Search text for matching lines
  • cut Extract columns
  • paste Append columns
  • tr Translate characters
  • sort Sort lines
  • uniq Locate identical lines
  • tee Cpoy stdin to a file and to stdout simultaneously

常用的檔案壓縮與包裝  File - Compression

  • gzip - Compress files(GUN Zip)
  • compress - Compress files(Unix)
  • bzip2 - Compress files(BZip2)
  • zip - Compress files(Windows ZIP)

File Comparison

  • diff Compare files line by line
  • comm Compare sorted files
  • cmp Compare files byte by byte
  • md5sum - One Way hash 的加密方式

Hardware

Disk and Filesystems

  • df - 計算磁區 (partition) 所使用的容量
  • mount - 掛載磁碟
  • fsck Check a disk for errors
  • sync Flush disk caches
  • mtools - 在 Linux 下的一套指令和 DOS 下的方式一樣
  • partprobe - 重讀 partition table,可以立即更新硬碟的 partition table 給系統知道.

Backups and Remote Storage

  • mt Control a tape drive
  • dump Back up a disk
  • restore Restore a dump
  • tar archives - Linux 下最古老常用來備份的工具.
  • 如何在 Linux 做燒錄的工作,可以參考這一篇 - cdrecord/dvdrecord - Burn a CD/DVD
  • rsync Mirror a set of files

Printing

  • lpr Print files
  • lpq View print queue
  • lprm Remove print jobs

Spelling Operations

  • look Look up spelling
  • aspell Check spelling interactively
  • spell Check spelling in batch

Processes

  • ps List all processes
  • w List users' processes
  • uptime View the system load
  • xload Monitor system load
  • free Display free memory
  • kill Terminate processes
  • nice Set process priorities
  • renice Change process priorities

Scheduling Jobs

Linux 提供了4種工作排程的服務,每一種的使用時機皆不相同

  • cron -  cron 適用於重複發生的工作
  • at - 適用於某一特定時間一執行的工作
  • batch - batch 則當系統負載低於 0.8 時才會去執行排程的工作
  • anacron - anacron 只有在 cron 沒有完成排程內的工作時才會去完成 cron 沒做的工作

其他

  • sleep Wait for some time
  • watch - 週期性的重覆執行同一支程式

Hosts

  • uname Print system information
  • hostname Print system's hostname
  • ifconfig Set/display network information
  • host Look up DNS
  • whois Look up domain registrants
  • ping Check if host is reachable
  • traceroute - 透過他們可以得知系統經過幾個 hops(經過哪些網路來傳送該封包)

Networking

  • ssh - SSH 主要是用來取代 Telnet 這種以明碼為傳遞基礎的遠端登入服務
  • sftp -SSH 本身就提供 ftp 的功能,它還是使用 22 port ,只要使用它提供的指令 sftp 就可以使用了.
  • scp - 的功能類似於 rcp
  • ftp Copy files between hosts
  • evolution GUI email client
  • mutt Text-based email client
  • mail Minimal email client
  • lynx Text-only web browser
  • wget Retrieve web pages to disk
  • slrn Read Usenet news
  • gaim Instant messageing/IRC
  • write Send messages to a terminal
  • mesg Prohibit talk/write
  • netstat - 顯示目前網路連線狀態

Audio and Video

  • grip Play CDs and rip MP3s
  • xmms Play audio files
  • cdparanoia Rip audio
  • audacity Edit audio
  • setterm - Text mode 關閉 screen saver.

Performance 

要如何知道 Linux 下面各系統的效能如何可以參考面幾種方式.

  • 測試磁碟 I/O 的工具 - iometer
  • 除了 iometer 可以來測試硬碟的速度,你可以透過 hdparm 這是一個比較簡單的方式來看目前硬碟傳送的速度 - hdparm
  • 網路效能測試工具 - iperf
  • 另外一套專業級的網路效能測試工具 - IxChariot

Monitor

  • Linux 底下提供了監控系統使用資源的程式
  • Linux 預設最古老的系統資源監控程式 - top 最簡單的硬碟監測工具 - iostat
  • KDE 底功能最完整的監控程式 - ksysguard
  • 不是Linux 系統預設的系統資源監控程式,不過使用上相當直覺 - gkrellm

Questions

  • 相信用 Linux 的各位一定遇到不少問題過,如果有專人能幫我解決問題不是輕鬆多了,想要擁有這福利請洽 - RHN

Other

  • date - 設定時間