NTP - I want use like common user
Ok i had wrote this script some time ago
Code:
cat /usr/bin/SincronizarHora.geb if i try ran commands like normal user : Code:
su -c "gpasswd -a inukaze ntp ; gpasswd -a inukaze ntpd" root Quote:
Code:
rcntpd stop Quote:
Code:
ntpdate -u time.nist.gov Quote:
Code:
$rcntpd start Quote:
Code:
hwclock -w Quote:
Ok why for just sync clock hour i need root permission ? Which things i should edit for all users inside ntp group can use commands ; ntpd, hwclock stop/start/restart/status ntp, ntpd, services. can delete and create the file " /run/ntpd.pid " |
/run is owned by root, so only root can remove /run/ntpd.pid. In Linux you must have write permissions on the directory in order to have the permission to remove a file from it, the permissions or the ownership of the file is immaterial.
But there are more fundamental issues here. ntp uses port 123. For all practical matters: Linux allows only root-owned processes to bind to ports below 1024 (the actual permissions are based on Linux-specific "capabilities", but this gets too deep in the weeds here). TLDR: you need to be root in order to start or stop ntpd. Non-root permissions won't be enough. |
Add your user to the sudoers file, allow it to use ntpdate, and then use "sudo ntpdate -u time.nist.gov" instead.
Something like this should work (and not even ask for your inukaze account password): # more /etc/sudoers.d/ntpdate inukaze your-hostname-here = NOPASSWD: /usr/bin/ntpdate For more information, man sudo man sudoers Also, ntpd is a service you start once and let it do its thing; no need to keep restarting it. |
Quote:
Code:
visudo -c the line inside my sudoers file is : Code:
%ntp Slack64 = NOPASSWD: /usr/bin/ntpdate, /usr/sbin/ntpdate, /usr/sbin/ntpd, /usr/sbin/ntpq, /sbin/hwclock Code:
ntpdate -u time.nist.gov Quote:
Quote:
Code:
su -c "ln -sf /sbin/hwclock /usr/bin/hwclock" root Code:
# Sincronizar Hora durante el arranque : |
> well the thing is when i try to run the command like my user :
> > ntpdate -u time.nist.gov Did you try `sudo ntpdate -u time.nist.gov`? Adding the custom sudoers file is the first part of the puzzle, but you still need to use `sudo` when running the command |
Quote:
Code:
sudo ntpdate -u time.nist.gov ; sudo hwclock -w Quote:
|
Quote:
|
Quote:
|
All times are GMT -5. The time now is 09:34 AM. |