Hey there!
Recently I had to create a new VM with CentOS on it and thought that I could write these things down to help myself in the future. Hopefully, these notes will help you too 🙂
Create the Virtual Machine
First of all, let’s get an iso image withe CentOS, to start fresh I’ll be using the “Minimal ISO”, you can download it from https://www.centos.org/download/, just click on the “Minimal ISO” button.
While downloading create a new VM using your favorite software, I’ll be using VMware Workstation 14 Player.
Everything is quite self-explanatory so I’ll just paste the screenshots.
Install CentOS using the Minimal ISO image
When booting from the ISO downloaded before firstly check if it isn’t corrupted. This will only take a moment of your time.
When everything is ok you can continue installing the operating system on your VM.
Once again I’ll paste some screenshots from the process because once again it’s not really complicated.
Now just restart the VM. After rebooting you can log in to your machine using the root account or the other one which was created during the installation process. I’ve logged in as miko
Next thing I encourage you to do is to run the sudo yum update
command. It will update all packages with available updates.
When executing this command with a non-root user miko
 we’ll get this error:
Add user to sudoers file
We can’t really do anything fun with this account, let’s switch to the root
user and fix this problem by adding my non-root user miko
to the sudoers
file located in /etc/sudoers
. The fastest way to doing so is by running these commands:
- Switch to the root account
su root
- Open the sudoers file
visudo
OR
vi /etc/sudoers
Tips for using
vi
:- to edit a document press
INSERT
- to stop editing press
Esc
- to quit type
:q
and pressEnter
- to save and quit type
:wq
and pressEnter
- to edit a document press
- Find the line which contains the phrase ## Allow root to run any commands anywhere and add a new line underneath the one regarding the
root
userUSERNAME ALL=(ALL) ALL
In the end it should look something like this:
## Allow root to run any commands anywhere root ALL=(ALL) ALL miko ALL=(ALL) ALL
- Save the file by pressing
ESC
, typing:wq
and pressingEnter
- To check if everything works like it should switch back to the non-root account
su username
- Once more try to update all of the installed packages
sudo yum update
Setup network on CentOS Minimal install
It looks like we have the required privileges but can’t connect to the repository due to a network error. That’s because when installing CentOS from the Minimal ISO you have to manually turn on the network adapter and ideally make it to connect automatically every time we spin up the OS. To do so we have to:
- List the Ethernet cards installed on your machine
nmcli d
- Start Network Manager
nmtui
- Choose
Edit a connection
- Choose your network interface and press
Edit...
- Check on the
Automatically connect
option, pressOK
and quit Network Manager - Reset network services (not always required)
service network restart
- Once again list ethernet cards installed on the machine
nmcli d
Now when running the command sudo yum update
you will get this:
Installing GUI on CentOS
The fastest way to install the GUI is to use the yum group
option, let’s do it:
- List all groups that are available to install
yum group list
- Install the GNOME Desktop environment
sudo yum group install "GNOME Desktop"
- Wait till it’s done installing…
- Start GUI
startx
- To autostart the GUI run this command
sudo ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target
- Reboot the VM to check if everything works
reboot
Looks great, doesn’t it?
I hope that this post was helpful. If you have any questions feel free to leave a comment below.
Be First to Comment