CentOS Quick Start Guide

By Shiwang Kalkhanda
  • Instant online access to over 7,500+ books and videos
  • Constantly updated with 100+ new titles each month
  • Breadth and depth in over 1,000+ technologies
  1. Getting Started with CentOS 7

About this book

Linux kernel development has been the worlds largest collaborative project to date. With this practical guide, you will learn Linux through one of its most popular and stable distributions.

This book will introduce you to essential Linux skills using CentOS 7. It describes how a Linux system is organized, and will introduce you to key command-line concepts you can practice on your own. It will guide you in performing basic system administration tasks and day-to-day operations in a Linux environment.

You will learn core system administration skills for managing a system running CentOS 7 or a similar operating system, such as RHEL 7, Scientific Linux, and Oracle Linux. You will be able to perform installation, establish network connectivity and user and process management, modify file permissions, manage text files using the command line, and implement basic security administration after covering this book.

By the end of this book, you will have a solid understanding of working with Linux using the command line.

Publication date:
December 2018


Chapter 1. Getting Started with CentOS 7

Community Enterprise Operating System, commonly referred to as CentOS, is a fast, stable, and open source enterprise-grade Linux distribution used on laptops, desktops, and servers. It is derived from the source code of Red Hat Enterprise Linux (RHEL), which is developed and maintained by the CentOS community. All proprietary content related to Red Hat Inc. is removed from the CentOS packages, which are then recompiled with CentOS community assets, such as logos and so on. CentOS 7 is an exact replica of RHEL 7, but is available for free with community support and updates. The CentOS project is now officially sponsored by Red Hat Inc. and is most suitable for environments where commercial support for operating systems is not mandatory.

In this chapter, we will give you a walk-through on how to install CentOS 7 on your computers. After installation, we will introduce you to the command-line console of Linux in order to use Bash (short for Bourne Again Shell). This chapter teaches you how to set up your environment to perform all the exercises in the following chapters of this book.

In this chapter, we will cover the following:

  • Preparing to install CentOS 7
  • Performing manual installation
  • Accessing the command line using the console
  • Introducing the Bash shell
  • Bash shell and command execution

Preparing to install CentOS 7

The CentOS community released its latest operating system version with the name CentOS 7.6-1810, where 7.6 comes from RHEL 7.6 and 1810 shows its release date (October 2018). CentOS 7.6 can be installed on physical or virtual hardware. You can use any of the main desktop virtualization software utilities, such as Oracle VirtualBox (https://www.virtualbox.org/wiki/Downloads) or VMWare Workstation (https://www.vmware.com/products/workstation-pro/workstation-pro-evaluation.html), as per your environment. My choice for desktop virtualization software is VirtualBox as it is free, open-source, and easy to use. You will also need a working internet connection to download the CentOS image from the community download page.


Those are using Linux as their base operating system can also use KVM for virtualization.

Getting the right hardware

For a minimal installation of CentOS 7.6, the following hardware requirements must be met:

  • 512 MB RAM
  • 4 GB HDD space
  • A network card

However, to practice all the exercises described in this book, we recommend that the following hardware requirements are met:

  • 64-bit architecture support
  • 1 GB RAM
  • 10 GB HDD space
  • DVD drive or USB memory stick
  • A network card

Getting the software

There are different ways to get the software required to perform all the exercises in this book. However, the easiest and most flexible way is to download the iso file from the CentOS website and burn it to a DVD, or create a bootable USB drive with CentOS. Then, boot your PC using the ISO DVD image if you are using a virtual machine. If you are installing onto a physical system, then use a bootable USB drive or burned CentOS DVD for installation.

Use the following link to download the CentOS 7.6 (64 bits) ISO image file: 



You can download MD5 and SHA1 hashes of the image file downloaded from CentOS site. The downloaded image should have the same hash as the one posted on the CentOS website.

Finalizing server setup details

Once you have the right hardware and software for the CentOS installation, you should decide on the basic setup parameters to be specified while performing the installation. The following table lists the details we will use during the installation of our CentOS 7.6 server described in this chapter:

Setup parameter

Sample values

IP address




Root password

[email protected]

User name


User password

[email protected]


Performing manual installation

Nowadays, the fastest and easiest way to install CentOS is to use a bootable USB drive; however, in our case, I have chosen to use the DVD ISO image with a virtual machine. First, we need to boot the computer system/virtual machine using the DVD. On booting from the DVD, you will get a cool CentOS screen displaying the basic installation options, and testing the media and troubleshooting options.Once your system/virtual machine is up and running with a bootable DVD of CentOS 7, follow these steps to install CentOS on your system:

  1. We have to choose theInstall CentOS 7 option and press Enter, as shown in the following screenshot.This will start the graphical installer and ask about the language to be used during the installation process:

  1. Now,you will see a WELCOME TO CENTOS 7 screen, prompting you to choose your language and keyboard settings. Choose your respective language and keyboard settings andclick on the Continue button, as shown in the following screenshot. In my case, I have chosenEnglish:

  1. After this,youwill see an INSTALLATION SUMMARY screen.From this screen, you can specify the settings you want to use for the threedifferent sections and their sub-sections, as shown in the following screenshot:

On this screen, the Begin Installation button will remain disabled as long as any setting from a section or subsection displayed on the INSTALLATION SUMMARY screen is still incomplete. If all the sections and subsections displayed on this screen are complete with minimum installation instructions, only then will the Begin Installation button be enabled.

By default, the installer does automatic partitioning for our hard disk. If we want to use the default layout, then we must click on INSTALLATION DESTINATION, and then approve the disk device we want to use for automatic partitioning by clicking on the Done button on the next screen. Thereafter, the Begin Installation button will be enabled and we can install CentOS with a minimal configuration, as shown in the following screenshot:


The minimal installation of CentOS 7 doesn’t have a graphical interface—it has a bare minimum set of packages installed, with limited features available in the command-line interface.

  1. If you are a beginner and want to useCentOS 7 with a graphical user interface (GUI), then follow these installation instructions. In this step, we'll learn about the usage of CentOS and then modify certain options that need to be configured during installation. The INSTALLATION SUMMARY screen has three sections, as follows:
    • SYSTEM

These three sections are explained as follows:

  • LOCALIZATION: This section further contains the following three sub-sections for configuration:
    • DATE & TIME

Or these three, the DATE & TIME sub-section is often required to be configured. The other two we have already configured in the previous steps.

In theDATE & TIMEoption, select the time zone that you are in by clicking on your location on the world map. You can also configure your current specificDATE & TIME from this window, as shown in the following screenshot:

We leave theKEYBOARD and LANGUAGE SUPPORT settings at their defaults, and move to the next section to be configured—in this case,SOFTWARE.

  • SOFTWARE: This section further contains two sub-sections for configuration:

Under theSOFTWARE section, we keepINSTALLATION SOURCE set to its default local media (DVD-ROM), as shown in the following screenshot:

The next sub-section for configuration is SOFTWARE SELECTION. This forms an important part of the installation procedure. Click on this option and you will get the screen shown in the following screenshot. From here, you can choose the default base environment and add-ons that are available for the selected environment. For our practice demonstration, we will install the GNOME Desktop base environment with four add-ons: GNOME Applications, Office Suite and Productivity, Development Tools and System Administration Tools as shown in the following screenshot:

  • SYSTEM: This section further contains four sub-sections for configuration:
    • KDUMP

In this section, we keep the KDUMP and SECURITY POLICY sub-sections set to their default parameters, and configure the two remaining sub-sections as follows:

Inthe INSTALLATION DESTINATION sub-section, we specify where we want to install CentOS. Automatic partitioning is selected by default, but wecan create a manual partitioning scheme of our own as per our requirements. As a bare minimum standard, we will create the following three partitions:

    • Boot partition: This partition stores bootable filessuch as the kernel image, and so on.
    • Swap partition: This is for swapping files and programs in and out of the RAM. It is generally twice the size of the RAM.
    •  Root (/)partition: This contains the Linux filesystem.

The following screenshot shows where to click to create manual partitions:

  1. Choose the device onto which to install the OS, and select I will configure partitioning. Finally, click on the Done button to proceed with the creation of multiple partitions as shown in the following screenshot:

  1. Now, we create a minimum of three partitions in the partition table (boot, swap, and /). In my case, I have kept File System as xfs, with the StandardPartition type for the boot and / partitions. For the swap partition, the File System type is kept as swap, as shown in the following screenshot:

  1. Next, on pressing Done, you will get the SUMMARY OF CHANGES dialog box. Click on the Accept Changes button to begin creating on the disk the partitions that we specified in the partition table, as shown in the following screenshot:

  1. NETWORK & HOST NAME: In this final part ofthe installation summary, which we'll configure networking. You can leave the default settings as they are to get the IP address from the DHCP server, or click on NETWORK & HOST NAME to set up networking manually. From the dialog box, click on theIPv4 Settings Tab, then choose the method as Manual from drop-down menu and specify the private IP address, as shown in the following screenshot:

Further in the NETWORK & HOST NAME settings, change the network connection state from Off to On, as shown in the following screenshot:

  1. Now that all the INSTALLATION SUMMARY sections are configured as required, the Begin Installation button is enabled. Click on the Begin Installation button to start the process of installation, as shown in the following screenshot:
  1. Next, the screen prompts for user settings. Here, we click Root Password first and set the password to [email protected].
  1. Next, we click on CREATE USER to create a user. For both the Full name and User name fields, enter student, and set Password as [email protected]. Here also we have to click on the Done button twice to confirm the password, as shown in the following screenshot:

  1. Have a cup of coffee while the installation process is in progress. Once the installation is complete, remove any installation media (the instructions only apply to the DVD method) and click on the Reboot button, as shown in the following screenshot:

  1. Once the system has rebooted, we will get the INITIAL SETUP screen, where we have to accept an EULA agreement before logging in to the system. Here, we click on LICENSE INFORMATION to accept the license agreement, as shown in the following screenshot:
  1. Once the license agreement has been accepted, the FINISH CONFIGURATION button will become enabled. Click on it to reach the login screen.
  1. On the login screen, click on the student username and enter the password as [email protected], as shown in the following screenshot:
  1. After a successful login, you will see the welcome screen that is displayed only when the user LOGS IN for the first time. Click on the Next button to reach the desktop.
  2. Congratulations! You have successfully installed the latest version of CentOS 7 on your computer system or virtual machine.You can explore your new CentOS 7 environment and perform other tasks, such as updating the system or installing other useful software for daily operational requirements. To power down the system, click on the right corner of desktop. You will get a drop-down menu; from there you can click on Shut down, as shown in the following screenshot:

With this, your installation process is complete. In the upcoming section, we will learn how to access the command-line console.


Accessing the command line using the console

When using CentOS, systemadministration or applications development tasksareperformed using either thecommand-line interface (CLI), such asthe Bash shell, or with the help of a GUI, such as GNOME, KDE, and so on. In this section, we will learn how to enter commands in the Bash shell at the Linux console.

Starting a Terminal 

When you log in to a Linux system in CLI mode or open a Terminal, it displays a string where it waits for user input (a command). This is known as a shell prompt.

To access a shell prompt in the GUI environment, you have to start a Terminal application, such as GNOME Terminal. There are multiple ways to launch a Terminal. The most frequently used ways to access a Terminal are as follows:

  • Select Applications | System Tools | Terminal
  • Right-click anywhere on your Terminal and select Open in Terminal from the context menu that pops up
  • From the activities overview, select Terminal

If you have started the Terminal application as a normal user, then the default prompt ends with a $ character, as shown in the following screenshot:

A normal shell prompt lists the following three details:

  • The login name of the current user
  • A short hostname of the machine, also known as the machine name
  • The name of the current working directory


The tilde (~) sign in the shell prompt represents the user's home directory. We will learn more about this in the following chapter.

If you have started or switched to the shell as a root user, also known as a superuser or administrator, then the prompt ends with a # character, as shown in the followingscreenshot:

The default shell of CentOS 7 is Bash, which provides a scripting facility for the automation of repeated tasks. The main functionality of any shell is to interpret the commands entered by the user at the prompt, and to provide a platform to launch any other program.


The default shell of Unix distributions is generally set as the Bourne shell. It is similar to the Microsoft Windows's Command Prompt application, cmd.exe. Windows 7 and Windows Server 2008 R2 onwards include Microsoft PowerShell, which is very similar in functionality to Bash.

There are two ways to access the shell. The first method is via the Terminal. When you install Linux without a GUI (as in a text-based installation), this can be the Linux machine's physical console, consisting of a keyboard for user input and a display to show output.

The second method is by using the shell from a virtual console. The Linux machine's physical console supports multiple virtual consoles, which act as separate Terminals with independent login sessions. If the GUI is installed, then the first virtual console is the GUI in CentOS/RHEL. In addition to the first graphical environment, five pure text-based environments are also available on a virtual console with which you can access a login shell. Ctrl + Alt + (F2 through F6) are text-based and Ctrl + Alt + F1 is the graphical desktop.

Command-line syntax and structure

Any command entered at the shell prompt can be broken down into three parts:




The name of the application to be executed


This modifies the behavior of the command; options are generally prefixed with one or two hyphens


These generally indicate the target on which the command is be applied

A command can consist of one or more options and can take one or more arguments, depending upon its syntax. Understanding the syntax of commands will tell you all about the options and arguments it can take, and in what order. To view the syntax of a command, we can use the --help option or view the manual page. The usage of the mkdir command with its options is shown in the following screenshot:

Initially, you may find the output of the --help option a bit confusing. However, it becomes much simpler once you understand the basic conventions used in the syntax, discussed as follows:

  • Square brackets, [ ], enclose optional items. For example, it is not mandatory to execute the mkdir command with any option, as shown in the following command line:
$ mkdir mydirectory
  • Ellipses, …, represent a list of more than one item of a given type. For example, we can use multiple options, such as -m and -p or -v, together with the mkdir command as shown in the following command line:
$ mkdir -p -v demo/linux/centos
  • Text given in angled brackets, <>, represents variable data. Sometimes, variable data is also written in capital letters. For example, DIRECTORY.. in mkdir means we have to insert the directory name we want to use with the mkdir command.
  • Multiple items separated by pipes (|), mean that only one of those items can be specified.

Exiting the shell

There are multiple ways to quit the shell, when you have finished using it and you want to end your session. Some of the most popular options to exit the shell are as follows:

  • Typing the exit command anytime on the console terminates the current session.
  • Pressing the Ctrl + D keys together is also a shortcut quite often used to terminate the current session.

Introducing the Bash shell

The GNU Bash is primarily aprogram that interprets commands entered by the user at the prompt. As we learned in the previous Command line syntax and structure section, each command entered by the user can have three parts:

  • The command
  • The options (beginning with - or --)
  • The arguments

Each word entered in the shell is separated from the others with a space. Commands are the names of various applications installed on our system, where each command has its own options and arguments.

When you want to execute a command entered at the prompt, the Enter key is pressed. After the Enter key is pressed, output from that command is displayed on the shell, which is followed again by the prompt as shown in the following screenshot:

Each command is entered on a single line; however, if you wish you can enter multiple commands on a single line using the semicolon (;), which acts as a command separator.

The various functions performed by the shell include the following:

  • It provides an interface between the user and operating system
  • It is a way for the user to execute commands and other programs
  • It acts as an command-line interpreter for commands entered at the command prompt
  • Shell also enables the automation of tasks by reading commands from a special text file, known as a shell script
  • Shell provides an environment for users and programs running on the operating system

There are multiple types of shell installed on each Linux distribution, with slight differences in features among them. The Bourne shell (sh) is the most primitive, and the Bash shell is the most advanced. The differences between these shells are listed in the following table:







Background processing






Command history






I/O redirection






Shell scripts






Command alias






File name completion






Command completion






Command line editing






Job control








Bash shell and command execution

In this section, we will learn about the different features of the Bash shell with which you can reduce errors and increase the speed at which you work on the Terminal.

Tab completion

Linux shell syntax is case-sensitive as well as space-sensitive, so typing errors are the first major hurdle in learning for any beginner. However, if the tab completion feature is adopted by a beginner, then it makes life very easy and smooth by reducing typing errors to a minimum.

Tab completion enables you to complete commandnamesor file names once you have typed enough characters at the prompt to make it unique. If the characters entered at prompt are not unique, pressing the Tab key twice displays all commands that can begin with the character already entered into the command line. An example of command completion using the Tab key is shown in the following screenshot:

The Tab completion feature can be used to complete file names or path names when typing them as argument to commands. Pressing the Tab key once completes the filename or path if it is unique; otherwise, pressing the Tab key a second time lists all the possible combinations of filenames or path names based on the current pattern. Thereafter, you can type additional characters to make the name or path unique, and press the Tab key again for completion of the command line. An example of path and filename completion using the Tab key is shown in the following screenshot:

Command-line editing shortcuts

Bash has a very useful command-line editing feature that can increase your productivity while working on the Terminal. It enables the user to use some shortcut commands to move around or delete characters on the command prompt. 

The following table lists themost usefulcommand line shortcuts available in Bash:



To move the cursor


Ctrl + A

Moves the cursor to the beginning of the command line

Ctrl + E

Moves the cursor to the end of the command line

Ctrl + Left arrow

Moves the cursor to the beginning of the previous word on the command line

Ctrl + Right arrow

Moves the cursor to the beginning of the next word on the command line

To delete characters


Ctrl + U

Deletes the characters from the current cursor position to the beginning of the command line

Ctrl + K

Deletes the characters from the current cursor position to the end of the command line

Ctrl + W

Deletes the last word from the current cursor positing on the command line

Ctrl + L

Clears the screen (you can also type the clear command)

To modify the size of the Terminal window


Ctrl + +

Increases the size of the Terminal window

Ctrl - -

Decreases the size of the Terminal window

The history command

The history command is used to display a list of previously executed commands prefixed with a command number showing the order of their execution, as shown in the following screenshot:

The exclamation point character (!) is a metacharacter in Bash,used forpreviously executedcommandexpansionfrom history liston prompt.

The following table lists various history commands that are quite useful for beginners:




Expands to the command matching the specified number from history


Expands to the most recently used command that begin with the string specified at the prompt

history -d <number>

Used to delete the numbered command from history

history -c

Empties the history list

Ctrl + R

Searches the history list of commands for a pattern, and executes the most recent match when found


The following screenshot displays the usage of the history command:

Besides the already listed options, we can use the arrow keys for navigation between the previous and next command line in the shell's history. The Up arrow key brings up the previous command executed from the history list. The Down arrow key brings up the next command from the history list.

Command aliases

The alias command is used to create an alias name or nickname for frequently used commands. It simplifies the administration process by providing alias names for long commands or even combinations of commands.

Listing current aliases

To list the currently configured aliases for your shell, just type alias without any argument at the prompt, as shown in the following command line:

$ alias

Setting an alias

The following syntax is used to set an alias x for the exit command. Thus, after setting this alias, whenever you want to exit from Terminal, you just have to enter x at the prompt:

$ alias x="exit"
$ alias c="clear"

Removing an alias

To remove an alias, the unalias command is used. For example, to remove the previously setalias, we use the unalias command as follows:

$ unalias x


The alias command will set its alias for the current session only. If you want to set an alias for any command persistently, you have to make an entry for it in /etc/bashrc for system-wide changes, and if you want to make user-specific changes, than put its entry in the .bashrc file stored in the user's home directory.



In this chapter, we started our journey learning CentOS 7. First, we began with the installation process, which was followed by an introduction to the Bash shell and command line syntax and structure. We then mastered the basic features of running commands from the shell with fewer strokes with the help of the Tab key, command-line shortcuts, history, and aliases.

In our next chapter, we will continue our journey through CentOS 7, looking at the Linux file system hierarchy and other essentials.

About the Author

  • Shiwang Kalkhanda

    Shiwang Kalkhanda (RHCA, RHCSS, MCSE) is a Linux geek and consultant with expertise in the automation of infrastructure deployment and management. He has more than 10 years' experience in security, system, and network administration, and training on open source tech. For most of his automation work, he uses Shell Scripting, Python, and Go. He holds a master's and a bachelor's degree in computer applications. He enjoys traveling and spending time with his children. He is also the author of a book on text processing utilities in Unix-like environments, Learning Awk Programming.

    Browse publications by this author

Recommended For You

Docker on Windows - Second Edition

Learn how to run new and old applications in Docker containers on Windows - modernizing the architecture, improving security and maximizing efficiency.

By Elton Stoneman
Mastering Windows Server 2019 - Second Edition

Enhance and secure your datacenter with the newest Microsoft server platform

By Jordan Krause
Networking Fundamentals

Become well-versed with basic networking concepts such as routing, switching, and subnetting, and prepare for the Microsoft 98-366 exam

By Gordon Davies
Hands-On Application Development with PyCharm

A definitive guide to PyCharm to help you build business-oriented Python applications ranging from modern web development to data science

By Quan Nguyen