Thursday, November 12, 2015

Linux : Red Hat 7 commands and configuration files

1 System Locale and Keyboard Configuration

/etc/locale.conf

# cat /etc/locale.conf
LANG="en_US.UTF-8"

# localectl status
   System Locale: LANG=en_US.UTF-8
       VC Keymap: us
      X11 Layout: us

# localectl list-locales

# localectl set-locale LANG=locale

# localectl list-keymaps

# localectl set-keymap map

2 Configuring the Date and Time

A real-time clock (RTC), a hardware clock (on the system board)
A system clock, a software clock, maintained by the kernel

timedatectl

# timedatectl
      Local time: Thu 2015-11-12 14:17:33 EST
  Universal time: Thu 2015-11-12 19:17:33 UTC
        RTC time: Thu 2015-11-12 19:15:33
        Timezone: America/New_York (EST, -0500)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: no
 Last DST change: DST ended at
                  Sun 2015-11-01 01:59:59 EDT
                  Sun 2015-11-01 01:00:00 EST
 Next DST change: DST begins (the clock jumps one hour forward) at
                  Sun 2016-03-13 01:59:59 EST
                  Sun 2016-03-13 03:00:00 EDT

If changes to the configuration of chrony or ntpd tools, enter the following command:
systemctl restart systemd-timedated.services

timedatectl set-time HH:MM:SS

This command updates both the system time and the hardware clock. The result is similar to using both date --set and hwclock --systohc commands.

 By default, the system is configured to use UTC. To configure your system to maintain the clock in the local time, run the timedatectl command with the set-local-rtc option as root:

timedatectl set-local-rtc boolean

To configure your system to maintain the clock in the local time, replace boolean with yes (or, alternatively, y, true, t, or 1). To configure the system to use UTC, replace boolean with no (or, alternatively, n, false, f, or 0). The default option is no.

 To change the current date, type the following at a shell prompt as root:

timedatectl set-time YYYY-MM-DD

Note that changing the date without specifying the current time results in setting the time to 00:00:00.

timedatectl set-time 'YYYY-MM-DD HH:MM:SS'

timedatectl list-timezones

To change the currently used time zone, type as root:

timedatectl set-timezone time_zone

To enable automatic synchronization of the system clock with a remote server, type:

~]# timedatectl set-ntp yes

 To display the current date and local time, type the following at a shell prompt:

~]$ date
Mon Sep 16 17:30:24 CEST 2013

To display the current date and time in UTC, type the following at a shell prompt:

~]$ date --utc
Mon Sep 16 15:30:34 UTC 2013

To customize the output of the date command, type:

~]$ date +"%Y-%m-%d %H:%M"
2013-09-16 17:30

 To change the current time, run the date command with the --set or -s option as root:

date --set HH:MM:SS

Replace HH with an hour, MM with a minute, and SS with a second, all typed in two-digit form.
By default, the date command sets the system clock to the local time. To set the system clock in UTC, run the command with the --utc or -u command line option:

date --set HH:MM:SS --utc

 To change the current date, run the date command with the --set or -s option as root:

date --set YYYY-MM-DD

Replace YYYY with a four-digit year, MM with a two-digit month, and DD with a two-digit day of the month.
Note that changing the date without specifying the current time results in setting the time to 00:00:00.

To change the current date to 2 June 2013 and keep the current time (11:26 p.m.), run the following command as root:

~]# date --set 2013-06-02 23:26:00

 hwclock is a utility for accessing the hardware clock, also referred to as the Real Time Clock (RTC). The hardware clock is independent of the operating system you use and works even when the machine is shut down. This utility is used for displaying the time from the hardware clock. hwclock also contains facilities for compensating for systematic drift in the hardware clock.
The hardware clock stores the values of: year, month, day, hour, minute, and second. It is not able to store the time standard, local time or Coordinated Universal Time (UTC), nor set the Daylight Saving Time (DST).
The hwclock utility saves its settings in the /etc/adjtime file, which is created with the first change you make, for example, when you set the time manually or synchronize the hardware clock with the system time.

 Running hwclock with no command line options as the root user returns the date and time in local time to standard output.

hwclock

 When you need to change the hardware clock date and time, you can do so by appending the --set and --date options along with your specification:

hwclock --set --date "dd mmm yyyy HH:MM"

 At the same time, you can also set the hardware clock to keep the time in either UTC or local time by adding the --utc or --localtime options, respectively. In this case, UTC or LOCAL is recorded in the /etc/adjtime file.

If you want to set the date and time to a specific value, for example, to "21:17, October 21, 2014", and keep the hardware clock in UTC, run the command as root in the following format:

~]# hwclock --set --date "21 Oct 2014 21:17" --utc

 You can synchronize the hardware clock and the current system time in both directions.

    Either you can set the hardware clock to the current system time by using this command:

    hwclock --systohc

    Note that if you use NTP, the hardware clock is automatically synchronized to the system clock every 11 minutes, and this command is useful only at boot time to get a reasonable initial system time.
    Or, you can set the system time from the hardware clock by using the following command:

    hwclock --hctosys

When you synchronize the hardware clock and the system time, you can also specify whether you want to keep the hardware clock in local time or UTC by adding the --utc or --localtime option. Similarly to using --set, UTC or LOCAL is recorded in the /etc/adjtime file.
The hwclock --systohc --utc command is functionally similar to timedatectl set-local-rtc false and the hwclock --systohc --local command is an alternative to timedatectl set-local-rtc true.

 To set the hardware clock to the current system time and keep the hardware clock in local time, run the following command as root:

~]# hwclock --systohc --localtime

To avoid problems with time zone and DST switching, it is recommended to keep the hardware clock in UTC

No comments:

Post a Comment