Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Another question would be why? Time isn't typically considered arbitrary, and these days it normally isn't set by hand anyway. Assuming you have network, you should have ntpd running. Check `ps -ax | grep ntpd` and see if it shows up. Look at /etc/ntp.conf for its setup. Depending on your distribution, it might have a startup script at /etc/init.d/ntpd. While you probably don't want to read the man page (network time protocol can get bloody complicated), `man ntpd` would at least confirm it is there. If it isn't set up and running, you'll want to google a simple howto for setting up ntpd in linux.
Here's a script I wrote to change the system time:
# set the system time and date
# make sure we are root
if test ~ != '/root'
echo 'ERROR: You must be root to run this script' >&2
# read user input
printf 'Enter month as ## => '
printf 'Enter day as ## => '
printf 'Enter year as #### => '
printf 'Enter hour out of 24 as ## => '
printf 'Enter minute as ## => '
printf 'Enter second as ## => '
echo "Press <Enter> when you want to set the time to $month/$day/$year $hour:$minute:$second"
# set date and time, and fix hwclock
date -s "$month/$day/$year $hour:$minute:$second"
echo 'System time is set. Settings will be in full effect on next reboot.'
You don't have to use the whole script, if you don't need to prompt the user.