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.
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.
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:
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
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>
SELinux operates in three modes:
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.
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
To configure a static IP address on a network interface, edit the network configuration files and restart the network service.
ip a
or ifconfig
./etc/sysconfig/network-scripts/
, named ifcfg-<interface>
, e.g., ifcfg-eth0
.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
systemctl restart network
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
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:
Edit the crontab file with:
crontab -e
Add the cron job line to schedule your script.
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
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.