天天看點

Linux指令行源碼查找方式

1.查找指令行所對應的可執行檔案,可以使用find/whereis/which/type find在指定目錄下查找名稱為指令行名的檔案

[email protected]:/work$ find /bin -name ls 
/bin/ls 
           

whereis查找指定指令的所有(-b)二進制檔案、(-m)man說明檔案、以及(-s)源代碼檔案

[email protected]:/work$ whereis ls 
ls: /bin/ls /usr/share/man/man1/ls.1.gz
           

which隻在PATH變量的指定路徑下查找

[email protected]:/work$ which ls 
/bin/ls 
           

type判斷指令行是bash自帶的,還是外部二進制檔案提供,并輸出路徑(-a參數輸出所有可能)

[email protected]:/work$ type -a ls 
ls is aliased to `ls --color=auto'     ---->在~/.bashrc中有别名定義
ls is /bin/ls    ------->實際位置
           

[email protected]:/work$ type cd 
cd is a shell builtin
           

對于bash的自帶指令,直接進入步驟3,下載下傳bash源碼包

2.根據執行檔案查找安裝包

[email protected]:/work# dpkg -S /bin/ls 
coreutils: /bin/ls 
           

3.下載下傳源碼包(該方式下載下傳不一定是最新的,也可以直接網上搜尋,在官網上下載下傳)

[email protected]:/work# apt-get source coreutils
           

4.源碼包存放在目前目錄,同時還有更新檔包,以及儲存壓縮包md5值的檔案。 上面的指令預設解壓源碼包,并把更新檔打上,是以隻目前目錄下的源碼檔案目錄就是我們所需的

繼續閱讀