Learn Basic System Configuration on the Command Line in Oracle Linux

5
1
Send lab feedback

Learn How to Localize Your Installation on Oracle Linux

Introduction

Many Oracle Linux systems are installed without a desktop environment. However, multiple ways of using the command line are available to configure base system settings, such as the system hostname.

This tutorial describes how to configure the system hostname, locale, language, and date and time from the command line. This tutorial is targeted at users of Oracle Linux or later.

Objectives

Upon completion of this Lab you will be able to:

  • Set the system host name
  • Set the system locale and system language
  • Set the system date, time and time zone

Prerequisites

  • Any system with Oracle Linux

Update the System Hostname

Note: When using the free lab environment, see Oracle Linux Lab Basics for connection and other usage instructions.

In other distributions, configuring the system hostname typically involves editing system files, such as /etc/hostname and /etc/hosts, running the hostname command to set the hostname, and rebooting the system. With Oracle Linux, the process is simplified through the hostnamectl command.

  1. Review the static and transient hostnames for your Oracle Linux system:

    sudo hostnamectl

    Note: The static hostname is the default host name for the system and is configured in the /etc/hostname file. The transient hostname represents the name that is set for the system by services such as DHCP or mDNS after a system boot. If the transient hostname is not set, the system uses the static hostname.

  2. Set the static hostname:

    sudo hostnamectl set-hostname myoracle.oraclehost
  3. You can also set a "pretty" hostname for your own reference:

    sudo hostnamectl set-hostname --pretty "My Oracle Linux Server"

    Note: A pretty hostname is a friendly free-form system name that is displayed in user interface environments. Normally, the transient hostname and the pretty hostname are identical. However, with the hostnamectl command, you can set different values for each.

Update the System Locale and Language

Use the localectl command to set the default system locale and language settings. The command handles the generation of locale information and sets the default values for users when they log into the system, either throught the command line or on a desktop environment. The command can also be used to set default keyboard mappings for both the command line and the desktop environment.

  1. Review the current system locale:

    sudo localectl
  2. List every locale that is available:

    sudo localectl list-locales
  3. Set the locale to British English and UTF-8 encoding:

    sudo localectl set-locale en_GB.utf8

    Note: The system locale defines the language and character set encoding used for presentation of information on a terminal and on many GUI applications as well. Locale options are usually listed in the following format LANGUAGE_COUNTRY.CODESET[@MODIFIERS]. The LANGUAGE is an ISO 639 language code, for example en for English; COUNTRY is an ISO 3166 country code, for example GB for Great Britain and the United Kingdom; CODESET is the character set or encoding, for example utf-8. Thus, in this example, the locale is en_GB.utf8.

  4. List every keymap that is available. Press the q key to exit:

    sudo localectl list-keymaps
  5. Set the keymap to British English:

    sudo localectl set-keymap gb
  6. Test that the changes have been applied by typing into the terminal window. If you are using a US English qwerty keyboard, then the " and @ keys should have swapped places.

  7. You can now change the locale settings for your system to reflect your own localization preferences.

Note: A locale can also be configured for a specific sessions or user. For session-based configurations, set the LANG environment variable. For user-based configurations, set the LANG variable on the user's profile or shell configuration. Thus, the environment variable is set each time a user logs into the system.

Update the System Date and Time

Use the timedatectl command to set the system date and time. The command updates the real time clock (RTC), also known as the hardware clock, as well as the system clock that is maintained by the system kernel.

  1. Review the current system date and time configuration:

    sudo timedatectl
  2. List all system time zones. Press the q key to exit:

    sudo timedatectl list-timezones
  3. Search for your time zone, using underscores for compound names. For example, to find Pacific Daylight Time (PDT):

    sudo timedatectl list-timezones | grep 'Los_Angeles'
  4. Set your time zone:

    sudo timedatectl set-timezone America/Los_Angeles
  5. Manually set the day and time:

    sudo timedatectl set-time '2100-01-01 00:00:00'

    Note: If the NTP service is set to active, your system's date and time are automatically synchronized with the configured NTP server. In that scenario, you cannot directly modify the date or time on your system.

For More Information

Learn how to use chrony to synchronize the system date and time over the network: https://docs.oracle.com/en/learn/config_chrony_linux_8/

The video demonstration and tutorial provided at https://www.youtube.com/watch?v=q8VlYiF5sx8 is also useful if you need more information on configuring the date and time from the command line interface.

SSR