4

From where to get the source code for reboot command in Linux ?

durron597
  • 31,968
  • 17
  • 99
  • 158
nitin_cherian
  • 6,405
  • 21
  • 76
  • 127

2 Answers2

5

See shutdown.c in util-linux.

ephemient
  • 198,619
  • 38
  • 280
  • 391
  • At least on Scientific Linux, this one is the source for /sbin/shutdown cmd, not /sbin/reboot. The other answer using rpm -qf is better for me. – Jiang Oct 19 '12 at 18:26
2

On RHEL / CentOS at least it's in the SysVinit package. You can determine this by

which reboot

to find the executable - it's in /sbin/reboot for me - then

rpm -qf /sbin/reboot

to find out which package it is in. You should then be able to download a SRPM from any CentOS mirror, e.g. http://www.mirrorservice.org/sites/mirror.centos.org/5.5/os/SRPMS/

Rup
  • 33,765
  • 9
  • 83
  • 112
  • 2
    Along those lines, `dpkg -S /sbin/reboot` queries the owner package on dpkg-based systems, which happens to be `upstart` on Ubuntu and `sysvinit` on Debian; `apt-get source` will fetch the sources. Too bad there isn't any single init system on Linux; each distribution has their own copy. (Even the multiple systems named sysvinit aren't the same.) – ephemient Jan 06 '11 at 07:34