Useful shortcuts for vi editor

Showing posts with label centos. Show all posts
Showing posts with label centos. Show all posts

Thursday 3 January 2019

How to fix "connection refused" error?

Error
e.g.
The connection to the server 10.10.10.10:6443 was refused - did you specify the right host or port?

Solution
On kubernetes control nodes, try to "stop/start" docker service
# service docker restart
or
# systemctl restart docker

Thursday 1 November 2018

How to change timezone?

-> Determine your timezone
# cd /usr/share/zoneinfo
# tzselect
e.g.
Europe/Istanbul

-> Remove current localtime soft link
# rm /etc/localtime 

-> Define your localtime soft link as new
# ln -s /usr/share/zoneinfo/Europe/Istanbul /etc/localtime

-> Check your latest timezone setting
# timedatectl

Thursday 4 October 2018

How to setup/configure/use mailx for Office365 account?

-> Update the OS
# yum -y update
or (y -> yes)
# yum update

-> Install mailx
# yum install -y mailx

-> Define soft link to use "email" the command
# ln -s /bin/mailx /bin/email

-> Prepare config file
# vi /etc/mail.rc
set smtp=outlook.office365.com
set smtp-auth-user=alper@alper.com
set smtp-auth-password=alper123
set ssl-verify=ignore
set nss-config-dir=/etc/pki/nssdb/
set smtp-use-starttls
set from="alper@alper.com(Alper Ozsoyler)"

-> Try to send an email to yourself
# echo "Your message is my message!" | email -v -s "Message Subject is Bla Bla" alper@alper.com

Ref: https://gist.github.com/ilkereroglu/aa6c868153d1c5d57cd8

Thursday 9 August 2018

How to check linux operating system info?

-> show kernel version and other info
# uname -a

-> show machine info
hostnamectl

-> show specific release version
# rpm --query centos-release 

How to check available yum packages?

e.g. install/update ansible by yum

-> Go to repo path

# cd /etc/yum.repos.d/

-> Add source paths into repo file to be able to install ansible

# vi epel.repo
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

[epel-debuginfo]

name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debug
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1

[epel-source]

name=Extra Packages for Enterprise Linux 7 - $basearch - Source
#baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMS
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1

-> Search yum package
yum search ansible

-> Check available yum package
# yum list available | grep ansible

-> Check available all yum packages with its duplicates
yum list available --showduplicates | grep ansible

-> Install ansible 
# yum install ansible

-> Download only yum package
yum install ansible --downloadonly --downloaddir=/root

-> Check available yum packages for upgrade
yum check-updates | grep ansible

-> Update ansible

yum update ansible

-> Check yum history
yum history list

Wednesday 18 July 2018

How to change service name?

e.g.
current service name: postgresql.service
desired service name: postgresql-9.1.service

Run following commands to change service name;

Step 1: Stop current service
# systemctl stop postgresql.service
# systemctl daemon-reload

Step 2: Change service name
# cd /usr/lib/systemd/system
# mv postgresql.service postgresql-9.1.service

Step 3: Start and enable new service
# systemctl start postgresql-9.1.service
# systemctl enable postgresql-9.1.service

Step 4: Check service status:
# systemctl status postgresql-9.1.service

Step 5: Make sure that service runs properly
# journalctl -u postgresql-9.1.service