Wednesday, 5 February 2020

CentOS 8

ip a / ip address     #show ip address
nmtui     #NetworkManager TUI
nmcli d     #NetworkManager device
 
yum install epel-release
yum update
yum install dnf
yum install vim
dnf install chrony

yum install iftop htop telnet tmux     #iftop -i eth0   #telnet only for test tcp port

yum install nc    #nc -z -v -u 192.168.10.12 161   #nc for test udp port

yum install traceroute
yum install nmap     #nmap -sU 192.168.10.12 to scan udp port
yum install iperf3
yum install bind-utils     #dig

yum install httpd
yum install mariadb-server
dnf install php php-opcache php-gd php-curl php-mysqlnd


#####################################################
Network interface configuration file:
[root@PacketFence-ZEN ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens160
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static     #or none/dhcp
DEFROUTE=yes     #yes: This interface is set as the default route for IPv4|IPv6 traffic.
IPV4_FAILURE_FATAL=no     #no: This interface is not disabled if configuration fails.
IPV6INIT=yes     #yes: Enable IPv6 on this interface.
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens160
UUID=27f5f975-99f0-444d-a2f0-2e0a039810d3
DEVICE=ens160
ONBOOT=yes     yes: This interface is activated at boot time.
HWADDR=08:00:29:5b:85:77
IPADDR=10.10.10.79
PREFIX=24
GATEWAY=10.10.10.1
DNS1=8.8.8.8
DNS2=8.8.4.4

[root@PacketFence-ZEN ~]# vim /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1              localhost localhost.localdomain localhost6 localhost6.localdomain6
1.2.3.4 www.google.com

[root@PacketFence-ZEN ~]# vim /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4

[root@PacketFence-ZEN ~]# vim /etc/sysconfig/network  #This file specifies global network settings
GATEWAY=10.10.10.1

Restart Network Services:
systemctl restart NetworkManager
nmcli networking off; nmcli networking on

#####################################################

NTP:
dnf install chrony
systemctl enable chronyd
vim /etc/chrony.conf
    allow 192.168.0.0/16     #If want to set Chrony to act as an NTP server for a local network.
    Server 192.168.1.150     #if want to set Chrony to act as an NTP client.
systemctl restart chronyd
firewall-cmd --permanent --add-service=ntp
firewall-cmd --reload
chronyc sources     #Check for NTP server sources.

timedatectl   #Read clock, RTC(hardware clock)
timedatectl set-local-rtc 1   #change the hardware clock time standard to localtime
timedatectl set-local-rtc 0   #revert to the hardware clock being in UTC
timedatectl set-timezone Asia/Kuala_Lumpur
timedatectl set-ntp yes
timedatectl set-ntp on
yum install ntp
ntpq -p
hwclock
ntpdate pool.ntp.org
ntpdate -u pool.ntp.org
logfile /var/log/ntp.log   #If you logfile
ss -atun | grep 123   #check if ntpd daemon is listening on it’s port


#####################################################

TMUX:
[root@centos8 ~]# tmux     #Creating sequence name Tmux Sessions
[root@centos8 ~]# tmux new -s session_name     #Creating Named Tmux Sessions
Ctrl+b d     #Detaching from Tmux Session
[root@centos8 ~]# tmux ls     #list all Tmux Session
[root@centos8 ~]# tmux attach-session -t 0     #Re-attaching to Tmux Session
Ctrl+b %     #Split current pane horizontally into two panes
Ctrl+b "     #Split current pane vertically into two panes
Ctrl+b o     #toggle between panes
 
#####################################################


yum install net-snmp net-snmp-utils

systemctl enable snmpd
vim /etc/snmp/snmpd.conf
    com2sec notConfigUser  default       <CommunityName>
    group   notConfigGroup v2c           notConfigUser
    view    allview       included   .1
    access  notConfigGroup ""      any       noauth    exact  allview none none
systemctl restart snmpd

  

RHEL 8 / CentOS 8 recover root password

https://linuxconfig.org/redhat-8-recover-root-password

1. Boot to the GRUB menu and enter the edit mode. Use your arrows to navigate to the the menu item you would normally boot your RHEL 8 Linux system from. Press e to start editing the selected menu item.


2. Perform a break at an early stage of the boot process by typing rd.break at the end of the line starting with kernel=. Once ready press CTRL+X to start the RHEL 8 boot process.


3. Check write access on the /sysroot mount point. By default this mount point is mounted only with the read-only (ro) access. Execute:
switch_root:/# mount | grep sysroot


 4. Remount the sysroot directory with read & write access. To do so execute:
switch_root:/# mount -o remount,rw /sysroot/
switch_root:/# mount | grep sysroot



5. Enter chroot system by executing:
switch_root:/# chroot /sysroot

6. Use the passwd command to set a new root password. Please note that when typing a new password the characters you type will not be visible. Simply keep typing.



7. Force file-system relabeling by executing the following command:
# touch /.autorelabel



 8. Exit the chroot system by executing the exit command:
# exit




9. Logout to continue the normal boot:
switch_root:/# logout




10. Wait for the file-system relabeling to complete. Depending on your system speed and number of files this might take some time. Be patient.

11. Login with your new root password.















  

Tuesday, 4 February 2020

CentOS 7 Yum Repo

yum --disablerepo=\* --enablerepo=base,updates update