Article 6MDTE NTP - I want use like common user

NTP - I want use like common user

by
inukaze
from LinuxQuestions.org on (#6MDTE)
Ok i had wrote this script some time ago

Code:cat /usr/bin/SincronizarHora.geb
#!/usr/bin/env bash

echo '
Autor ----------------> Inukaze ( Venezuela )
Sitio ----------------> https://goo.gl/ij6WqW
Correo-E -------------> bloginukaze@gmail.com
Licencia -------------> GPL 2

******* Inicio : Acerca de este Guiin ********

Yo intento escribir guiones compatibles con
Sistemas operativos Unix & POSIX , y otros
Sistemas operativos que soporten bash

Este archivo es un guion sencillo para
Sincronizar la hora utilizando
i ntpdate i (asi que debe estar instalado)

******** Fin : Acerca de este Guiin **********'
sleep 3

#Determinar en que directorio estoy :
GUION=$(readlink -f "$0")
RUTA=$(dirname "$GUION")
ntpdate=$(whereis -B "/usr/sbin" "/usr/local/sbin" "/sbin" "/usr/bin" "/usr/local/bin" "/bin" -b ntpdate | grep -i "ntpdate" | cut -d " " -f02 | cut -c11-20)
service=$(whereis -B "/usr/sbin" "/usr/local/sbin" "/sbin" "/usr/bin" "/usr/local/bin" "/bin" -b service | grep -i "service" | cut -d " " -f02 | cut -c11-20)
rcntpd="/etc/rc.d/rc.ntpd"

if [ -z "$ntpdate" ]; then
echo
echo "ntpdate no esta instalado en tu sistema operativo GNU"
echo "Por favor, instale primero i ntpdate i"
echo
exit 0
fi

#Slackware(64) :
if [ -d "/etc/rc.d" ];then
if [ -f "$rcntpd" ]; then
chmod +x "$rcntpd"
"$rcntpd" "stop"
#ntpdate -u 0.south-america.pool.ntp.org
ntpdate -u time.nist.gov
hwclock -w
"$rcntpd" "start"
fi
fi

#Debians :
if [ -z "$service" ]; then
echo ""
else
sudo service ntpd stop
sudo su -c "rm -rf /etc/localtime" root
sudo su -c "ln -s /usr/share/zoneinfo/America/Caracas /etc/localtime" root
echo 'TZ='America/Caracas'; export TZ' >> "$HOME/.profile" ; source "$HOME/.profile"
sudo update-locale LC_TIME=es_ES.UTF-8
#ES#sudo su -c "cp -rf $PWD/usr/share/i18n/locales/es_ES /usr/share/i18n/locales/es_ES" root
#ES#sudo su -c "cp -rf $PWD/usr/share/i18n/locales/es_ES@euro /usr/share/i18n/locales/es_ES@euro" root
#ES#sudo su -c "cp -rf $PWD/usr/share/i18n/locales/es_VE /usr/share/i18n/locales/es_VE" root
LANG="es_ES.UTF-8" ; export LANG="$LANG"
LANGUAGE="es_ES.UTF-8" ; export LANGUAGE='"'"$LANGUAGE"'"'
LC_ALL="es_ES.UTF-8" ; export LC_ALL="$LC_ALL"
# ntpdate -u 0.south-america.pool.ntp.org ; hwclock -w
ntpdate -u time.nist.gov ; hwclock -w
sudo service ntpd start
fi

exit 0right now i prefer use " Network Manager " for manual configuration IP inside the KDE Plasma Desktop [ Grafical Session ].

if i try ran commands like normal user :

Code:su -c "gpasswd -a inukaze ntp ; gpasswd -a inukaze ntpd" rootQuote:
Contraseia:
Aiadiendo al usuario inukaze al grupo ntp
gpasswd: el grupo intpdi no existe en /etc/group
Code:rcntpd stopQuote:
Stopping NTP daemon.../etc/rc.d/rc.ntpd: linea 15: kill: (1022) - Operaciin no permitida
rm: no se puede borrar '/run/ntpd.pid': Permiso denegado
if my user is part of ntp group, why not had permission to delete the file '/run/ntpd.pid' ?

Code:ntpdate -u time.nist.govQuote:
28 Apr 17:51:02 ntpdate[3406]: step-systime: Operation not permitted

Code:$rcntpd startQuote:
Starting NTP daemon: /usr/sbin/ntpd -g -u ntp:ntp28 Apr 17:54:45 ntpd[3943]: must be run as root, not uid 1000
Code:hwclock -wQuote:
bash: hwclock: orden no encontrada
The hwclock command just can be use by the root ?

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 "
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments