2008年1月11日 星期五

檔案搜尋

which 接command
依照PATH的路徑 尋找command 列出該位置

xiang-debian:/var# which ls
/bin/ls

whereis [option] name
尋找特定程式的可執行檔 原始碼檔 以及manpage路徑. 該指令只會在標準Linux 目錄尋找(/bin /etc /usr/bin /usr/local......)

option
-b 只尋找可執行檔
-m 只尋找manpae
-s 只尋找原始碼檔


locate 接patterns
列出包含patterns的檔案. 需要注意的事,第一次執行locate時,他會建立一個索引資料庫,locate都是從該資料庫尋找,所以如果檔案在更新資料庫之後出現是找不到的.

updatedb 更新資料庫囉

whatis keyword
會於whatis資料庫中尋找keyword, 需完全符合keyword才會顯示出來

apropos keyword
跟whatis差不多 , 但沒那麼嚴格,會找出類似的資料

另外 find 會另外寫一篇

2008年1月9日 星期三

apt 指令

常用的一些指令 其他請參考man

=========
apt-get
=========
apt-get update
更新資料庫,依sources.list 的設定 比對軟體資料庫

apt-get install 接套件名稱
安裝套件,安裝過程中幾乎只要選擇yes/no apt就會幫我們安裝

apt-get remove 接套件名稱
移除套件

apt-get upgrade
套件升級

apt-get source
取得套件source

apt-get clean
透過apt-get install 所安裝的套件,一般都會先下載到 /var/cache/apt/archives 及 /var/cache/apt/archives/partial目錄底下,要清除這些套件就需要使用這個指令

apt-get check
當發生問題時可以使用這個指令來診斷問題

==========
apt-cache
==========
apt-cache showpkg
顯示套件資訊

apt-cache stats
顯示相關統計資訊

apt-cache show
顯示套件資訊 如 rpm -qi

apt-cache search
尋找相關套件

apt-cache depends
顯示套件相依性

apt

APT(Advanced Package Tool)是 Debian GNU/Linux 用來管理套件的工具

apt功能
apt 能安裝 管理 移除 或是升級套件,而且最重要的 他會自動解決相依性的問題
假如在安裝A套件時 需要先安裝B套件,在以前我們會需要先去下載並安裝B套件,之後在安裝A套件,但是apt會"自動"的執行

apt運作原理
事實上apt是透過網路連線連到遠端的伺服器上去下載套件的,在 /etc/apt/sources.list 這個檔案裡設定我們指定的apt 伺服器位址.

sources.list 格式
deb uri distribution [component1] [componenent2] [...]
deb 這一欄只有兩種寫法 deb . deb-src , deb為編譯好的套件, deb-src 則為 source 的版本

uri ( Universal Resource Identifier ) 套件的來源位置, 位置可以是系統的某個file CDROM 的檔案 遠端伺服器(http ftp)的檔案等等
常見選項 file 系統內的檔案 deb file:/home/moto/debian stable main contrib non-free
CDROM 光碟檔案 deb cdrom:/dists stable main contrib non-free
http 透過http傳輸 deb http://http.us.debian.org/debian stable main contrib non-free
distribution debian 軟體種類(下面說明)

component 參數共分為 『 main 』、『 contrib 』、『 non-US 』、『 non-free 』
main 最基本及主要且符合自由軟體規範的軟體
contrib 這裡頭軟體雖然可以在 Debian 裡頭運作,即使本身屬於自由軟體但多半卻是相依於非自由 ( non-free ) 軟體。
non-US 來自非美國地區的軟體
non-free 非屬於自由軟體

關於debian 的軟體種類大致上分為三種 stable . testing . unstable
stable
最穩定的版本,通常適合用在伺服器上面

testing
已經相當接近stable的版本,這些軟體大多是從unstable流入, 適合desktop使用

unstable
版本最新的類型,不過通常太新相對的bug也比較多一點,但更新速度很快就是了

參考資料 debian 無痛起步

debian 套件管理

debian 最基本的套件管理工具是 dpkg 操作對象為檔案名稱
另一個工具是 apt 操作對象為套件名稱

dpkg
語法 dpkg [option] action
dpkg會維護 /var/lib/dpkg 目錄下的套件資訊
其中 available 列出所有可用套件
status 紀錄套件的屬性
選項
-i 接套件名稱 安裝指定的套件
-l 接pattern 在以安裝的套建中 列出指定的 pattern 以及相關資料
-L 接套件名稱 列出安裝該套件所會安裝的檔案
-r 接套件名稱 移除該套件 但保留組態檔
--purge 接套件名稱 移除該套件的所有檔案
--info 接套件名稱 套件相關資訊
其他的 請找man吧

使用 --info 的範例
==============================================
xiang-debian:/tmp# dpkg --info lynx_2.8.5-2sarge2.2_i386.deb
新格式的 debian 套件,版本是 2.0。
大小 1859352 bytes:主控檔案=1200 bytes。
14 字節, 1 行 conffiles
854 字節, 20 行 control
468 字節, 20 行 * postinst #!/bin/sh
228 字節, 15 行 * postrm #!/bin/sh
537 字節, 15 行 * preinst #!/bin/sh
206 字節, 9 行 * prerm #!/bin/sh
Package: lynx
Version: 2.8.5-2sarge2.2
Section: web
Priority: optional
Architecture: i386
Depends: libbz2-1.0, libc6 (>= 2.3.6-6), libgnutls13 (>= 1.4.0-0), libncursesw5 (>= 5.4-5), zlib1g (>= 1:1.2.1)
Recommends: mime-support
Conflicts: lynx-ssl
Replaces: lynx-ssl
Provides: www-browser, news-reader, lynx-ssl
Installed-Size: 4568
Maintainer: James Troup
Description: Text-mode WWW Browser
Lynx is a fully-featured World Wide Web (WWW) client for users
running cursor-addressable, character-cell display devices (e.g.,
vt100 terminals, vt100 emulators running on PCs or Macs, or any other
"curses-oriented" display). It will display hypertext markup language
(HTML) documents containing links to files residing on the local
system, as well as files residing on remote systems running Gopher,
HTTP, FTP, WAIS, and NNTP servers.
===============================================

debian 學習

最近參加了debian的讀書會 所以會開始記些debian的東西囉


/xiang