I come from a windows background and in windows there was .bat files that could run commands automatically. Now since I have swiched to linux (Ubuntu) i beilieve it does not support .bat files, so I was wondering can someone please help me create a script which when run, will do the following:
Not 100% sure that < will work for a password prompt.
Generally it is considered a bad idea to put passwords inside scripts. I guess it depends on how much your system would be compromised if the password was discovered by a hacker. I don’t know much about ntpdate but maybe add that command into the /etc/sudoers config file allowing you to run that command without a password.
For the ntp update you could just add the command to a cron job which by default runs at root. man crontab for details and will also avoid handling the password in general.