用linux一段时间了,有时候想看看ls、cat、more等命令的源代码,在下载的内核源码中用cscope没能找到,在网上搜索了一下,将方 法总结以下:linux
lpj@lpj-linux:~$ which ls /bin/ls
lpj@lpj-linux:~$ dpkg -S /bin/ls coreutils: /bin/ls
sudo apt-get source coreutils cd /usr/src/coreutils-XXX #XXX表示版本号 sudo tar zxvf coreutils-XXX.tar.gz
sudo apt-get -d source coreutils cd /usr/src tar zxvf coreutils-XXX.tar.gz gzip -d coreutils-XXX.diff.gz #这一步会生成coreutils-XXX.diff文件 patch -p0 < coreutils-XXX.diff cd coreutils-XXX tar zxvf coreutils-XXX.tar.gz
OK,这几步执行完后,就能够进入/usr/src/coreutils-XXX/coreutils-XXX/src中查看各命令对应的源代码了spa