Skip to main content

CentOS Server Setup & Configuration


Overview

This document provides a step-by-step guide for setting up and configuring CentOS Server as a virtual machine, including installation, user setup, networking, and essential post-installation tasks.


1. Creating the CentOS VM (Hyper-V)

  • Open Hyper-V Manager and create a new VM named CentOS Server.
  • Use Generation 2 and allocate 4GB RAM.
  • Create a 20GB dynamically expanding virtual hard disk.
  • Attach the CentOS Stream ISO as the installation media.
  • Use the Default Switch for networking (DHCP).

2. Installing CentOS Server

  • Boot the VM and start the CentOS installer (Anaconda).
  • Set language and keyboard layout.
  • Set timezone and enable NTP.
  • Choose Server with GUI or Minimal Install.
  • Select the 20GB disk and use automatic partitioning.
  • Enable the Default Switch for network connectivity.
  • Set hostname (e.g., mycentosserver).
  • Set a strong root password and create a regular user (optionally with sudo privileges).
  • Begin installation and reboot when complete.

3. Post-Installation Steps

  • Log in with your user account.
  • Update the system:
    sudo dnf update
  • Install essential tools:
    sudo dnf install net-tools curl vim
  • Enable and start SSH if needed:
    sudo systemctl enable sshd
    sudo systemctl start sshd

4. Networking

  • By default, the VM uses DHCP via the Default Switch.
  • To set a static IP, edit /etc/sysconfig/network-scripts/ifcfg-eth0.
  • Restart networking:
    sudo systemctl restart network

5. File Sharing (Samba)

  • Install Samba:
    sudo dnf install samba samba-common samba-client
  • Configure /etc/samba/smb.conf for your share.
  • Set permissions and add a Samba user:
    sudo smbpasswd -a <username>
  • Start and enable Samba services:
    sudo systemctl start smb nmb
    sudo systemctl enable smb nmb
  • Allow Samba through the firewall:
    sudo firewall-cmd --permanent --add-service=samba
    sudo firewall-cmd --reload

6. Security & SELinux

  • For testing, SELinux can be set to permissive:
    sudo setenforce 0
  • For production, configure SELinux policies for Samba instead of disabling.

7. Documentation & Resources

  • All configuration files and scripts are documented in the project repository.
  • For troubleshooting, check service status with systemctl status and review logs in /var/log/.

References