Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

I already know about faketime and datefudge, but is there a way to set this up transparently for any process that's being run as a certain user (identified by a specific UID)?

share|improve this question
up vote 1 down vote accepted

Since you have the entire source code to Linux, you can set this up exactly as you want, but you'll have to modify the system kernel and rebuild it to make it so. It isn't easy to set this up based on a UID.

If you only want to arrange that a logged in user has this property for most commands they execute, give them a login shell that uses faketime to set the environment variable and then call their real shell. You can get a taste for how this looks by doing it interactively:

$ date
Mon Oct 14 14:02:05 EDT 2013
$ faketime yesterday bash
$ date
Sun Oct 13 14:02:10 EDT 2013
$ exit
$ date
Mon Oct 14 14:02:15 EDT 2013

A special login shell should also work for cron jobs that use the user's login shell.

Of course this fakery fails for any program that sets or ignores its own $LD_PRELOAD information:

$ faketime yesterday bash
$ date
Sun Oct 13 14:02:20 EDT 2013
$ env -i /bin/date
Mon Oct 14 14:02:25 EDT 2013
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .