一、簡介
有時候想看看ls、cat、more等命令的源代碼,本文介紹相應查看方法。
二、方法
參考:
以查看uname命令源碼為例進行說明,步驟如下:
# whereis uname uname: /bin/uname /usr/share/man/man1/uname.1.gz /usr/share/man/man2/uname.2.gz /usr/share/man
# rpm -qf /bin/uname
coreutils-8.5-7.fc14.i686
# yumdownloader --source coreutils-8.5-7.fc14.i686
# rpm2cpio coreutils-8.5-7.fc14.src.rpm | cpio -idv coreutils-8.5.tar.xz
coreutils-8.5.tar.xz
9446 blocks
# tar xjvf coreutils-8.5.tar.xz
三、源碼分析
參考:
http://blog.csdn.net/yxc135/article/details/22161907