Quick tips

CentOS7

change hostname

hostnamectl status

[donhk@localhost ~]$ hostnamectl status
Static hostname: localhost.localdomain
Icon name: computer-laptop
Chassis: laptop
Machine ID: b6f94b45aa6c4b0d85f94c7b24db1b4c
Boot ID: 57fce336491f4da9ad1db3831846a0e3
Operating System: Oracle Linux Server 7.4
CPE OS Name: cpe:/o:oracle:linux:7:4:server
Kernel: Linux 4.1.12-112.16.4.el7uek.x86_64
Architecture: x86-64

[donhk@localhost ~]$ sudo hostnamectl set-hostname server
[donhk@localhost ~]$ hostnamectl status
Static hostname: server 
Icon name: computer-laptop 
Chassis: laptop 
Machine ID: b6f94b45aa6c4b0d85f94c7b24db1b4c 
Boot ID: 57fce336491f4da9ad1db3831846a0e3 
Operating System: Oracle Linux Server 7.4 
CPE OS Name: cpe:/o:oracle:linux:7:4:server 
Kernel: Linux 4.1.12-112.16.4.el7uek.x86_64 
Architecture: x86-64

disable firewall

sudo systemctl stop firewalld     #stopt it
sudo systemctl disable firewalld  #do not start it up on boot

change ssh port

sudo vi /etc/ssh/sshd_config

# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
Port 2244
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

sudo semanage port -a -t ssh_port_t -p tcp 2244

sudo systemctl restart sshd

install ufw

yum install -y epel-release 
yum install -y ufw