Search the Catalog
Learning Debian GNU/Linux

Learning Debian GNU/Linux

By Bill McCarty
1st Edition September 1999
1-56592-705-2, Order Number: 7052
360 pages, $34.95 , Includes CD-ROM


Previous: 7.4 Viewing System Messages and Logs Chapter 7
Configuring and Administering Linux
Next: 8. Using Linux Applications and Clients
 

7.5 Setting the System Time and Time Zone

Linux provides commands that let you set the current system date and time and the system time zone.

7.5.1 Setting the Current System Date and Time

To display the current system time, enter the date command:

debian:~# date
Fri Jul 30 02:28:22 PDT 1999

To set the current system time, use the following form of the date command:

date 
MMDDhhmm[
CC]
YY[.
ss]

The parts of the command argument have the following meanings:

MM

A two-digit month, 01-12.

DD

A two-digit day of month, 01-31.

hh

A two-digit hour, 00-24.

mm

A two-digit minute, 00-59.

CC

An optional two-digit century; for example, 19 or 20.

YY

A two-digit year; for example, 99 or 00.

ss

An optional two-digit second, 00-59.

The command displays the time you enter and then sets the system time:

debian:~# date 073010411999
Fri Jul 30 10:41:00 PDT 1999

When you power down or reboot your system, the system date and time will revert to the values held in non-volatile (CMOS) memory. To store the Linux date and time in CMOS, issue the following command:

hwclock --systohc

If you set your clock to UTC rather than local time, issue the command:

hwclock --systohc --utc

7.5.2 Setting the Time Zone

To set the time zone, use the tzconfig command. The command initiates a dialog that displays the current time zone and asks if you want to change it. If you reply yes, the command prompts you to choose from a list of geographical areas and then cities. Based on your choices, the command sets and displays the current time zone. A typical dialog resembles the following:

debian:~# 

tzconfig
Your current time zone is set to US/Pacific
Do you want to change that? [n]: 

y

Please enter the number of the geographic area in which you live:

      1) Africa                     7) Australia
      2) America                    8) Europe
      3) US time zones              9) Indian Ocean
      4) Canada time zones          10) Pacific Ocean
      5) Asia                       11) Use System V style time zones
      6) Atlantic Ocean             12) None of the above

Then you will be shown a list of cities which represent the time zone
in which they are located. You should choose a city in your time zone.

Number: 

2

Adak Anchorage Anguilla Antigua Araguaina Aruba Asuncion Atka Barbados
Belem Belize Bogota Boise Buenos_Aires Cancun Caracas Catamarca Cayenne
Cayman Chicago Chihuahua Cordoba Costa_Rica Cuiaba Curacao Dawson
Dawson_Creek Denver Detroit Dominica Edmonton El_Salvador Ensenada
Fort_Wayne Fortaleza Glace_Bay Godthab Goose_Bay Grand_Turk Grenada
Guadeloupe Guatemala Guayaquil Guyana Halifax Havana Indiana/Indianapolis
Indiana/Knox Indiana/Marengo Indiana/Vevay Indianapolis Inuvik Iqaluit
Jamaica Jujuy Juneau Knox_IN La_Paz Lima Los_Angeles Louisville Maceio
Managua Manaus Martinique Mazatlan Mendoza Menominee Mexico_City Miquelon
Montevideo Montreal Montserrat Nassau New_York Nipigon Nome Noronha Panama
Pangnirtung Paramaribo Phoenix Port-au-Prince Port_of_Spain Porto_Acre
Porto_Velho Puerto_Rico Rainy_River Rankin_Inlet Regina Rosario Santiago
Santo_Domingo Sao_Paulo Scoresbysund Shiprock St_Johns St_Kitts St_Lucia
St_Thomas St_Vincent Swift_Current Tegucigalpa Thule Thunder_Bay Tijuana
Tortola Vancouver Virgin Whitehorse Winnipeg Yakutat Yellowknife

Please enter the name of one of these cities or zones
You just need to type enough letters to resolve ambiguities
Press Enter to view all of them again
Name []: 

Los_Angeles
Your default time zone is set to 'America/Los_Angeles'.
Local time is now:      Fri Jul 30 02:26:32 PDT 1999.
Universal Time is now:  Fri Jul 30 09:26:32 UTC 1999.


Previous: 7.4 Viewing System Messages and Logs Learning Debian GNU/Linux Next: 8. Using Linux Applications and Clients
7.4 Viewing System Messages and Logs Book Index 8. Using Linux Applications and Clients

Back to: Learning Debian GNU/Linux


oreilly.com Home | O'Reilly Bookstores | How to Order | O'Reilly Contacts
International | About O'Reilly | Affiliated Companies | Privacy Policy

© 2001, O'Reilly & Associates, Inc.