How To Set or Change Timezone on CentOS 7

Checking the Current Timezone

In CentOS and other modern Linux distros, you can use the timedatectl command to display and set the current system’s time and timezone.

Changing Timezone in CentOS

Before changing the timezone, you’ll need to find out the long name for the timezone you want to use. The timezone naming convention usually uses a “Region/City” format.

To list all available time zones, you can either list the files in the /usr/share/zoneinfo directory or use the timedatectl command.

timedatectl list-timezones
...
America/Tijuana
America/Toronto
America/Tortola
America/Vancouver
America/Whitehorse
America/Winnipeg
...

Once you identify which time zone is accurate to your location, run the following command as sudo user:

sudo timedatectl set-timezone your_time_zone

For example, to change the system’s timezone to America/Toronto:

sudo timedatectl set-timezone America/Toronto

Run the timedatectl command to verify the changes:

How can I connect to linux vps/server?

How to Connect PuTTY

  1. Download Putty ; https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html 
  2. Launch the PuTTY SSH client, then enter your server’s SSH IP and SSH Port. Click the Open button to proceed.
    The main menu of PuTTY SSH client
  3. login as: message will pop-up and asks you to enter your SSH username. For VPS and Server users, this is usually root.  After entering your username, press Enter.
  4. Type your SSH password and press Enter again. For security reasons, the screen won’t show the password but will register what you type.
    Connecting to your server via PuTTY

Congratulations! You have successfully connected to your account using the PuTTY SSH client. You can list all available SSH commands by executing help via the terminal.

How to Install Nginx on CentOS 7

Nginx pronounced engine x is a free, open-source, high-performance HTTP and reverse proxy server responsible for handling the load of some of the largest sites on the Internet.

Nginx can be used as a standalone web server, and as a reverse proxy for Apache and other web servers.

Compared to Apache, Nginx can handle a much large number of concurrent connections and has a smaller memory footprint per connection.

This tutorial will teach you how to install and manage Nginx on your CentOS 7 machine.

Prerequisites

Before starting with the tutorial, make sure you are logged in as a user with sudo privileges and you don’t have Apache or any other service running on port 80 or 443.

Installing Nginx on CentOS

Follow the steps below to install Nginx on your CentOS server:

  • Nginx packages are available in the EPEL repositories. If you don’t have EPEL repository already installed you can do it by typing:

 

sudo yum install epel-release

Resetting the Root Password in CentOS 8

  • Restart the server and press the e button in the GRUB start menu to edit the startup entry.
  • Add the following parameters at the end of the line starting with linux ($root)/:

rd.break enforcing=0

  • The line should now look something like this:

linux ($root)/vmlinuz-4.18.0-80.11.2.el8_0.x86_64 root=/dev/mapper/centos-root\ ro crashkernel=auto resume=/dev/mapper/centos-swap rd.lvm.lv=centos/root rd.l\ vm.lv=centos/swap rd.break enforcing=0

The parameter rd.break causes the boot process to be interrupted before control is passed from initramfs to systemd. This allows the initramfs prompt to be used for command input, and the parameter enforcing=0 puts SELinux in permissive mode. This saves the later – and possibly very time-consuming – relabeling of the file system, which would be necessary if SELinux were switched off.

  • Press Ctrl+x to boot the system with the changed parameters, and the switch_root prompt of initramfs will be displayed.
  • Since the filesystem under /sysroot/ is mounted with read-only permissions, you must first remount it with write permissions:

switch_root:/# mount -o remount,rw /sysroot

  • Now switch to a chroot environment:

switch_root:/# chroot /sysroot

The prompt changes to sh-4.4#.

  • Now you can change the password via passwd:

sh-4.4# passwd
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

touch /.autorelabel

  • To leave the chroot environment, type the following command:

exit

  • Reboot the server. To do this, enter the following command:

reboot