1

I am trying to automate a time change on Ubuntu 10.04 with a bash script using the date command. The script works, but it requires sudo privileges, however, the user who will execute the script does not have sudo privileges. Obviously I do not want to include the sudo password in the script.

Is there file I can change the permissions of that would allow non sudo users to change the time?

1
  • You could make a specific sudo exception: unix.stackexchange.com/questions/44865 (of course, replace apache with tthe username). This will give the user sudo privileges, but only for that specific command, and won't require sharing the password. Dec 17, 2014 at 15:51

2 Answers 2

3

You can add a line to the /etc/sudoers file.

This file controls who is allowed to run what commands using sudo, and whether they need to enter a password. A line similar to the below will do the trick, replacing <username> with the user's name:

<username> ALL=(ALL) NOPASSWD: /bin/date

You can also use a group name using %groupname format.

Edit this file using the visudo command, which you will need to run as root, with sudo.

You can find much more info in the sudoers man page (man sudoers) or in the Ubuntu documentation at https://help.ubuntu.com/community/Sudoers

0
1

I solved this problem using libfaketime, and it worked very well. This is definitely more secure than allowing anyone to change the date on your computer.

You must log in to answer this question.

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