CentOS 7 server VirtualBox tutorial. How to setup and install, part 3.

centos virtualbox horizontal

This is part 3 of the 6 part tutorial series that shows how to install CentOS 7 on VirtualBox.

Part 1 is on the installation and setup of VirtualBox.

Part 2 is on the installation of CentOS 7.

Part 3, part 4 and part 5 is on the configuration of CentOS 7 as well as installation of some nice to have third party software’s.

Part 6 is on general security.


First thing to do is to login in with “root” by using the password we provided in the previous part of this tutorial. After you have successfully logged in your screen will look the picture below.

1


Press “LeftCTRL + L” to clear the screen.

Let’s check if we have any kind of connection to the internet. Type in the command below and press ENTER.

1.1

Here we can clearly see that the ethernet has a STATE of “disconnected”.

And if we try to ping Google DNS servers using the command:

Then we get the output “connect: Network is unreachable.”


Since there is not that much we can do without internet access we will be fixing that first of all.

Start of by changing directory to this path /etc/sysconfig/network-scripts/.

Now let us list all of the files in this folder.

What we get is something like the picture below.

2

The file that is of any interest for us right now is ifcfg-enp0s3. So let us edit this file by using the vi text editor. Don’t worry if you have not used this text editor before as I will explain how to do everything.

Open up the file using the command below.

3

The first thing to take note of is the last line where it says ONBOOT=no.

We are going to change this to ONBOOT=yes.

Now the way vi text editor works is changing “modes”. Now we are in the “READ mode”. To be able to edit the file we need to be in the “INSERT mode”. To get to “INSERT mode” we simply press the i button on the keyboard.

After you have pressed i on the keyboard you will see the program show — INSERT — on the lower left corner just like you see in the picture below.

4

Now you will be able to freely move the cursor using the arrow keys. Navigate to ONBOOT and replace the “no” with “yes” as shown below.

5

Since you are still in the “INSERT mode” what you need to do now is to press ESC once. The — INSERT — in the lower left corner should have isappeared now. That means you are in the “READ mode”. We are going to try another mode where you are able to write commands to the text editor. Let us
call this mode “COMMAND mode”. You can get to this mode simpy by pressing SHIFT + . which is the same as a colon :. After the colon has appeared in the lower left corner, input “wq” which stands for “write quit”.

6

Press ENTER and the file should now be saved.


Before we can see the effects of the changes we need to do a network restart.

If all went well you should see and output similar to this:

7


Now if we try doing what we did before we will hopefully get another output this time.

Now we have a STATE of “connected”. Which is good.

8

And if we try to ping Google DNS servers again

9

We can see that it works as expected. Press CTRL + C to cancel the pinging.


Now that we have internet access, the first thing we are going to do is update everything.

The -y flag stands for “yes”, so you automatically enter yes for every promt it makes. It not a very big deal but saves us some effort at this point.

This might take a while so just sit back and relax or grab yourself some coffee while waiting.

It will let you know when it has completed the update.

10


Now a good thing to do would be to make sure we have a good hostname.

To change the hostname we need to locate a file called hostname in the /etc folder.

There is not too much in this file at the moment.

Go to “INSERT mode” by pressing i.

Remove the current contents of the file.

Add the line “centos7.local”

Now your screen should look something like this:

11

Since you are still in “INSERT mode”, the — INSERT — still shows up in the lower left corner. Press ESC once and it will disappear. Once it is gone press CTRL + ., or simply write a colon :. And once the colon appears type in “wq”, for “write quit”.

Press ENTER to save the file.

We are going to edit one more file that is located in the same /etc folder.

To make things simple here we just leave the contents of the file as it is, and add a new line to it which is “127.0.0.1    centos7.local”.

Your screen should look something like this:

12

Once you have everything correct just do the same procedure to save on the vi text editor. Go to “COMMAND mode”, input :wq and press ENTER and you are done.

Let’s do a reboot now.


To see if your hostname was successfully changed type in the command

13

If the output is “centos7.localhost” then you know it was a success.


Good job! This is the end of part 3 of this tutorial series.

Click here for part 4.

Leave a Reply

Your email address will not be published. Required fields are marked *