esc
Type to search across all notes

CentOS 7

Install CentOS 7 to dual boot with Windows 10

Preparation

The hardware is ThinkPad SL410 with Windows 10 installed, 8 GB memory, 120 GB solid state drive, 320 GB hard disk drive. Windows 10 and CentOS 7 will be installed on the solid state drive.

A USB drive with free space more than 8GB is needed as the bootable USB drive. Download CentOS 7 ISO image from https://www.centos.org/download/. Download Rufus from https://rufus.ie/en/, it is used for creating the bootable USB drive. Burn the CentOS 7 ISO image into the USB drive to make it bootable.

Create a new partition with 40 GB free space. In Windows disk management, create a partition by shrinking the volume from the existing partition.

Installation

Plug the USB drive and reboot the computer, pause the startup to set to boot from the USB drive in BIOS options.

Follow the steps displayed when the CentOS anaconda installer starts. In the Software Selection, I choose minimal installation, which has no desktop environment. Create the root password and a user.

Modify Bootloader OS options

GRUB (Grand Unified Bootloader) is used as the default bootloader. Windows Boot Manager is the Windows one, which does not support dual boot configuration.

To support dual boot, a new entry for Windows 10 will be added in the grub configuration file, it is located at /etc/grub.d/40_custom.

Reboot the computer, choose CentOS, modify this file, and append the following lines to the file.

menuentry "Windows 10" {
        set root=(hd0,1)
        chainloader +1
}

Windows 10 is the label to be displayed in the menu options in GRUB. The hd0,1 means the Windows partition, which is the second partition in the first disk. The number may vary based on the disks and partitions.

Start using

Create a user other than root for daily use

It is common and recommended to use a non-root user for daily activities. Running as non-root user minimizes security risks by limiting system access and priviledges, which helps prevent accidental or malicious changes that could impact critical system files and configurations.

  • Log in as the root user or a user with sudo privileges.
  • Add the new user: adduser username
  • Set a password for the new user: passwd username
  • Grant sudo privileges (Optional): usermod -aG wheel username
  • Switch to the new user: su - username
  • Log out the current user: exit
  • /etc/passwd: stores information about all user accounts
  • /etc/shadow: stores password information for each user
  • /etc/group: lists all system groups
  • /etc/gshadow: contains group membership information with additional security information for group passwords
  • /etc/sudoers: defines who is allowed to run certain commands as root, recommended to edit using visudo. When granting root access by adding user to wheel, this modifcation is not needed.

Setup SSH Login

SSH (Secure Shell) is a protocol for secure remote login and other secure network services over an insecure network.

Install the SSH server: yum install openssh-server

Start the SSH server: systemctl start sshd

Enable the SSH server to start on boot: systemctl enable sshd

Check the status of the SSH server: systemctl status sshd

Configure the firewall to allow SSH connections: firewall-cmd --permanent --add-service=ssh

Reload the firewall to apply the changes: firewall-cmd --reload

Test the SSH connection from another machine: ssh username@hostname

To disable password authentication and use SSH keys instead, follow these steps:

  • Generate an SSH key pair on the client machine: ssh-keygen -t rsa -b 4096
  • Copy the public key to the server: ssh-copy-id username@hostname
  • Edit the SSH configuration file on the server: sudo vi /etc/ssh/sshd_config
  • Set PasswordAuthentication no to disable password authentication.
  • Restart the SSH service: sudo systemctl restart sshd

For more information, see https://phoenixnap.com/kb/how-to-enable-ssh-centos-7

Common operations

Start, shutdown the computer

  • Shutdown the computer: poweroff
  • Restart the computer: reboot

Prevent the computer from suspending when closing the lid

  • Open the /etc/systemd/logind.conf file for editing.
  • Find the HandleLidSwitch=suspend, replace the default suspend with ignore, save the changes.
  • Run the command # systemctl restart systemd-logind.service so that the changes preserve the next restart of the system.

Networks

  • Connect to WiFi: nmcli dev wifi connect my-wireless-ssid my-secret-password
  • Show connections: nmcli connection show
  • Connect via profile: nmcli connection up my-connection

Mount a USB drive, usually the USB drive is mounted at /mnt/myusb

  • Insert the USB drive
  • Identify the USB drive: lsblk
  • Create a mount point: sudo mkdir /mnt/myusb
  • Mount the USB drive: sudo mount [-t ntfs] /dev/sdb1 /mnt/myusb, the -t to specify file system is optional

Install Development tools

MySQL

See https://stackoverflow.com/questions/70993613/unable-to-install-mysql-on-centos7

Allow remote connection to MySQL server

check port connection in client

telnet 192.168.0.106 3306 (LAN IP)

check port listening in server

netstat -tulnp

check firewall info in server (port)

sudo firewall-cmd --list-all

add the port to the firewall

sudo firewall-cmd --zone=public --add-port=3306/tcp

sudo firewall-cmd --runtime-to-permanent

Change default temporary password

See https://dev.mysql.com/doc/refman/5.7/en/default-password.html

create a new user and grant remote access permission

SQL Server Express

See

Oracle 11g XE

See https://davidghedini.com/pg/entry/install_oracle_11g_xe_on_centos/

Java and JDK

JDK will be installed at /usr/lib/jvm/jdk-17

Install Temurin OpenJDK, see https://computingforgeeks.com/install-temurin-openjdk-on-centos-rhel-oracle-linux/

Apache Tomcat

Download apache_tomcat_9.x to /tmp

Extract to /opt/tomcat

Create tomcat users and groups

Change tomcat users permission to make tomcat the owner of tomcat

More info, see

References