12

When we use uptime, it only shown us the up-time of ours machine since it started from the last time it turning on/shutdown/reboot.

But, what if I want to get the time when our machine started from the very first time when it installed?

Do Linux own this tools? Or any clues about how I can find out the answer of it?

yan
  • 123
  • 5
  • Which distribution? Some potential answers to this question may be distribution-specific. – Michael Hampton Sep 30 '13 at 02:37
  • @Michael: I'm using Debian server ... – yan Sep 30 '13 at 02:38
  • You say "machine" but the answers seem to assume "installation". (Case in point, when I built my current PC and physically reinstalled the old hard disk with the old system still on it in the new case, the new machine essentially had an accumulated power-on time of 0 hours, but the installed system had been running for a long time already. Even this isn't completely accurate as I kept the same power supply that I had been using before...) – user Sep 30 '13 at 07:52

2 Answers2

21

One of my favorite distribution-agnostic tricks is to check the inode change time of files or directories which are extremely unlikely to ever have been altered over the life of the server. These are generally directories in the root directory, such as /lost+found.

For example, this Ubuntu 10.04 LTS system was indeed installed around 9:40 pm on February 1, 2011.

# ls -lctr / | head -n 5
total 88
drwxr-xr-x   2 root root  4096 2011-02-01 21:40 selinux
drwxr-xr-x   2 root root  4096 2011-02-01 21:40 opt
drwxr-xr-x   2 root root  4096 2011-02-01 21:40 mnt
drwxr-xr-x   2 root root  4096 2011-02-01 21:40 media

And finally, a sure fire answer which is reasonably sure to be accurate, if you have an ext* root filesystem. Look at the filesystem metadata, which contains the time the filesystem was created. For instance, this command shows the creation time for the filesystem mounted at /.

tune2fs -l $(grep " / " /proc/mounts | grep -v rootfs | cut -f 1 -d " ") | grep created
Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • You are right Michael, it have the same value with timestamp of /var/log/installer, the answer that has answered by MdMara ... TYVM. – yan Sep 30 '13 at 02:53
11

If you're on a distribution that uses Anaconda, you can look at /root/install.log.


edit: It appears you're using Debian. Debian places its install log into /var/log/installer.

MDMarra
  • 100,183
  • 32
  • 195
  • 326
  • Thank you MDMarra ... using your answer and to find out the oldest file in it then I use command *ls -gt | tail -l* ... – yan Sep 30 '13 at 02:45