Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to give different users unique system date/times in Ubuntu?

For example, if I wanted the date to always be June 22nd for user Bob (because that's his birthday) but still have the correct date/time display for every other user, is there a way, straightforward or not, to do so?

share|improve this question
Break the clock display for bob. Ubuntu is open source so pretty much everything is possible if you are willing to put in the time to find out how to do it. – soandos May 31 '11 at 19:20
Not without hacking into the kernelspace. Of course, if you are just trying to fake date(1) then you can just add an if statement with the getuid() function. – bubu May 31 '11 at 19:28
Tell me more about this if statement – tel May 31 '11 at 19:37
Bob has the same birthday as me. Neat. – Zoredache May 31 '11 at 20:57

No need to hack the kernel. That would be relatively easy with an interposition library assuming the ways Bob uses to know what the time is are bounded.

For example, many commands like date(1) are using clock_gettime(2) to get the current date and time. An interposing library would patch on the fly the date part and set it June 22.

This won't work statically linked binaries like busybox, but these binaries could be easily patched the same way.

Here is a sample code demonstrating the feasibility:

#define _GNU_SOURCE
#include <stdio.h>
#include <stdint.h>
#include <time.h>
#include <dlfcn.h>
#include <unistd.h>
#include <sys/types.h>

int clock_gettime(clockid_t clk_id, struct timespec *tp)
    static int (*cgt)(clockid_t, struct timespec*) = NULL;
    if (!cgt)
        cgt = dlsym(RTLD_NEXT, "clock_gettime");

    int rv = cgt(clk_id, tp);
    if(getuid()==1000) // Assuming 1000 is bob's uid.
        struct tm * tm=localtime(&tp->tv_sec);
        time_t tt=mktime(tm);
    return rv;

And what it provides:

$ date
Wed Jun  2 23:44:51 CEST 2011
$ export LD_PRELOAD=$PWD/
$ date
Wed Jun 22 23:44:51 CEST 2011
$ id -u
share|improve this answer
OK, so... how do you actually do it? – Nitrodist May 31 '11 at 20:56
Hints added in my reply. – jlliagre Jun 1 '11 at 9:24
and full code now. – jlliagre Jun 2 '11 at 23:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.