Centos6 Linux installation and more

English only (for the moment…)

How To install CentOS 6 Linux in a Real or Virtual Computer. And MORE!

————————- BEGIN ————————-

“Real” installation:

“Real” installation requirements: a Computer is required to produce the USB/CD/DVD supports from the ISO images, and a “destination” Computer is needed to install the Operating System.
The destination pc should be a Windows PC with at least an Intel i3 or similar level CPU, at least 2GB of RAM (best 4GB or more), USB boot support or CDROM/DVD boot support, at least one 40GB (best 80GB or more) hard drive.

Note for an old PC with an old CPU like P4 is more suitable the old Version 5 i386, perhaps the CentOS 6 32 bit could run on it but it is strongly suggested to use a newer and more powerful hardware, if only the clean install of the OS is planned and no more software is required the system could fit into 20GB of hard drive space, but the use of very old and poor hardware is discouraged.
CentOS 6 can run on hardware like a 2010 Intel Core 2 Duo with USB and CD/DVD support, 4GB of RAM and 250GB of hard drive.

Note that a 32 bit architecture can handle a maximum of 4 GB of memory, but some processors support the PAE (Physical Address Extension) function that provides support for more than 4 GB of memory, in this case the single process would still operate limited to a maximum of 4 GB of memory.

The physical support can be either an USB pendrive or a CD/DVD.

  • USB Pendrive
    The “Rufus” program can create bootable USB pendrives from bootable ISO images,
    download the ISO image file, open Rufus and follow the instructions.
    Be careful, do not proceed if not sure, first of all create backup copies of all data before proceeding with the next instructions.
    https://rufus.ie/ CD/DVD
    Download the ISO image as explained below, burn it to a physical support, if a CD/DVD is required CDBurnerXP is suggested
    https://www.cdburnerxp.se/

Once that the physical support is ready and YOU HAVE DONE AT LEAST A BACKUP COPY OF ALL THE DATA, you may proceed enabling the boot from USB or CD/DVD.

Important, the “REAL” installation will erase and destroy every data on the hard disk, no warranty is provided about any kind of damage or data loss provoked using the present text.

Be careful, do not proceed if not sure, first of all create backup copies of all data before attempting any of the next instructions.

“Virtual” Installation

“Virtual” installation requirements : a Windows PC (host) will run a Virtual Machine Manager capable of running another operating system inside of it (guest OS), so this physical PC will require at least 4GB of RAM, at least an Intel i3 or similar level CPU, at least a 40GB hard drive.
The clean OS installation could fit in 20GB of hard drive space, but it is suggested to arrange enough space for applications and data.

Simple rule: the usage of very old hardware with poor resources is discouraged, one computer will run both its OS and a guest OS, you may want to enable VT-X Vrtualization support and more features, so the previous hardware minimal specifications should be respected, furthermore it is suggested to consider a convenient hard drive space to fit all the data needed also in future.

Download and install VMware Workstation free evaluation version
https://www.vmware.com/products/workstation-player/workstation-player-evaluation.html

Choose of the ISO image file

Simple rule: in order to run a 64bit operating system a 64 bit system is required.

Centos version 6 or 7? The version 6 is still used in a large amount of production systems worldwide and is often used to teach the basics of GNU Linux, the version 7 is newer and keeps some features of the previous versions and provides a more modern technology powered by the CentOS Community.

This guide is based on CentOS 6 “Minimal” ISO image files to install a clean and essential CentOS operating system in order to know, learn and customize it.

for CentOS 6 x86_64 iso images
http://isoredirect.centos.org/centos/6/isos/x86_64/
CentOS-6.10-x86_64-minimal.iso 2018-06-29 18:42 406M

for CentOS 6 i386 iso images
http://isoredirect.centos.org/centos/6/isos/i386/
CentOS-6.10-i386-minimal.iso 2018-06-29 22:46 356M

Preparation:
“Real” Installation
download the ISO file, produce the physical support (USB Pendrive or CD/DVD), check the BIOS or EFI boot options of the “destination” PC (check the user manual of the computer) and use the physical support to boot the PC.
Remember that all the data in the computer will be erased and lost, so do a backup copy and do not proceed with next steps if not sure. No warranty is given for any kind of loss of data or any kind of issue and problem derived from the present text.

Ready? Start the PC with the CentOS boot drive.

“Virtual” installation
dowload the ISO file, open VMware Workstation Player and prepare the virtual machine guest system following these instructions
Create a new Virtual Machine
I will install the operating system later
Linux – CentOS (the version choesen between 6 32bit, 6 64bit)
insert a name for the VM
Maximum disk space 40 GB – Store virtual disk as a single file

Customize Hardware (set the following virtual hardware settings)

Memory 2048 MB (2GB)
Processors 1 (or more processors)
(if virtualization is supported it is possible to enable the Virtualization engine options, this features are not required for the present guide)
Hard disk SCSI 40GB (at least)
CD/DVD use image file (CentOS iso image file)
USB Controller present (bluetooth may be disabled)
Sound Card Auto detect (connect at power on)
Network Adapter NAT (or Bridged in alternative)
Display Auto detect

To check and review the virtual hardware settings click “Edit virtual machine settings”

Ready? Click on “PlayVirtual Machine”

#

From this point the procedure is the same for both installation types, there are only a few settings involving drivers, wifi and physical resources clearly not present on virtual machines.
The Warnings about loss of data are reminders about the “Real” installation, also if a risk of loss of data is possible for “Virtual” install if any existing virtual hard drive is selected.
Simple rule, if not sure search information, study, ask to the experts before experimenting with procedures that could provoke loss of data.
The present text, its author and publisher are not and will never not be responsible for any kind of issue, damage, data loss derived from the procedures described.

#

CentOS 6
Same procedure for 32bit and 64bit version.
Select the options below to install a minimal CentOS Linux Operating System:

  • Install or upgrade an existing system
    (or if using an “old” pc choose the second option Install with basic video driver)
  • Skip
  • Next
  • Choose the language – Next
  • Choose the keyboard layout – Next
  • Basic storage devices – Next

WARNING from this step all data will be erased, be careful and do not proceed if not sure, it is strongly suggested to make several backups of every data.

  • Let the flag on “Apply my choice…” – Yes, discard any data
  • choose the Hostname (example CENTOS6.localdomain)
    and
  • Configure Network
    select System eth0
    Edit – flag “Connect Automatically” – Apply… – Close
  • choose the timezone – Next
  • Enter and Confirm the “Root Password” – Next
    ROOT: in Linux (and Unix in general), there is a SuperUser named root.
    More info at the page https://help.ubuntu.com/community/RootSudo
    If the password chosen is not enough complex, the system may ask to confirm if proceed anyway or if a more complex password would be entered.

WARNING This option will remove all data from the selected drive. Make sure you have backups and if not sure, do not proceed.

  • Use all space – Next
    (the two options Encrypt system and Review partitioning layout are interesting, useful, but not treated in this text that represents a minimal basic guide)

This step will erase all the data on the selected hard drive.

  • Write changes to disk
    Wait the install to complete.
  • Reboot

When the startup is completed if the screen shows (for the 64bit) a screen like this:
CentOS release 6.10 (Final)
Kernel 2.6.32-754.el6.x86_64 on an x86_64
CENTOS6 login: _

Player – Removable Devices – CD/DVD (IDE) – Settings
flag “Use physical drive” and let selected “Auto detect”
press OK

Your CentOS Operating System is running.

Brief note about Linux and its commands

The Bash (Unix shell) is a Unix shell and command language.
To become confident with Linux it is suggested to read, study, attend classes and online courses about Linux, Bash, and Unix systems.
For example googling could provide website with some commands like this:
https://likegeeks.com/main-linux-commands-easy-guide/

Useful links

Centos & Linux
https://wiki.centos.org/Documentation
https://www.linux.org/docs/
https://www.tecmint.com/free-online-linux-learning-guide-for-beginners/

Linux commands
https://linuxconfig.org/linux-commands
https://www.tecmint.com/linux-commands-cheat-sheet/
https://ss64.com/bash/
https://www.linux.com/learn/how-use-linux-command-line-basics-cli
http://www.linuxcommand.org/

Classes and courses (also FREE courses are offered):
https://www.udemy.com/
https://www.cybrary.it/
https://training.linuxfoundation.org/

CentOS configuration example

The following steps show how to make a basic configuration of CentOS Linux, this guide is targeted to all the people who want to learn Linux, so the guide includes a limited set of commands and configurations based on the habits and personal taste of the author.
The aim is to configure a minimal CentOS system using low resources.
From this point every command to be written at the Bash prompt will begin with # to be easily recognized.

First screen:
CentOS release 6.10 (Final)
Kernel 2.6.32-754.el6.x86_64 on an x86_64
CENTOS6 login:

For a first configuration enter the following commands :
# root
insert the password set during the installation and press Enter

note that the prompt has changed to
root@CENTOS6 ~ #

to list files and directories
# ls

to show the current folder
# pwd

To clear the screen
# clear
or “ctrl+l”

Note : the text editor used in this guide is “VI”, please remember always that any modification, any small change to any file could cause an instable system and loss of data.
It is suggested to study the official CentOS and Linux documentation.

To run vi enter the command
# vi
to exit write the following command and press enter
# :q
Note that VI is a powerful text editor builtin in Linux, for more details see http://www.lagmonster.org/docs/vi.html
If any mistake or problem happen, you may use this command to close the file without saving it
# :q!

to show the network address(es)
# ip a
or
# ifconfig

the IP address in use is at the “eth0” entry near “inet addr:” for example 192.168.55.128 or 192.168.81.135
This is a Class C IP address, the Class C range goes from 192.0.0.x to 223.255.255.x and its default subnet mask is 255.255.255.x.
More info about IP addresses can be found at :
https://en.wikipedia.org/wiki/IP_address
https://www.tutorialspoint.com/ipv4/ipv4_address_classes.htm

192.168.81.154

  • Disable IPv6
    Why? Because on this training focused system IPv6 won’t be used.
    Disable IPv6
    # vi /etc/sysctl.conf
    go to the end of the file, press “i” to enable edit mode, add the following lines
    net.ipv6.conf.all.disable_ipv6 = 1
    net.ipv6.conf.default.disable_ipv6 = 1
    net.ipv6.conf.lo.disable_ipv6 = 1
    net.ipv6.conf.eth0.disable_ipv6 = 1
    then press the “Esc” key to exit edit mode and type the command to write and save the file
    # :wq

use the following command to load the edited configuration
# sysctl -p

edit the hostname in the hosts file
# vi /etc/hosts
go to the first line, press “i” press enter and add the following line using the computer name chosen during the installation (in this case the name is CENTOS6)
127.0.0.1 CENTOS6 CENTOS6.localdomain

then press the “Esc” key to exit edit mode and type the command to write and save the file
# :wq

Note that 127.0.0.1 is the defeult loopback IPv4 address.

Check and edit the network settings using the command
# vi /etc/sysconfig/network-scripts/ifcfg-eth0

For the purpose of this tutorial only the following entry have been edited
NM_CONTROLLED=no
NAME=”eth0″

One important entry is ONBOOT=yes because when set to “no” the network interface must be enabled manually every time that the system is started.

Reboot changing runlevel with
# telinit 6

For more info
http://manpages.ubuntu.com/manpages/cosmic/en/man8/telinit.8.html
http://www.linuxguide.it/command_line/linux-manpage/do.php?file=telinit

The reboot could also be performed using commands like # reboot -f or # init 6 or
# shutdown -r now …but it telinit is preferred.

Create a user for the ordinary operations, in order to limit the usage of the Root account. The username chosen for the example is “linux”

# adduser linux
# passwd linux
insert a password and press enter, enter again the password and press enter
# usermod -aG wheel USERNAME
# visudo
delete the “#” at the beginning of the line :
%wheel ALL=(ALL) ALL
# :wq

Note that in Bash files a line beginning with “#” is classified as “commented” and the command contained in it will generally not been processed.
Comments are considered very useful to understand configuration files, scripts and programs.

Network troubleshooting basics

How to check the network interfaces and details
# ip a
or
# ifconfig

The network service can be checked for the status, stopped, started, restarted with several commands like for example :
# service network status

# ifup eth0
# service network start

# ifdown eth0
# service network stop

Note if the network address is present (192.168.x.x) for the interface eth0 it is possible to check if the connettivity is working with a simple command named ping:
# ping google.com

if the result is something like network unreacheable or another error maybe the network interface is not active or the ip address require to be assigned again by the router or the VM network manager, a reboot is suggested.
The file that confirm if the network can be reached is the DNS configuration file, commands to view it:

# less /etc/resolv.conf
or
# cat /etc/resolv.conf

the file content should look like:
; generated by /sbin/dhclient-script
search localdomain
nameserver 192.168.x.x

The nameserver represents the DHCP server recognized by the system it can be the router (in a real environment) or the VM network manager (in a virtual environment).
The netowrk troubleshooting in case of network failure, includes in the first steps of the best practice the ping of that IP address, since it represents the Gateway.
If the ping fails a real interface/cable/devices/router/configuration issue can be impacting the network, or in a virtual environment a configuration could be the root cause of the problem to be investigated.

Disabling iptables
Why? Because in this guide it is not planned to use them, furthermore the iptables can limit or deny some real or virtual network service.
# service iptables status
# service iptables stop
# chkconfig iptables off

Check OS and system configuration and performances, as suggested in the first part it could be very helpful to study the Linux and Bash commands to become confident with this nice and powerful system.
The following commands are some of the thousands combination frequently adopted to perform systems troubleshooting and configurations :

# uptime
# uname -a
# cat /etc/centos-release
# ifconfig | grep -i inet
# whoami
# pwd
# free -m
# df -hP
# du -h /home; du -h /root
# du -shcx *

The following commands show the real time status (updated every few seconds) and to exit from them it is used che keys combination “ctrl + c”.
# top
# watch -n 3 free -m

Now that some commands have been seen, it is possible to proceed using the user created in the previous steps, in order to avoid the habit of using the Root user.

To review the previously used commands it is used the command
# history

and the commands present in the list shown can be executed again, exactly as they appear in the list, entering an “!” followed by the number at the left of the command we want to run again, for example:
# history
1 ls
2 ip a
3 free -m

With the output list shown it is possible to execute again the “ip a” command entering
# !2
And the “ls” command entering
# !1

This line of commands delete the history
# history -c && history -w

To close the session and start using the standard user enter
# exit
or
# logout

The screen is back to the login prompt:
CentOS release 6.10 (Final)
Kernel 2.6.32-754.el6.x86_64 on an x86_64
CENTOS6 login:

Enter the username and the password, the screen will show the prompt with the username for example with a computer name CENTOS6 and the username linux:
linux@CENTOS6 ~ $

Since the user has been inserted in the sudoers (aka wheel group), it will be possible to run commands using “sudo”:
# sudo ls

The first time a “sudo” command will produce a screen like:
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

  #1) Respect the privacy of others.
  #2) Think before you type.
  #3) With great power comes great responsibility.

  sudo  password for linux:

If a user is created without adding it to the wheel group the system could reply something like:
user is not in the sudoers file. This incident will be reported.
user@CENTOS6 ~ $

Note that it is important to know the Bash and Linux rules, to avoid damage and data loss.

A full root shell can be gained running
# sudo –i
The prompt changes to
root@CENTOS6 ~ #
So it will be better to close the root session when it will be no more necessary, using
# exit
turning to the user shell
linux@CENTOS6 ~ $

Update time
It is strongly suggested to perform an update operation before installing other software.
A full update can be performed using the standard user with “sudo” or the root user without the “sudo”.
The flag -y avoid the prompt for confirmation at any request.

# sudo yum update -y && sudo yum upgrade -y

Clearing the cache
Cache entries are accumulated in the /var/cache/yum/ folder, to remove all of them run the command
# sudo yum clean all -y

SSH (Secure Shell)
SSH is an encrypted protocol suitable for secure data communication, remote shell services or command execution between two computers, SSH provides a secure channel over a network that could be unsecured.
Note: for the “Real” installation the SSH could be used within a network where the IP address of the destination computer is reacheable using another computer with SSH client installed and working.
While for the “Virtual” installation the real Windows computer will connect via SSH to the destination computer.

Install SSH
# sudo yum install -y openssh-server

The SSH daemon (services are named daemons in Linux) can be managed with
# sudo service sshd start
# sudo service sshd stop

Start automatically sshd daemon at boot:
# sudo chkconfig sshd –add
# sudo chkconfig sshd on –level 2,3,4,5

Stop automatic initialization of sshd daemon at boot:
# sudo chkconfig sshd off
#sudo chkconfig sshd –del

To permit the login via SSH using ROOT
# vi /etc/ssh/sshd_config

Remove the comment tag (#) from the line
PermitRootLogin yes

To connect sia SSH it is necessary to have a client installed on another pc,
it is suggested Putty client, it is also available in a version that does not require install called “putty.exe (the SSH and Telnet client itself)”
Putty download: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
Putty intructions: https://the.earth.li/~sgtatham/putty/0.70/puttydoc.txt

Once opened Putty, put the IP address of the CentOS PC in the Host field and click “Open” to login and perform activities on the remote computer, the commands will be executed in the same way as when the login is performed locally.
A prompt will ask to confirm the connection.
Note that every interruption of the network services,interfaces,drivers,connections will disconnect the Putty remote client.

Service Message

This guide has been written to encourage the readers in approaching the GNU Linux Operating System and to make an important step into the world open source softare, hopefully this text could be seen as a basic tutorial, with some “personal” choices to keep the system lightweight and the tone friendly, hoping this will be appreciated.

Support the CentOS community

https://www.centos.org/

End of the Service Message

Install a Desktop Environment or GUI (Graphical User Interface)
Until this step only the CLI (or text shell) has been used, but the CentOS can provide graphical interfaces and more, for the list of packages installed and available use
# yum grouplist | less
For details about a specific group use for example
# yum groupinfo “Desktop”

Install GNOME desktop on CentOS 6
# sudo yum groupinstall -y “X Window System”
# sudo yum groupinstall -y “Desktop”

Changing the inittab file would make permanent the startup into the default Desktop Environment :
# sudo vi /etc/inittab
change
id:3:initdefault:
to
id:5:initdefault:

# sudo yum groupinstall -y fonts

To reboot CentOS
# sudo telinit 6

To start Gnome
# sudo startx
or
# sudo telinit 5

For security reasons it is strongly suggested to avoid logging in Graphical environments with the Root user, the standard users are preferred.

After the first reboot the system could start a configuration GUI.

To Exit click on the username icon on the right of the upper taskbar then Quit and Log Out.
To shutdown or restart click on the button System on the taskbar and choose the desired action.

Gnome Configuration
Please note that the following steps are intended as suggestions,
based on personal taste and they are absolutely not mandatory, since they are based on personal taste of the author.

System – Preferences – Display
set the optimal resolution for the monitor in use
Apply – Close when ok

Applications – System Tools – Terminal
click the menu Edit – Profile Preferences
here it is possible to set many customizations, one of the most used is the color choice inside the tab Colors – Built-in schemes

System – Preferences – Screen Saver
unflag Activate if using a “Virtual” installation

Open the computer browser with a double click on the desktop icon named Computer
Edit – Preferences
Icon and compact view Default zoom level 66%
Behavior – flag Always open in browser windows
Preview – set Never to all
Media – flag Never prompt or start programs on media insertion
Close the Computer browser, open it again and see the differences.

The following options is not suggested, but it could be set to avoid system changes for training environments without security requirements like inb the present guide
System – Preferences – Software Updates – Check Never

In a “Real” installation it is possible to switch between GUI and CLI with keys combinations :
CLI to GUI : Ctrl + Alt + F1
GUI to CLI : Ctrl + Alt + F6

Runlevels
Run Level Mode Action
0 Halt Shuts down system
1 Single-User Mode No network No daemons No root login
2 Multi-User Mode No network No daemons
3 Multi-User Mode w/Networking Normal start
4 Undefined Not used/Definable
5 X11 Runlevel 3 + display manager(X)
6 Reboot Reboots the system

In the “Virtual” and “Real” install it is possible to switch to:
CLI with
# telinit 3
# telinit 5

To reboot CentOS
# telinit 6

To shutdown CentOS
# telinit 0

Internet Browser
# sudo yum grouplist
# sudo yum groupinfo “Internet Browser”
# sudo yum groupinstall -y “Internet Browser”

In the applications menu appeared the Internet group containing the Firefox browser.
Suggestion: set the homepage to https://start.duckduckgo.com/ and the search engine to Duckduckgo.
Why?
Because Duckduckgo is the search engine that doesn’t track you. More info at https://start.duckduckgo.com/spread

From time to time the “Virtual” (and maybe the “Real”) installation could result disconnected, with result of errors in the execution of yum commands, an eassy way solution is often:
# ping google.com
if the ping produces errors
# sudo ifdown eth0
# sudo ifup eth0
# ping google.com

CentOS 6 to Discover, Study and Develop

Useful text editor to work with the system, manage files, and study:
# sudo yum install gedit

Downloader
# sudo yum install wget

Java
Many prefer GNU licensed and open source software, about Java, OpenJDK is considered tto be the community reference, but since a large amount of books, courses and classes are based on Oracle Java the choice in this tutorial is Oracle Java 8 Platform also if it is known as a commercial Platform.

Install Oracle Java 8
Open Firefox and go to https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Accept the License Agreement and download a suitable version for your system (64 bit or 32 bit) for example
Linux x64 170.15 MB jdk-8u202-linux-x64.rpm
The file will be saved in the Download directory

# sudo rpm -ivh jdk-8u202-linux-x64.rpm

Check the Java version
# java -version
java version “1.8.0_202”
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)
# javac -version
javac 1.8.0_202

Check (if present) alternative Java configurations, at the selection request press Enter to confirm

# alternatives –config java
There is 1 program that provides ‘java’.

Selection Command

*+ 1 /usr/java/jdk1.8.0_202-amd64/jre/bin/java
Enter to keep the current selection + , or type selection number:

Eclipse IDE (integrated development environment)
Eclipse is the most widely used Java IDE, the CentOS 6 gives the possibility to install from its repositories the Eclipse “Helios” (23 June 2010 version 3.6), old but still working on old systems and useful for students and fans of Linux and Development.
# sudo yum grouplist | grep -i eclipse
# sudo yum groupinstall Eclipse

In the applications menu appeared the Development group containing the Eclipse IDE.
Once clicked on the icon Eclipse the Workspace launcher will open asking to confirm the location of the workspace.
The workspace is the folder where the codes will be stored.
Eclipse info:
https://wiki.eclipse.org/Main_Page
https://wiki.eclipse.org/Eclipse_Articles,_Tutorials,_Demos,_Books,_and_More

Remeber to periodically check for updates also when using old repositories:
# sudo yum update -y && sudo yum upgrade -y
# sudo yum clean all

Enjoy Linux and good study to all.

Java resources
https://www.javatpoint.com/java-tutorial
https://fileadmin.cs.lth.se/cs/Education/EDA040/common/java21.pdf
http://www.oracle.com/events/global/en/java-outreach/resources/java-a-beginners-guide-1720064.pdf
https://docs.oracle.com/javaee/7/JEETT.pdf
https://www.cs.colostate.edu/~cs160/.Summer16/resources/JavaTutorial.pdf
http://math.hws.edu/eck/cs124/downloads/javanotes6-linked.pdf
http://gsl.mit.edu/media/programs/indonesia-summer-2013/materials/o’reilly_-_learning_java.pdf
https://www.roseindia.net/java/beginners/
https://www.udemy.com/
https://www.youtube.com/

#

Broadcast message from root@CENTOS6.localdomain
(unknown) at 00:00 …
The system is going down for halt NOW!

#

————————- END ————————-