CentOS

CentOS
https://www.centos.org/docs/5/html/
https://wiki.centos.org/
https://wiki.centos.org/HowTos/Oracle12onCentos7
https://docs.oracle.com/database/121/index.html

CentOS version
cat /etc/centos-release
hostnamectl
rpm --query centos-release

CentOS setup
# pciutils (for running lspci)
# xorg-x11-server-utils (for running xrandr)
yum install -y nano mlocate wget zip unzip xorg-x11-drv-vesa pciutils xorg-x11-server-utils

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# --nogpgcheck Run with GPG signature checking disabled
yum localinstall -y epel-release-latest-7.noarch.rpm
# or directly:
yum install epel-release

grep -nri rhgb /etc/
sed -i s/"rhgb quiet"/"text"/ /etc/default/grub

the only one working (after second boot) with CentOS on VMWare 12.1.0 on ASRock with Intel N3150
yum -y groups install "MATE Desktop"
echo "exec /usr/bin/mate-session" > ~/.xinitrc
startx

RedHat

Red Hat
http://developers.redhat.com/blog/2016/03/31/no-cost-rhel-developer-subscription-now-available/
http://developers.redhat.com/products/rhel/get-started/#tab-vmware
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/

show OS version
lsb_release -a

Red Hat setup
https://linuxconfig.org/rhel-7-solution-to-there-are-no-enabled-repos-message
mkdir /media/rhel7-repo-iso
# VMware: make sure Device Status checkbox named Connected is checked!
mount /dev/cdrom /media/rhel7-repo-iso/
# or mount the iso file:
mount -o loop /root/rhel-server-7.1-x86_64-dvd.iso /media/rhel7-repo-iso/
# create the repo file:
touch /etc/yum.repos.d/RHEL_7_Disc.repo
# fill in the following content:
cat /etc/yum.repos.d/RHEL_7_Disc.repo
[RHEL_7_Disc] -> make sure to be unique among /etc/yum.repos.d/*.repo
name=RHEL_7_x86_64_Disc
baseurl="file:///media/rhel7-repo-iso/"
gpgcheck=0
enabled=1
# view the new repository:
yum repolist
# clear the related caches:
yum clean all
subscription-manager clean
#
# see https://adrhc.go.ro/wordpress/redhat-centos/
# do My CentOS setup
# do Nux Dextop
# no desktop will work with VMWare 12.1.0 on ASRock with Intel N3150 (including MATE Desktop) but XFCE with xrdp will work!
#
# Now you will be able to install new software on your unregistered RHEL 7 linux box.
yum group list hidden | grep -iP "GNOME|KDE|MATE|XFCE|Cinnamon"
yum -y groups install "Xfce"

remote desktop
# Install first EPEL and Nux Desktop repositories.
# http://www.itzgeek.com/how-tos/linux/centos-how-tos/install-xrdp-on-centos-7-rhel-7.html
yum -y install xrdp tigervnc-server
firewall-cmd --permanent --zone=public --add-port=3389/tcp
firewall-cmd --reload
chcon --type=bin_t /usr/sbin/xrdp
chcon --type=bin_t /usr/sbin/xrdp-sesman
systemctl start xrdp.service
netstat -antup | grep xrdp
systemctl enable xrdp.service
Replace ". /etc/X11/..." with "startxfce4" in /etc/xrdp/startwm.sh.
sudo sed -i s/"\. \/etc\/X11\/Xsession"/"#\. \/etc\/X11\/Xsession\n\tstartxfce4"/ /etc/xrdp/startwm.sh
sudo sed -i s/"\. \/etc\/X11\/xinit\/Xsession"/"#\. \/etc\/X11\/Xsession\n\tstartxfce4"/ /etc/xrdp/startwm.sh
sudo sed -i s/"\. \/etc\/X11\/xdm\/Xsession"/"#\. \/etc\/X11\/Xsession\n\tstartxfce4"/ /etc/xrdp/startwm.sh
# Make sure you use module “sesman-Xvnc” when conncting with your remote desktop client.

missing compat-libstdc++-33 required by Oracle
# https://access.redhat.com/discussions/1182083
yum repolist all
yum-config-manager --enable rhel-7-server-optional-rpms
# anyway it didn't work ...
# so I found it here: https://access.redhat.com/downloads/content/compat-libstdc++-33/3.2.3-72.el7/x86_64/fd431d51/package
wget -O compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm https://access.cdn.redhat.com//content/origin/rpms/compat-libstdc++-33/3.2.3/72.el7/fd431d51/compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm?_auth_=1469872436_8ba1708561e657273933106fa6efbe9b

Oracle and systemd

# http://docs.oracle.com/database/121/index.htm
# https://172.16.148.137:5500/em/login
# start db:
[oracle@redhat7 ~]$ sqlplus / AS SYSDBA
STARTUP
# start TNS listener
[oracle@redhat7 ~]$ lsnrctl start
# TNS listener status
[oracle@redhat7 ~]$ lsnrctl status
cat /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
# stop TNS listener
[oracle@redhat7 ~]$ lsnrctl stop
# TNS listener status
ps -ef | grep [t]nslsnr
# oracle + listener startsqlplus system/Yxx32145 AS SYSDBA
# for this you need the apropiate environment variables in /home/oracle/.bash_profile e.g.:
TMPDIR=$TMP; export TMPDIR
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/12.1.0/dbhome_1; export ORACLE_HOME
ORACLE_SID=orcl; export ORACLE_SID
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/lib64; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
# then allow dbstart in /etc/oratab to start a specific instance:
[root@redhat7 ~]# sed -i s/"N$"/"Y"/ /etc/oratab
[oracle@redhat7 ~]$ $ORACLE_HOME/bin/dbstart $ORACLE_HOME
# oracle status:
ps -ef | grep [o]racle
ps -ef | grep [o]ra_
# oracle status from sqlplus:
[oracle@redhat7 ~]$ sqlplus / AS SYSDBA
select INSTANCE_NAME, STARTUP_TIME, STATUS, ARCHIVER, "THREAD#", LOGINS, INSTANCE_ROLE, ACTIVE_STATE from v$instance;
select SPID as "Process ID" , STID as "Thread ID", PNAME as "Process Name", EXECUTION_TYPE as "Process Type" from v$process order by 4,1,2;
# stop db:
[oracle@redhat7 ~]$ sqlplus / AS SYSDBA
SHUTDOWN IMMEDIATE
# or allow dbstart in /etc/oratab to start a specific instance (stop db + listener):
# see http://docs.oracle.com/database/121/UNXAR/strt_stp.htm#UNXAR417
# see https://oracle-base.com/articles/linux/automating-database-startup-and-shutdown-on-linux
[root@redhat7 ~]# sed -i s/"N$"/"Y"/ /etc/oratab
[oracle@redhat7 ~]$ $ORACLE_HOME/bin/dbshut $ORACLE_HOME
tailf $ORACLE_HOME/startup.log
# list options existing in a response file:
grep -v -P "^#|=$" KIT/Oracle/db.rsp | grep -v "^$"
# Log messages are written to:
/u01/app/oracle/diag/rdbms/orcl/orcl/trace/alert_orcl.log
/u01/app/oracle/diag/rdbms/orcl/orcl/alert/log.xml
find /u01 -name log.xml

# when after normal shutdown oracle processes are still running do a shutdown abort from sqlplus

# show oracle pid (for systemd):
[oracle@redhat7 ~]$ output=$(sqlplus -S / AS SYSDBA <<EOF
select SPID from v\$process where PNAME = 'PMON';sysman
EOF
);echo "$output" | grep -P "\d+"
# or show this way:
ps -e | grep [p]mon_orcl | awk '{print $1;}'

# change $ORACLE_HOME/bin/dbstart in order to show PMON's PID:
	OS_PID=$(sqlplus -S / AS SYSDBA <<EOF
select SPID from v\$process where PNAME = 'PMON';
EOF
)
	OS_PID=$(echo "$OS_PID" | grep -P "\d+")
	echo "$0: ${INST} \"${ORACLE_SID}\" warm started (PID $OS_PID)."
	if [ -d /run/oracle ]; then
		echo "$OS_PID" > /run/oracle/oracle.pid
		echo "created /run/oracle/oracle.pid"
	fi
# or change like this:
	OS_PID=$(ps -e | grep [p]mon_orcl | awk '{print $1;}')
	echo "$0: ${INST} \"${ORACLE_SID}\" warm started (PID $OS_PID)."
	if [ -d /run/oracle ]; then
		echo "$OS_PID" > /run/oracle/oracle.pid
		echo "created /run/oracle/oracle.pid"
	fi
# in order to use dbstart and dbshut with systemd you'll have to also change them 
# so that awk, cat, cut, grep, touch, chmod commands 
# are used with their absolute path (e.g. /bin/cat)

# systemd oracle.service
[Unit]
Description=Oracle 12c
After=local-fs.target
Wants=local-fs.target
[Service]
Type=forking
User=oracle
Group=oinstall
RuntimeDirectory=oracle
PIDFile=/run/oracle/oracle.pid
Restart=on-failure
RestartSec=3
TimeoutSec=0
ExecStart=/u01/app/oracle/product/12.1.0/dbhome_1/bin/dbstart /u01/app/oracle/product/12.1.0/dbhome_1
ExecStop=/u01/app/oracle/product/12.1.0/dbhome_1/bin/dbshut /u01/app/oracle/product/12.1.0/dbhome_1
[Install]
WantedBy=multi-user.target

# all users of the database visible to the current user
select username from all_users order by username;

# tables for schema/user
SELECT DISTINCT OBJECT_NAME FROM ALL_OBJECTS WHERE OBJECT_TYPE = 'TABLE' AND OWNER = 'HR';

# change user's password:
ALTER USER sys IDENTIFIED BY "Yxx32145";
ALTER USER system IDENTIFIED BY "Yxx32145";
sqlplus system/Yxx32145 AS SYSDBA

# Enterprise Manager
# http://www.dba-oracle.com/t_11g_connect_sysdba_ora_01031.htm
sys - allowed to connect AS SYSDBA
system - not allowed to connect AS SYSDBA

CentOS and Oracle

# https://wiki.centos.org/HowTos/Oracle12onCentos7

# rsync -cEhikLmrtz --progress --delete-after KIT/Oracle/linuxamd64_12102_database_se2_* root@172.16.148.136:/root/KIT
# scp KIT/Oracle/linuxamd64_12102_database_se2_* root@172.16.148.137:/root/KIT

# run as root ...
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
passwd oracle

# For Intel N3150 CPU I changed the original "kernel.shmmax = 1987162112" like below.
echo "# oracle kernel parameters
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4093800448
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586" >> /etc/sysctl.conf

# Check and apply the oracle kernel parameters:
# -p Load in sysctl settings from the file specified or /etc/sysctl.conf if none given. 
#    Specifying - as filename means reading data from standard input.
# -a Display all values currently available.
sysctl -p
sysctl -a

# Specify limits for oracle user in the /etc/security/limits.conf
echo "# limits for oracle user
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536" >> /etc/security/limits.conf

yum install -y zip unzip
unzip KIT/linuxamd64_12102_database_se2_1of2.zip -d /stage/
unzip KIT/linuxamd64_12102_database_se2_2of2.zip -d /stage/
chown -R oracle:oinstall /stage/

# Create /u01 directory for Oracle software and /u02 for database files.
mkdir /u01
mkdir /u02
chown -R oracle:oinstall /u01
chown -R oracle:oinstall /u02
chmod -R 775 /u01
chmod -R 775 /u02
chmod g+s /u01
chmod g+s /u02

# Check required packages are installed:
yum list binutils.x86_64 compat-libcap1.x86_64 gcc.x86_64 gcc-c++.x86_64 glibc.i686 glibc.x86_64 glibc-devel.i686 glibc-devel.x86_64 ksh compat-libstdc++-33 libaio.i686 libaio.x86_64 libaio-devel.i686 libaio-devel.x86_64 libgcc.i686 libgcc.x86_64 libstdc++.i686 libstdc++.x86_64 libstdc++-devel.i686 libstdc++-devel.x86_64 libXi.i686 libXi.x86_64 libXtst.i686 libXtst.x86_64 make.x86_64 sysstat.x86_64

# Install missing required packages:
yum install -y binutils.x86_64 compat-libcap1.x86_64 gcc.x86_64 gcc-c++.x86_64 glibc.i686 glibc.x86_64 glibc-devel.i686 glibc-devel.x86_64 ksh compat-libstdc++-33 libaio.i686 libaio.x86_64 libaio-devel.i686 libaio-devel.x86_64 libgcc.i686 libgcc.x86_64 libstdc++.i686 libstdc++.x86_64 libstdc++-devel.i686 libstdc++-devel.x86_64 libXi.i686 libXi.x86_64 libXtst.i686 libXtst.x86_64 make.x86_64 sysstat.x86_64

# Also install the "X Window System" package group (already included with GNOME, KDE, MATE, XFCE, Cinnamon).
yum groupinstall -y "X Window System"

# the only one working (after second boot) with CentOS on VMWare 12.1.0 on ASRock with Intel N3150
# login with oracle user created above
sudo yum -y groups install "MATE Desktop"
echo "exec /usr/bin/mate-session" > ~/.xinitrc
startx
# open a command prompt with oracle user and run:
/stage/database/runInstaller

...
# see Oracle Installer Screens at https://wiki.centos.org/HowTos/Oracle12onCentos7#head-539cfe4ae2bd6f126de557cbfc5d7d7a99826c04
...

# Firewall (run as root)
firewall-cmd --get-active-zones
firewall-cmd --zone=public --add-port=1521/tcp --add-port=5500/tcp --add-port=5520/tcp --add-port=3938/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-ports

# Oracle Environment
# Login as oracle user and add the following values to the /home/oracle/.bash_profile
TMPDIR=$TMP; export TMPDIR
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/12.1.0/dbhome_1; export ORACLE_HOME
ORACLE_SID=orcl; export ORACLE_SID
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/lib64; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
# Reload the bash_profile to apply the new settings:
. .bash_profile

# Login to the database
sqlplus system@orcl

# Manage database with Oracle Enterprise Manager:
https://<hostname>:5500/em

Yum

# https://www.centos.org/docs/5/html/yum/
# http://linux.duke.edu/projects/yum/

The Alert Icon is part of the up2date application, which enables you to easily install system updates.

You may use any of the following formats to specify a package in a yum operation: name, name.architecture, name-version, name-version-release, name-version-release.architecture, and epoch:name-version-release.architecture.

The system-config-packages utility can ONLY be used if you do not update any packages and install only from the CD/DVD. This utility will fail if updates have been done.

Packages repository cache directories: /var/cache/yum/.

Put user specific aliases and functions in ~/.bashrc
# Aliases (linux commands + software)
alias free='free -m'
alias grep='grep --color'
alias grepx='grep -n --color'
alias ls='ls -hv --color --show-control-chars --group-directories-first'
alias ll='ls -hlv --color --show-control-chars --group-directories-first'
alias nethogs='nethogs egiga0'
alias psa='ps -e -o pid,pcpu,pmem,rss,ni,state,stat,start,time,nlwp,comm,cmd'
alias tailn='tail -f nohup.out'
alias tailf='tail -f'

To install the package tsclient, enter the command:
su -c 'yum install tsclient'
To install the package group MySQL Database, enter the command:
su -c 'yum groupinstall "MySQL Database"'
When you install a service, CentOS does not activate or start it. To configure a new service to run on bootup, choose Desktop->System Settings->Server Settings->Services, or use the chkconfig and service command-line utilities.

To update the tsclient package to the latest version, type:
su -c 'yum update tsclient'

To remove the tsclient package from your system, use the command:
su -c 'yum remove tsclient'
To remove all of the packages in the package group MySQL Database, enter the command:
su -c 'yum groupremove "MySQL Database"'

To search for a specific package by name, use the list function:
su -c 'yum list tsclient'
To view details about a package:
su -c 'yum info tsclient'
To search for version 0.132 of the application, use the command:
su -c 'yum list tsclient-0.132'
Use the standard wildcard characters to run any search option with a partial word or name: ? to represent any one character, and * to mean zero or more characters. Always add the escape character (\) before wildcards. To list all packages with names that begin with tsc, type:
su -c 'yum list tsc\*'

The search option checks the names, descriptions, summaries and listed package maintainers of all of the available packages:
su -c 'yum search mysql'

The provides function checks both the files included in the packages and the functions that the software provides. This option requires yum to download and read much larger index files than with the search option:
To search for all packages that include files called libneon, type:
su -c 'yum provides libneon'
To search for all packages that either provide a MTA (Mail Transport Agent) service, or include files with mta in their name:
su -c 'yum provides MTA'

CentOS systems automatically use the CentOS Project repositories. These include [base], [updates], [addons], [centosplus], [contrib], [extras], and [testing]. Some of these repositories are not enabled by default, because they might change core packages. The enabled repositories are [base], [updates], [addons], and [extras].
To perform a full system update, type this command:
su -c 'yum update'
To activate automatic daily updates, enter this command:
su -c '/sbin/chkconfig --level 345 yum on; /sbin/service yum start'

To add an extra repository, place a definition file in the /etc/yum.repos.d/ directory. The names of repository definition files end with .repo.
Default yum repositories are automatically used as up2date channels. If you want to add other channels for up2date, you must manually configure up2date to use these channels. To do so, edit the /etc/sysconfig/rhn/sources file.

To manually add a public key to your rpm keyring, use the import feature of the rpm utility. To import the file GPG-PUB-KEY.asc, type the following command:
su -c 'rpm --import GPG-PUB-KEY.asc'
to import the file GPG-PUB-KEY.asc on the web site www.therepository.com use this command:
su -c 'rpm --import http://www.therepository.com/GPG-PUB-KEY.asc'

To purge the package data files, use this command:
su -c 'yum clean headers'
Run this command to remove all of the packages held in the caches:
su -c 'yum clean packages'

Enter this command to manually install the package tsclient-0.132-4.i386.rpm:
su -c 'yum localinstall tsclient-0.132-4.i386.rpm'

You can list yum groups with:
yum grouplist 
and for more (hidden) groups including the group ids, try ("group list" is equivalent to "grouplist"):
yum group list hidden | grep -i "X Window System"
To install Xfce group:
yum groups install "Xfce" 

Lists the repository ID, name, and number of packages it provides for each enabled repository:
yum repolist
# including disabled:
yum repolist all
# see also:
ll /etc/yum.repos.d
# enable a repository:
yum-config-manager --enable InstallMedia
# or edit repo file, e.g. (set enabled=1):
nano /etc/yum.repos.d/packagekit-media.repo

yum install yum-utils
# list files from mate-system-monitor.x86_64 package:
repoquery -l mate-system-monitor.x86_64

# list group content
yum group info "General Purpose Desktop"

# List installed packages with YUM
yum list installed

# list dependencies:
yum deplist openssl.x86_64
repoquery --requires --resolve git2u-core -> shows required packages
repoquery --requires git2u-core -> shows required files from packages required

# List the files in git2u-core-2.10.0-1.ius.el6.x86_64.rpm requiring libcrypto.so.10:
rpm -q --filerequire -p git2u-core-2.10.0-1.ius.el6.x86_64.rpm | grep libcrypto.so.10

# List packages on which git2u-core-2.10.0-1.ius.el6.x86_64.rpm package depends:
rpm -q --requires -p git2u-core-2.10.0-1.ius.el6.x86_64.rpm

# install a package with no dependencies checking:
wget https://dl.iuscommunity.org/pub/ius/stable/Redhat/6/x86_64/git2u-core-2.10.0-1.ius.el6.x86_64.rpm
rpm -i --nodeps git2u-core-2.10.0-1.ius.el6.x86_64.rpm
# you then may continue to install depending packages with yum as usual:
yum install git2u-gitweb

# list repository content
yum list available | grep 'case sensitive repository id here'

# search for gcc package
yum list \*gcc\*
# install gcc
yum install gcc

# add a repository
yum-config-manager --add-repo http://www.nasm.us/nasm.repo

RedHat & CentOS

Change hostname
hostnamectl set-hostname redhat7.localdomain
hostnamectl status

Change in /etc/sysconfig/network
HOSTNAME=redhat7.localdomain

Change in /etc/hosts (otherwise Oracle won't start -> when using Oracle ...)
127.0.0.1   redhat7 redhat7.localdomain

reboot

Static ip setup
[root@localhost ~]# cat /etc/sysconfig/network
NETWORKING=yes
GATEWAY=172.16.148.2
HOSTNAME=redhat7.localdomain

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eno16777736 
TYPE="Ethernet"
#BOOTPROTO="dhcp"
BOOTPROTO="none"
DEFROUTE="yes"
PEERDNS="yes"
PEERROUTES="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_FAILURE_FATAL="no"
NAME="eno16777736"
UUID="12cca20f-49ce-41e6-aa82-2a6cbeb6e0cc"
DEVICE="eno16777736"
ONBOOT="yes"
PREFIX=24
IPADDR=172.16.148.136
#NETWORK=172.16.148.0
NETMASK=255.255.255.0
USERCTL=no

Nux Dextop
Nux Dextop is a RPM repository specially made for installing popular desktop and multimedia related packages such as VLC, Flash player, Shutter etc., in RHEL, CentOS, and Scientific Linux distributions. It is currently available for RHEL/CentOS/Scientific Linux 6 and 7 versions. This repository is made to coexist with EPEL Repository. And more importantly, Nux Dextop repository may or may not be up to date. Use it at your own risk.
Nux Dextop: A Desktop And Multimedia Oriented RPM Repository
Extra Packages for Enterprise Linux (EPEL) Extra Packages for Enterprise Linux (or EPEL) is a Fedora Special Interest Group that creates, maintains, and manages a high quality set of additional packages for Enterprise Linux, including, but not limited to, Red Hat Enterprise Linux (RHEL), CentOS and Scientific Linux (SL), Oracle Linux (OL). EPEL packages are usually based on their Fedora counterparts and will never conflict with or replace packages in the base Enterprise Linux distributions. https://fedoraproject.org/wiki/EPEL
Install EPEL Repository On RHEL / CentOS / Scientific linux 6.x, 5.x
GNOME, KDE, MATE, XFCE, Cinnamon http://unix.stackexchange.com/questions/181503/how-to-install-desktop-environments-on-centos-7 see /etc/inittab multi-user.target: analogous to runlevel 3 graphical.target: analogous to runlevel 5 To view current default target, run: systemctl get-default Check OS version cat /etc/redhat-release