Configure New timezone Permanently in bash

centos

In the realm of Linux server administration, managing time settings is a critical aspect that directly impacts system synchronization and overall functionality.

Whether you’re a seasoned Ubuntu administrator or a novice looking to enhance your server configuration skills, this guide is tailored to help you efficiently and effectively set up and maintain the desired timezone on your Ubuntu server.

Configuration

$ timedatectl list-timezones
output omitted...
Asia/Kolkata
Asia/Krasnoyarsk
Asia/Kuala_Lumpur
Asia/Kuching
Asia/Kuwait
Asia/Macau
output omitted...
$ sudo timedatectl set-timezone Asia/Kuala_Lumpur

Explanation

  1. list-timezones is to list all supported time zone by timedatectl
  2. set-timezone Asia/Kuala_Lumpur is to make your system to follow Kuala Lumpur’s timezone

X11 forwarding after sudo

centos
$ xauth list
<hostname>/unix:0 MIT-MAGIC-COOKIE-1 1fb2c048e3a32a3fe013c565b8422727
<hostname>/unix:12 MIT-MAGIC-COOKIE-1 29b9ba4a72136095e43540119c8da384
<hostname>/unix:11 MIT-MAGIC-COOKIE-1 99b08ccb7e8a76e75c70d7c75723505d
<hostname>/unix:10 MIT-MAGIC-COOKIE-1 b2ea07f58365b8672bea7497ffacee4f

Then execute, change user as root with sudo -i and execute xauth add followed by one entry from above output that having the highest number.

$ sudo -i
# xauth add <hostname>/unix:12 MIT-MAGIC-COOKIE-1 29b9ba4a72136095e43540119c8da384

Explanation

  1. xauth list being executed before sudoing to root to output the xauth authorization hex key
  2. after sudo as root, xauth add to add the authorization hex key from non-root into root

Installing X11 for X11 forwarding

centos
$ sudo yum install -y xorg-x11-server-common
$ sudo yum install -y  xorg-x11-xauth

Then logout, login from your shell and execute your X windows application.

Explanation

  1. xorg-x11-server-common is needed for every common file needed in x11
  2. xorg-x11-xauth is needed for X11 authorization utilities

Open firewalld permanently in CentOS 7

centos

CentOS 7 was shipped together with firewalld which a layer above iptables.

Unlike iptables, no rc.local need to be update to make sure a permanent firewall configuration with firewalld.


Command

  • To permanently open TCP port 80
    $ sudo firewall-cmd --permanent --zone=public --add-port=80/tcp
  • The port is yet to open, unless we reboot the machine, else just reload service
    $ sudo firewall-cmd --reload
  • Make sure port open correctly by listing all allowed port/service
    $ firewall-cmd --list-all