Where Online Learning is simpler!



$ whatis date

date date (1) - print or set the system date and time

  1. date

How to use the date command to change the system date and time?

In this example below, I am showing you some of the ways you can change the system date and time locally . Please understand that in order for the system date to automatically synchronized with accurate date and time, you need to configure your system with Network Time Protocol Daemon (ntpd). The Network Time Protocol Daemon (ntpd), Network Time Protocol Query (ntpq) and other related commands are explained in Chapter 4 under the "Advanced UNIX commands".

Here, I use the date command to find out the date and time.

$ date

Saturday, March 12, 2011 08:10:42 PM PST

In order to change the system date and time, I need to have root access, so I become root to run the date command and change the system date and time.

$ su -

Password:

Oracle Corporation SunOS 5.11 snv_151a November 2010

I use the date command as root to know what is the current system date and time is.

# date

Saturday, March 12, 2011 08:10:48 PM PST

Now, I change the time only to 8:16 pm from 8:10 pm.

# date 0312201611

Saturday, March 12, 2011 08:16:00 PM PST

Here, I change only the year to 2010.

# date 0312201611

Friday, March 12, 2010 08:16:00 PM PST

Now, I change the month only to January.

# date 0312201610

Tuesday, January 12, 2010 08:16:00 PM PST

Here, I change the date to January 1, 2011 for same time.

# date 0101201611i

Saturday, January 1, 2011 08:16:00 PM PST

At this time, I want to change the date and time to correct date that I like to set it which is the below date and time.

# date 0312201711

Saturday, March 12, 2011 08:17:00 PM PST

# date

Saturday, March 12, 2011 08:17:01 PM PST


Please click on " Please click on " man date " to see the Manual Page for this command.


Previous Home Page Next



Contact us     |      About us     |      Term of use      |      Copyright © 2000-2025 MyWebUniversity.com ™