4

I need to be able to set the system time using 'date' as a regular user.

I have a non-networked pc connected to a GPS receiver and would like to sync the time to GPS time. Needs to be done from a script and can't require password prompt.

Thinking that I can change the permissions on the date cmd to enable execution by any user. Is this possible and how do I do it? Any other suggestions?

UPDATE Using sudo is acceptable, just can't require a password prompt. Sentance edited above.

2
  • Date is a command owned by root, changing permission will require sudo. Why not simply ask your admin ? Feb 5, 2016 at 0:44
  • I am the admin. I needed to know how to enable another user.
    – tcashin
    Feb 5, 2016 at 6:19

1 Answer 1

4

You have two options, for both you'll need root access (sudo) to setup.

  1. Use sudo to allow a specific user to run /bin/date as root. man sudoers and man sudo to learn more.

  2. Use Linux' capability CAP_SYS_TIME to let /bin/date set time without root. man capabilities and man setcap to learn more.

Complete guide could be found here: (read the two answers) https://unix.stackexchange.com/questions/78299/allow-a-specific-user-or-group-root-access-without-password-to-bin-date

2
  • Thanks. Been awhile since I've used Ubuntu and the sudoers file and man page is not for the faint hearted. Think I figured it out. BTW, I was also able to accomplish my goal by setting suid on /bin/date. Any reason why that would be good or bad?
    – tcashin
    Feb 5, 2016 at 6:22
  • Assuming that suid on /bin/date works, it provides no control what so ever, and allows all the users of the system to do the same as well as it allows ALL capabilities to /bin/date.
    – niry
    Feb 5, 2016 at 6:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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