Interview

10 Linux RHEL Interview Questions and Answers

Prepare for your next technical interview with our comprehensive guide on Linux RHEL, featuring common and advanced questions to boost your skills.

Linux Red Hat Enterprise Linux (RHEL) is a leading enterprise operating system known for its stability, security, and performance. Widely adopted in various industries, RHEL is the backbone of many critical systems, from servers and cloud environments to container orchestration and virtualization. Its robust ecosystem and extensive support make it a preferred choice for organizations looking to ensure reliability and scalability in their IT infrastructure.

This article offers a curated selection of interview questions designed to test your knowledge and proficiency with RHEL. By working through these questions, you will gain a deeper understanding of key concepts and practical skills, enhancing your readiness for technical interviews and boosting your confidence in handling RHEL-related tasks.

Linux RHEL Interview Questions and Answers

1. Describe the purpose of the /etc directory and name three types of files you would expect to find there.

The /etc directory in Linux RHEL is the central location for system configuration files. It contains configuration files and shell scripts necessary for system initialization and management.

Three types of files you would expect to find in the /etc directory are:

  • System Configuration Files: These files configure the system’s behavior and settings, such as /etc/passwd for user account information and /etc/fstab for disk drives and partitions.
  • Application Configuration Files: These files configure installed applications, like /etc/httpd/conf/httpd.conf for Apache HTTP Server and /etc/ssh/sshd_config for the SSH server.
  • Startup Scripts: These scripts manage system services, found in /etc/init.d/ and symbolic links in /etc/rc.d/ for service startup at different run levels.

2. Explain how you would install, update, and remove a package using YUM or DNF.

YUM and DNF are package managers in RHEL for managing software packages, handling installation, updating, and removal while resolving dependencies.

To install a package, use:

sudo yum install package_name
# or
sudo dnf install package_name

To update a package:

sudo yum update package_name
# or
sudo dnf update package_name

To remove a package:

sudo yum remove package_name
# or
sudo dnf remove package_name

3. How would you start, stop, enable, and check the status of a service using systemd?

Systemd is a system and service manager in RHEL. To manage services, use the systemctl command.

To start a service:

sudo systemctl start <service_name>

To stop a service:

sudo systemctl stop <service_name>

To enable a service at boot:

sudo systemctl enable <service_name>

To check the status of a service:

sudo systemctl status <service_name>

4. What are the different modes of SELinux, and how would you change the mode?

SELinux operates in three modes:

  • Enforcing: SELinux policy is enforced, granting or denying access based on rules.
  • Permissive: Policy is not enforced, but violations are logged for troubleshooting.
  • Disabled: SELinux is turned off, and no security contexts are checked.

To change the SELinux mode temporarily, use setenforce:

setenforce 0  # Permissive
setenforce 1  # Enforcing

For permanent changes, edit /etc/selinux/config and set SELINUX to enforcing, permissive, or disabled. Reboot for changes to take effect.

5. How do you add a new user and assign them to a specific group?

To add a new user and assign them to a specific group, use the useradd command with the -G option:

sudo useradd -G groupname username

Set a password for the new user with passwd:

sudo passwd username

6. Describe the steps to configure a static IP address on a network interface.

To configure a static IP address on a network interface, edit the network configuration files and restart the network service.

  • Identify the network interface using ip a or ifconfig.
  • Edit the configuration file in /etc/sysconfig/network-scripts/, named ifcfg-<interface>, e.g., ifcfg-eth0.
  • Include the static IP address, netmask, gateway, and DNS servers:
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=8.8.4.4
  • Save changes and restart the network service:
systemctl restart network

7. How would you create a new partition and logical volume using LVM?

To create a new partition and logical volume using LVM:

1. Create a new partition: Use fdisk or parted to create a partition and set its type to Linux LVM (type 8e).

2. Create a physical volume (PV): Initialize the partition as a PV with pvcreate:

   pvcreate /dev/sdX1

3. Create a volume group (VG): Use vgcreate to create a VG:

   vgcreate my_volume_group /dev/sdX1

4. Create a logical volume (LV): Use lvcreate to create an LV:

   lvcreate -L 10G -n my_logical_volume my_volume_group

5. Format the logical volume: Format with a filesystem, e.g., ext4:

   mkfs.ext4 /dev/my_volume_group/my_logical_volume

6. Mount the logical volume: Create a mount point and mount the LV:

   mkdir /mnt/my_mount_point
   mount /dev/my_volume_group/my_logical_volume /mnt/my_mount_point

8. Write a cron job that runs a script every day at midnight.

To set up a cron job that runs a script every day at midnight, edit the crontab file:

0 0 * * * /path/to/your/script.sh

Explanation:

  • First field (0): minute (0th minute).
  • Second field (0): hour (0th hour, midnight).
  • Third field (*): day of the month (every day).
  • Fourth field (*): month (every month).
  • Fifth field (*): day of the week (every day).
  • Last field: path to the script.

Edit the crontab file with:

crontab -e

Add the cron job line to schedule your script.

9. How do you list all currently loaded kernel modules and load a new module?

To list all currently loaded kernel modules, use lsmod:

lsmod

To load a new kernel module, use modprobe:

sudo modprobe example_module

To remove a loaded module, use rmmod:

sudo rmmod example_module

10. Explain how to open a specific port in the firewall using firewalld.

Firewalld is a dynamic firewall management tool in Linux. To open a specific port, use firewall-cmd:

sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent
sudo firewall-cmd --reload

The first command opens port 8080 for TCP traffic in the public zone and makes the change permanent. The second command reloads the firewall to apply the changes.

Previous

15 Canvas App Interview Questions and Answers

Back to Interview
Next

10 L2 L3 Protocols Interview Questions and Answers