Script zum ändern der Systemzeit
#!/bin/bash # by Changer WHITE='\033[0;37m' GREEN='\033[0;32m' YELLOW='\033[0;33m' NO_COlOR='\033[0m' echo -e "${GREEN}" echo -e "Set Time and Date" echo -e "Format: year-month-day Hour:Minute:Second.Nanosecond" echo -e "Example:" echo -e "2016-02-09 13:10 to set Time to February 09th 2016 13:10" echo -e -n "please enter Date: ${YELLOW}" read datestring echo -e -n "${GREEN}New Time: ${WHITE}" sudo date --set "$datestring" sleep 5 exit
#Anlegen des Scripts pi@pi-desktop:~$ nano /opt/set_date.sh #Inhalt von oben kopieren #Strg + o speichern Strg + x schließen #Ausführbar machen pi@pi-desktop:~$ chmod +x /opt/set_date.sh
Damit jeder Benutzer den Befehl ausführen darf, kann man date noch in der sudoers Datei eintragen. Hier fügt man einfach die hervorgehobene Zeile hinzu.
pi@pi-desktop:~$ sudo nano /etc/sudoers [sudo] password for pi: #Inhalt der Datei # # This file MUST be edited with the 'visudo' command as root. # # Please consider adding local content in /etc/sudoers.d/ instead of # directly modifying this file. # # See the man page for details on how to write a sudoers file. # Defaults env_reset Defaults mail_badpass Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" # Host alias specification # User alias specification # Cmnd alias specification # User privilege specification root ALL=(ALL:ALL) ALL # Members of the admin group may gain root privileges %admin ALL=(ALL) ALL # Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL %sudo ALL=(root) NOPASSWD: /bin/date # See sudoers(5) for more information on "#include" directives: #includedir /etc/sudoers.d #Strg + o speichern Strg + x schließen
Nun kann das Script zum Beispiel auf dem Desktop als Starter hinzugefügt werden.