Centos
Centos
#centos
Table of Contents
About 1
Remarks 2
Versions 2
Examples 2
Installation or Setup 2
Credits 38
About
You can share this PDF with anyone you feel could benefit from it, downloaded the latest version
from: centos
It is an unofficial and free centos ebook created for educational purposes. All the content is
extracted from Stack Overflow Documentation, which is written by many hardworking individuals at
Stack Overflow. It is neither affiliated with Stack Overflow nor official centos.
The content is released under Creative Commons BY-SA, and the list of contributors to each
chapter are provided in the credits section at the end of this book. Images may be copyright of
their respective owners unless otherwise specified. All trademarks and registered trademarks are
the property of their respective company owners.
Use the content presented in this book at your own risk; it is not guaranteed to be correct nor
accurate, please send your feedback and corrections to info@zzzprojects.com
https://riptutorial.com/ 1
Chapter 1: Getting started with centos
Remarks
CentOS versions download: here
"The CentOS Linux distribution is a stable, predictable, manageable and reproducible platform
derived from the sources of Red Hat Enterprise Linux (RHEL). Since March 2004, CentOS Linux
has been a community-supported distribution derived from sources freely provided to the public by
Red Hat. As such, CentOS Linux aims to be functionally compatible with RHEL.
The CentOS Project is a community-driven free software effort focused around the goal of
providing a rich base platform for open source communities to build upon. We will provide a
development framework for cloud providers, the hosting community, and scientific data
processing, as a few examples. We work with several ‘upstream’ communities to help them layer
and distribute their software more effectively on a platform they can rely on.
The CentOS Project is modelled on the structure of the Apache Foundation, with a governing
board that oversees various semi-autonomous Special Interest Groups or ‘SIGs’. These groups
are focused on providing various enhancements, addons, or replacements for core CentOS Linux
functionality. A few notable examples of SIGs are:
Core - Building and releasing the core CentOS Linux platform. Xen4CentOS - Providing Xen4
support for CentOS 6 CentOS Design - Improving the user experience with high quality artwork."*
Versions
5 2007-04-12
6 2011-07-10
7 2014-07-07
Examples
Installation or Setup
Detailed instructions on getting CentOS 7 installation and basic set up for starting on.
https://riptutorial.com/ 2
download page. Burn it to a DVD or create a bootable USB stick using LiveUSB Creator
called Unetbootin.
3. After you have created the installer bootable media, place your DVD/USB into your system
appropriate drive, start the computer, select your bootable unit and the first CentOS 7 prompt
should appear. At the prompt choose Install CentOS 7 and press [Enter] key.
4. The system will start loading media installer and a Welcome screen should appear. Select
your Installation Process Language, that will assist you through the entire installation
procedure and click on Continue.
https://riptutorial.com/ 3
5. The next step, present screen prompt is Installation Summary. It contains a lot of options to
fully customize your system. First thing you may want to setup is your time settings. Click on
Date & Time and select your server physical location from the provided map and hit on upper
Done button to apply configuration.
https://riptutorial.com/ 4
6. The next step is to choose your Language Support and Keyboard settings. Choose your
main and extra language for your system and when you’re finished hit on Done button.
https://riptutorial.com/ 5
7. The same way choose your Keyboard Layout by hitting the plus button and test your
keyboard configuration using the right input filed. After you finish setting up your keyboard,
you can use any key combination for switching between keyboards, in my case I am using
https://riptutorial.com/ 6
Alt+Ctrl. After selection of your desired key combination, press Done again to apply changes
and go back to main screen on Installation Summary.
https://riptutorial.com/ 7
8. Now we can add LANGUAGE SUPPORT if you don't want to use English. Click on
"LANGUAGE SUPPORT" to open the dialog.
https://riptutorial.com/ 8
9. By default, CentOS comes with English language preinstalled, but we can add more
languages easily. In my case, I am adding Deutsch German with Deutsch (Deutschland) as
the additional language. Press Done after selection.
10. On the next step you can customize your installation by using other Installation Sources than
https://riptutorial.com/ 9
your local DVD/USB media, such as a network locations using HTTP, HTTPS, FTP or NFS
protocols and even add some additional repositories, but use this methods only if you know
what you’re doing. So leave the default Auto-detected installation media and hit on Done to
continue.
https://riptutorial.com/ 10
11. On the next step you can choose your system installation software. On this step CentOS
offers a lot of Server and Desktop platform environments that you choose from, but, if you
want a high degree of customization, especially if you are going to use CentOS 7 to run as a
server platform, then I suggest you select Minimal Install with Compatibility Libraries as Add-
ons, which will install a minimal basic system software and later you can add other packages
as your needs require using:
https://riptutorial.com/ 11
10. Now it’s time to partition your hard-drive. Click on Installation Destination menu, select your
disk and choose I will configure partitioning. Read more about what partition to choose here:
https://www.centos.org/docs/5/html/Installation_Guide-en-US/s1-diskpartitioning-x86.html
https://riptutorial.com/ 12
11. On the next screen, choose LVM (Logical Volume Manager) as partition layout and, then,
click on Click here to create them automatically, option which will create three system
partition using XFS filesystem, automatically redistributing your hard-disk space and
gathering all LVS into one big Volume Group named “centos”.
https://riptutorial.com/ 13
12. If you are not pleased with the default partition layout done automatically by the installer you
can completely add, modify or resize your partition scheme and when you finish hit on Done
button and Accept Changes on the Summary of Changes prompt.
https://riptutorial.com/ 14
NOTE: For those users, who have hard-disks more than 2TB in size, the installer automatically will
convert partition table to GPT, but if you wish to use GPT table on smaller disks than 2TB, then
you should use the argument inst.gpt to the installer boot command line in order to change the
default behavior.
13. The next step is to set your system hostname and enable networking. Click on Network &
Hostname label and type your system FQDN (Fully Qualified Domain Name) on Hostname
filed, then enable your Network interface, switching the top Ethernet button to ON. If you
have a functional DHCP server on you network then it will automatically configure all your
network setting for enabled NIC, which should appear under your active interface.
https://riptutorial.com/ 15
14. If your system will be destined as a server it’s better to set static network configuration on
Ethernet NIC by clicking on Configure button and add all your static interface settings like in
the screenshot below, and when you’re finished hit on Save button, disable and enable
Ethernet card by switching the button to OFF and ON, and, then hit on Done to apply setting
https://riptutorial.com/ 16
and go back to main menu.
https://riptutorial.com/ 17
15. Add the entries for Address, Netmask and Gateway as per your static IP environment. In my
case I am using Address as 192.168.1.100, Netmask 255.255.255.0, Gateway as
192.168.1.1 and DNS servers as 8.8.8.8 8.8.4.4 These values may vary according to your
network environment. After that press Save.
IMPORTANT: If you do not have an IPv6 internet connection, then set IPv6 from auto to ignore on
the IPv6 tab, otherwise you won't be able to reach the internet from this server on IPv4 as CentOS
seems to ignore the correct IPv4 setup then and uses IPv6 instead which fails.
https://riptutorial.com/ 18
16. Next, we have to turn the connection ON as shown in the screenshot below. Further press
Done.
17. Now it’s time to start installation process by pressing on Begin Installation button and set up
a strong password for root account.
https://riptutorial.com/ 19
18. The installation process will start now and you get a small blue progress bar in the next
windows. Now we have to set the ROOT PASSWORD and add a new non-root user in
the USER CREATION option. I will first go for root password.
https://riptutorial.com/ 20
20. Next we will go for USER CREATION.
21. Next I will create user, as in my case I used the Full name "Administrator"
and Username "administrator", check the option Require the password to use this account
and then press Done. Off-course you can use any value as per your choice.
https://riptutorial.com/ 21
22. Press Finish.Have patience and wait for the completion of the setup.
23. After completion of the installation, it will ask to reboot the server, just press Finish
configuration.
https://riptutorial.com/ 22
24. The server reboots and will request your username and password afterwards.
Congratulation! You have now installed last version of CentOS on your bare new machine.
Remove any installation media and reboot your computer so you can login to your new minimal
CentOS 7 environment and perform other system tasks, such as update you system and install
other useful software needed to run day to day tasks.
25. Now we are ready to do login with the user that we just created above or we can use the root
credentials.
https://riptutorial.com/ 23
Login as root user to the server so we can do some final installation steps.
yum update
I will install two command line editors to be able to edit configuration files on the shell:
Network Configuration
CentOS 7.2 minimal don't come pre-installed with the ifconfig command we will install it as follows:
yum install net-tools
If you want to change or see the network configuration file, just edit the file
nano /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE="Ethernet"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="no"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_FAILURE_FATAL="no"
NAME="ens33"
UUID="eb1ba0ce-af9f-4953-a6a7-3d05a15c8d4f"
DEVICE="ens33"
ONBOOT="yes"
IPADDR="192.168.1.100"
PREFIX="24"
GATEWAY="192.168.1.1"
DNS1="192.168.1.1"
DNS2="8.8.8.8"
DNS3="8.8.4.4"
TYPE="Ethernet"
BOOTPROTO="dhcp"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
https://riptutorial.com/ 24
IPV6_FAILURE_FATAL="no"
NAME="ens33"
UUID="eb1ba0ce-af9f-4953-a6a7-3d05a15c8d4f"
DEVICE="ens33"
ONBOOT="yes"
HWADDR="00:50:56:15:23:79"
PEERDNS="yes"
PEERROUTES="yes"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_PRIVACY="no"
Note: The above DEVICE name may vary so please check the equivalent file in the directory
/etc/sysconfig/network-scripts.
Adjust /etc/hosts
nano /etc/hosts
Now you may prefer to use GUI instead, here is a variety of flavor you could choose from:
Installing GNOME-Desktop:
# startx
https://riptutorial.com/ 25
How to use GNOME Shell?
The default GNOME Desktop of CentOS 7 starts with classic mode but if you'd like to use GNOME
Shell, set like follows:
Option B: set the system graphical login systemctl set-default graphical.target and reboot the
system. After system starts
1. Click the button which is located next to the "Sign In" button.
2. Select "GNOME" on the list. (The default is GNOME Classic)
3. Click "Sign In" and log in with GNOME Shell.
https://riptutorial.com/ 26
GNOME shell starts like follows:
Installing KDE-Desktop:
https://riptutorial.com/ 27
KDE Desktop Environment starts like follows:
https://riptutorial.com/ 28
Installing Xfce Desktop Environment:
https://riptutorial.com/ 29
OTHER WAY TO DO IT:
Rather than make use of the hacking of a startx command into a .xinitrc file, it's probably better to
tell Systemd that you want to boot into a graphical GUI vs. the terminal.
The last bit will associate the runlevel 5 target as your default with respect to Systemd.
You can also use Systemd to accomplish this. This is arguably the better method since you're
managing the state of the system directly through Systemd and its CLIs.
https://riptutorial.com/ 30
graphical.target
Targets
In Systemd the targets runlevel5.target and graphical.target are identical. So too are
runlevel2.target and multi-user.target.
RHEL / CentOS Linux Install Core Development Tools Automake, Gcc (C/C++), Perl, Python &
Debuggers
Q. How do I install all developer tools such as GNU GCC C/C++ compilers, make and others, after
installing CentOS or RHEL or Fedora Linux from a shell prompt?
1. flex
2. gcc c/c++ compiler
3. redhat-rpm-config
4. strace
5. rpm-build
6. make
7. pkgconfig
8. gettext
9. automake
10. strace64
11. gdb
12. bison
13. libtool
14. autoconf
15. gcc-c++ compiler
16. binutils and all dependencies.
Installation:
Open the terminal or login over ssh session and type the following command as root user:
https://riptutorial.com/ 31
Sample outputs that follows:
Now you can compile and use any application on your system.
Verification
$ gcc --version
Sample outputs:
https://riptutorial.com/ 32
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
How do I list all currently running services in Fedora / RHEL / CentOS Linux server?
There are various ways and tools to find and list all running services under Fedora / RHEL /
CentOS Linux systems.
The syntax is as follows for CentOS/RHEL 6.x and older (pre systemd):
service --status-all
service --status-all | more
service --status-all | grep ntpd
service --status-all | less
Print the status of any service. To print the status of apache (httpd) service:
chkconfig --list
netstat -tulpn
ntsysv
chkconfig service off
chkconfig service on
chkconfig httpd off
chkconfig ntpd on
ntsysv is a simple interface for configuring runlevel services which are also configurable through
chkconfig. By default, it configures the current runlevel. Just type ntsysv and select service you
want to run.
If you are using systemd based distro such as Fedora Linux v22/23/24 or RHEL/CentOS Linux
7.x+. Try the following command to list running services using the systemctl command. It control
the systemd system and service manager.
https://riptutorial.com/ 33
The syntax is:
systemctl
systemctl | more
systemctl | grep httpd
systemctl list-units --type service
systemctl list-units --type mount
systemctl list-unit-files
Sample outputs:
https://riptutorial.com/ 34
above image shows List all units installed on the CentOS /RHEL 7 systemd based system, along
with their current states
To view processes associated with a particular service (cgroup), you can use the systemd-cgtop
command. Like the top command, systemd-cgtop lists running processes based on their service:
systemd-cgtop
Sample outputs:
https://riptutorial.com/ 35
To list SysV services only on CentOS/RHEL 7.x+ use (does not include native systemd services)
chkconfig --list
Sample outputs:
https://riptutorial.com/ 36
FIREWALL HOW TO:
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-using-firewalld-on-
centos-7
References
• https://wiki.centos.org/Documentation
• https://www.centos.org/docs/5/
• https://wiki.centos.org/Manuals/ReleaseNotes/CentOS7
• Install Gnome GUI on CentOS 7 / RHEL 7
• 8.3. WORKING WITH SYSTEMD TARGETS
CentOS versions 2 - 5
CentOS version 7
CentOS 7 is fully based on RedHat the detail documentation, examples and system administration
guides are located here:CentOS 7 full documention
https://riptutorial.com/ 37
Credits
S.
Chapters Contributors
No
https://riptutorial.com/ 38