System Time and Date command in Red Hat and it perimeters

System Time and Date command in Red Hat and it perimeters

In Red Hat-based Linux distributions, you can use the date command to display or set the system’s date and time. Here’s how you can use the date command and its parameters, along with some examples:

ParameterDescriptionExample
+%Y-%m-%dPrint year-month-day formatdate +%Y-%m-%d
+%H:%M:%SPrint hour:minute:second formatdate +%H:%M:%S
+%APrint full weekday namedate +%A
+%BPrint full month namedate +%B
+%ZPrint timezone namedate +%Z
--setSet the system date and time (requires root privileges)sudo date --set="2023-08-25 15:30:00"
--helpDisplay help information for the date commanddate --help

Examples:

  1. Display the current date in the “year-month-day” format:
Bash
   date +%Y-%m-%d
  1. Display the current time in the “hour:minute:second” format:
Bash
   date +%H:%M:%S
  1. Display the current full weekday name:
Bash
   date +%A
  1. Display the current full month name:
Bash
   date +%B
  1. Display the current timezone:
Bash
   date +%Z
  1. Set the system date and time (requires root privileges):
Bash
   sudo date --set="2023-08-25 15:30:00"

Remember that setting the system date and time requires administrative privileges (sudo), and incorrect changes can potentially disrupt your system’s functioning. Always be cautious when using these commands, especially in a production environment.

Exit mobile version