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 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
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
- Open the sudoers file
Tips for using
- to edit a document press
- to stop editing press
- to quit type
- to save and quit type
- 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
USERNAME 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
- To check if everything works like it should switch back to the non-root account
- 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
- Start Network Manager
Edit a connection
- Choose your network interface and press
- Check on the
Automatically connectoption, press
OKand quit Network Manager
- Reset network services (not always required)
service network restart
- Once again list ethernet cards installed on the machine
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
- 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
Looks great, doesn’t it?
I hope that this post was helpful. If you have any questions feel free to leave a comment below.