1. Which command is used to create a new user in Linux?
adduser
usercreate
newuser
createuser
Show Answer
✅ Correct Answer: adduser
2. Which file stores user account information in Linux?
/etc/passwd
/etc/shadow
/etc/group
/etc/users
Show Answer
✅ Correct Answer: /etc/passwd
3. Which command is used to change file ownership in Linux?
chown
chmod
chgrp
usermod
Show Answer
✅ Correct Answer: chown
4. What is the default firewall service in RHEL 8?
firewalld
iptables
ufw
nftables
Show Answer
✅ Correct Answer: firewalld
5. Which command displays the disk usage of a directory in Linux?
Show Answer
✅ Correct Answer: du
6. Which file controls sudo privileges in Linux?
/etc/sudoers
/etc/privileges
/etc/sudoconfig
/etc/permissions
Show Answer
✅ Correct Answer: /etc/sudoers
7. Which command is used to list open network connections?
Show Answer
✅ Correct Answer: netstat
8. Which command is used to extract a tar.gz file?
tar -xzf file.tar.gz
tar -czf file.tar.gz
unzip file.tar.gz
extract file.tar.gz
Show Answer
✅ Correct Answer: tar -xzf file.tar.gz
9. What does the "ls -l" command display?
A detailed list of files
Only hidden files
Only directories
File sizes only
Show Answer
✅ Correct Answer: A detailed list of files
10. Which command is used to check the current runlevel?
runlevel
uptime
ps -aux
systemctl status
Show Answer
✅ Correct Answer: runlevel
11. Which command is used to reboot a Linux system immediately?
reboot
shutdown -r now
halt
init 6
Show Answer
✅ Correct Answer: reboot
12. Which command is used to display the current working directory?
Show Answer
✅ Correct Answer: pwd
13. Which command shows the last system boot time?
who -b
uptime
last
dmesg | grep boot
Show Answer
✅ Correct Answer: who -b
14. Which command is used to search for a specific string in a file?
Show Answer
✅ Correct Answer: grep
15. Which command is used to change the hostname in Linux?
hostnamectl set-hostname
hostname
sysctl hostname
hostconfig
Show Answer
✅ Correct Answer: hostnamectl set-hostname
16. Which command is used to remove a directory in Linux?
Show Answer
✅ Correct Answer: rmdir
17. Which command displays memory usage in Linux?
Show Answer
✅ Correct Answer: free
18. Which command lists all running processes?
Show Answer
✅ Correct Answer: ps aux
19. Which file stores system logs in Linux?
/var/log/syslog
/etc/log
/log/system
/log/messages
Show Answer
✅ Correct Answer: /var/log/syslog
20. Which command is used to schedule a cron job?
crontab -e
cron
taskadd
jobs -s
Show Answer
✅ Correct Answer: crontab -e
21. Which command is used to check disk space usage?
df -h
du -sh
lsblk
fdisk -l
Show Answer
✅ Correct Answer: df -h
22. Which command is used to kill a running process by name?
pkill
kill
terminate
stop
Show Answer
✅ Correct Answer: pkill
23. Which command is used to display active network interfaces?
ip a
ifconfig
netstat -i
route -n
Show Answer
✅ Correct Answer: ip a
24. Which command updates package repositories in RHEL?
dnf update
yum update
apt-get update
pkg update
Show Answer
✅ Correct Answer: dnf update
25. Which command changes file permissions in Linux?
chmod
chown
chgrp
setperm
Show Answer
✅ Correct Answer: chmod
26. Create a new user named "developer" with UID 1500 and home directory /home/dev
useradd -u 1500 -d /home/dev developer
adduser -u 1500 -h /home/dev developer
usermod -u 1500 -d /home/dev developer
newuser developer -u 1500 -h /home/dev
Show Answer
✅ Correct Answer: useradd -u 1500 -d /home/dev developer
27. Set the password for user "developer" to "RedHat123"
echo "RedHat123" | passwd --stdin developer
passwd developer <<< "RedHat123"
chpasswd developer:RedHat123
setpass developer RedHat123
Show Answer
✅ Correct Answer: echo "RedHat123" | passwd --stdin developer
28. Create a directory /data/share with permissions 775, owned by group "developers"
mkdir -p /data/share && chmod 775 /data/share && chgrp developers /data/share
install -d -m775 -g developers /data/share
newdir /data/share -m775 -g developers
mkfolder /data/share -perm 775 -group developers
Show Answer
✅ Correct Answer: mkdir -p /data/share && chmod 775 /data/share && chgrp developers /data/share
29. Mount /dev/sdb1 persistently to /mnt/data using XFS filesystem
Add "UUID=$(blkid -s UUID -o value /dev/sdb1) /mnt/data xfs defaults 0 0" to /etc/fstab then mount -a
mount /dev/sdb1 /mnt/data -t xfs -o defaults && echo "/dev/sdb1 /mnt/data xfs defaults 0 0" >> /etc/fstab
mkfs.xfs /dev/sdb1 && mount /dev/sdb1 /mnt/data
format /dev/sdb1 xfs && automount /mnt/data
Show Answer
✅ Correct Answer: Add "UUID=$(blkid -s UUID -o value /dev/sdb1) /mnt/data xfs defaults 0 0" to /etc/fstab then mount -a
30. Create a cron job that runs /usr/local/bin/backup.sh daily at 2:30 AM
crontab -e then add "30 2 * * * /usr/local/bin/backup.sh"
echo "30 2 * * * /usr/local/bin/backup.sh" >> /etc/crontab
addcron "30 2 * * * /usr/local/bin/backup.sh"
schedule -t daily -h 2 -m 30 /usr/local/bin/backup.sh
Show Answer
✅ Correct Answer: crontab -e then add "30 2 * * * /usr/local/bin/backup.sh"
31. Configure the system to automatically mount /dev/cdrom at /media/cdrom
Add "/dev/cdrom /media/cdrom iso9660 defaults,ro,user,noauto 0 0" to /etc/fstab
mount /dev/cdrom /media/cdrom && chmod 755 /media/cdrom
automount --device /dev/cdrom --target /media/cdrom
echo "cd /dev/cdrom /media/cdrom" >> /etc/autofs.conf
Show Answer
✅ Correct Answer: Add "/dev/cdrom /media/cdrom iso9660 defaults,ro,user,noauto 0 0" to /etc/fstab
32. Find all files in /var/log modified in the last 7 days and save the list to /root/logfiles.txt
find /var/log -mtime -7 > /root/logfiles.txt
ls -l /var/log/* | grep "7 days" > /root/logfiles.txt
locate /var/log -d 7 > /root/logfiles.txt
search /var/log -modified +7d -out /root/logfiles.txt
Show Answer
✅ Correct Answer: find /var/log -mtime -7 > /root/logfiles.txt
33. Configure the system to use 192.168.1.100 as its DNS server
Add "nameserver 192.168.1.100" to /etc/resolv.conf
echo "DNS=192.168.1.100" >> /etc/sysconfig/network
netconfig set dns 192.168.1.100
resolvectl add 192.168.1.100
Show Answer
✅ Correct Answer: Add "nameserver 192.168.1.100" to /etc/resolv.conf
34. Create a symbolic link /usr/bin/py3 that points to /usr/bin/python3
ln -s /usr/bin/python3 /usr/bin/py3
symlink /usr/bin/python3 /usr/bin/py3
link -s /usr/bin/python3 /usr/bin/py3
mklink /usr/bin/py3 /usr/bin/python3
Show Answer
✅ Correct Answer: ln -s /usr/bin/python3 /usr/bin/py3
35. Set the default runlevel to multi-user mode (no GUI)
systemctl set-default multi-user.target
init 3
telinit 3
change-runlevel 3
Show Answer
✅ Correct Answer: systemctl set-default multi-user.target
36. Configure the system to synchronize time with time.server.example.com
Add "server time.server.example.com" to /etc/chrony.conf and restart chronyd
ntpdate time.server.example.com
timedatectl set-ntp time.server.example.com
echo "time.server.example.com" > /etc/ntp.conf
Show Answer
✅ Correct Answer: Add "server time.server.example.com" to /etc/chrony.conf and restart chronyd
37. Create a 1GB swap file at /swapfile and activate it
dd if=/dev/zero of=/swapfile bs=1M count=1024 && mkswap /swapfile && swapon /swapfile
fallocate -l 1G /swapfile && swapon /swapfile
mkfile 1G /swapfile && swapctl -a /swapfile
createswap /swapfile 1G
Show Answer
✅ Correct Answer: dd if=/dev/zero of=/swapfile bs=1M count=1024 && mkswap /swapfile && swapon /swapfile
38. Configure the system to automatically resize /home to use all available space on boot
Add "x-systemd.growfs" to /etc/fstab for /home entry
echo "growpart /home" >> /etc/rc.local
install growfsd service for /home
autogrowfs enable /home
Show Answer
✅ Correct Answer: Add "x-systemd.growfs" to /etc/fstab for /home entry
39. Find all files owned by user "olduser" and change ownership to "newuser"
find / -user olduser -exec chown newuser {} \;
chown -R newuser:newuser /
for file in $(ls -l | grep olduser); do chown newuser $file; done
find / -owner olduser | xargs chown newuser
Show Answer
✅ Correct Answer: find / -user olduser -exec chown newuser {} \;
40. Configure the system to allow SSH access only from 192.168.1.0/24
Add "AllowUsers *@192.168.1.*" to /etc/ssh/sshd_config and restart sshd
iptables -A INPUT -p tcp --dport 22 -s 192.168.1.0/24 -j ACCEPT
firewall-cmd --add-rich-rule="rule family="ipv4" source address="192.168.1.0/24" service name="ssh" accept"
echo "192.168.1.0/24" > /etc/ssh/allowed_hosts
Show Answer
✅ Correct Answer: firewall-cmd --add-rich-rule="rule family="ipv4" source address="192.168.1.0/24" service name="ssh" accept"
41. Create a compressed archive of /etc directory named etc_backup.tar.gz
tar -czf etc_backup.tar.gz /etc
zip -r etc_backup.tar.gz /etc
gzip /etc > etc_backup.tar.gz
archive create etc_backup.tar.gz /etc
Show Answer
✅ Correct Answer: tar -czf etc_backup.tar.gz /etc
42. Configure the system to automatically start Apache web server at boot
systemctl enable httpd
chkconfig httpd on
service httpd enable
initctl enable httpd
Show Answer
✅ Correct Answer: systemctl enable httpd
43. Find all files larger than 100MB in /var and save the list to /root/largefiles.txt
find /var -size +100M > /root/largefiles.txt
du -h /var | grep "100M" > /root/largefiles.txt
ls -lh /var | awk "{if ($5 > 100M) print}" > /root/largefiles.txt
search /var -size +100MB -out /root/largefiles.txt
Show Answer
✅ Correct Answer: find /var -size +100M > /root/largefiles.txt
Want more practice? Check out our other mock exams: