Courseiva
Knowledge + Practice
CertificationsVendorsCareer RoadmapsLabs & ToolsStudy GuidesGlossaryPractice Questions
C
Courseiva

Free IT certification practice questions with explained answers for CCNA, CompTIA, AWS, Azure, Google Cloud, and more.

Certification Practice Questions

CCNA practice questionsSecurity+ SY0-701 practice questionsAWS SAA-C03 practice questionsAZ-104 practice questionsAZ-900 practice questionsCLF-C02 practice questionsA+ Core 1 practice questionsGoogle Cloud ACE practice questionsCySA+ CS0-003 practice questionsNetwork+ N10-009 practice questions
View all certifications →

Product

CertificationsCertification PathsExam TopicsPractice TestsExam Dumps vs Practice TestsStudy HubComparisons

Company

AboutContactEditorial PolicyQuestion Writing PolicyTrust Center

Legal

Privacy PolicyTerms of Service

Courseiva is a free IT certification practice platform offering original exam-style practice questions, detailed explanations, topic-based practice, mock exams, readiness tracking, and study analytics for Cisco, CompTIA, Microsoft, AWS, and other technology certifications.

© 2026 Courseiva. Courseiva is operated by JTNetSolutions Ltd. All rights reserved.

Courseiva is an independent certification practice platform and is not affiliated with, endorsed by, or sponsored by Cisco, Microsoft, AWS, CompTIA, Google, ISC2, ISACA, or any other certification vendor. Vendor names and certification marks are used only to identify the exams learners are preparing for.

← Create simple shell scripts practice sets

EX200 Create simple shell scripts • Complete Question Bank

EX200 Create simple shell scripts — All Questions With Answers

Complete EX200 Create simple shell scripts question bank — all 0 questions with answers and detailed explanations.

37
Questions
Free
No signup
Certifications/EX200/Practice Test/Create simple shell scripts/All Questions
Question 1mediummultiple choice
Read the full Create simple shell scripts explanation →

A system administrator needs to create a shell script that checks if the user 'jdoe' exists in the system and, if not, creates the user with a home directory. The script should also verify that the creation was successful. Which of the following script snippets correctly implements this logic?

Question 2easymultiple choice
Read the full Create simple shell scripts explanation →

A developer wrote a shell script that is intended to back up log files by copying all .log files from /var/log/myapp to /backup/logs. The script runs daily via cron but the backup folder is empty. The script contains the following line: `cp /var/log/myapp/*.log /backup/logs/`. What is the most likely reason the backup fails?

Question 3hardmulti select
Read the full Create simple shell scripts explanation →

Which THREE of the following practices are recommended when creating simple shell scripts in a Red Hat Enterprise Linux environment to ensure reliability, security, and maintainability?

Question 4mediummultiple choice
Read the full Create simple shell scripts explanation →

Refer to the exhibit. A junior admin runs this script as root, but it always prints 'httpd is running' even when httpd is stopped. What is the most likely cause?

Network Topology
if systemctl is-activequiet $SERVICERefer to the exhibit.```bash#!/bin/bash# Script: check_service.shSERVICE="httpd"thenecho "$SERVICE is running"elsesystemctl restart $SERVICEecho "$SERVICE was restarted"fi```
Question 5hardmultiple choice
Read the full Create simple shell scripts explanation →

You are a system administrator for a medium-sized company running Red Hat Enterprise Linux 8 on all servers. The development team has created a shell script that is supposed to be run nightly via cron to synchronize configuration files from a master server to multiple web servers. The script is located at /opt/scripts/sync_configs.sh and is owned by root. It uses rsync over SSH with key-based authentication. The script works perfectly when run manually by root, but when it runs via cron, the synchronization fails with the error 'Host key verification failed.' The script does not explicitly specify any SSH options. The cron job is configured in /etc/crontab as: `0 2 * * * root /opt/scripts/sync_configs.sh`. The SSH keys are stored in /root/.ssh/id_rsa and the known_hosts file contains the correct host key for the master server. What is the most likely cause of the failure, and what is the best course of action to resolve it?

Question 6easymulti select
Read the full Create simple shell scripts explanation →

Which TWO of the following are true about creating simple shell scripts in Red Hat Enterprise Linux?

Question 7hardmultiple choice
Read the full Create simple shell scripts explanation →

You are a system administrator for a small company. The development team has created a shell script named 'deploy.sh' that automates deployment of a web application. The script is located at /home/devops/deploy.sh. The team reports that when they run the script with './deploy.sh' from the /home/devops directory, it fails with a 'Permission denied' error. However, running 'bash deploy.sh' works fine. Additionally, the script's first line is '#!/bin/bash' and the file permissions are '-rw-rw-r--'. The team wants to be able to run the script directly without typing 'bash'. Which of the following actions should you take to resolve the issue?

Question 8mediumdrag order
Read the full Create simple shell scripts explanation →

Arrange the steps to configure a logical volume snapshot named 'snap_lv_data' of logical volume 'lv_data'.

Drag steps to the numbered slots on the right, or tap a step then tap a slot.

Steps
Order
1Step 1
2Step 2
3Step 3
4Step 4
5Step 5
Question 9mediummatching
Read the full Create simple shell scripts explanation →

Match each package management command to its action.

Drag a concept onto its matching description — or click a concept then click the description.

Concepts
Matches

Install a package with dependencies

Uninstall a package

Update all packages to latest versions

Show all installed packages

Question 10easymultiple choice
Read the full Create simple shell scripts explanation →

An administrator writes a script that uses the 'set -e' option at the top. What is the primary effect of this option?

Question 11easymultiple choice
Read the full Create simple shell scripts explanation →

A system administrator needs to create a shell script that processes a list of hostnames stored in a file, one per line, and runs a command on each host. Which loop construct is most appropriate?

Question 12easymultiple choice
Read the full NAT/PAT explanation →

A developer wants to create a script that accepts a directory path as an argument and creates a timestamped backup of that directory. If no argument is provided, it should back up the current directory. How should the script handle the argument?

Question 13mediummultiple choice
Read the full Create simple shell scripts explanation →

An administrator writes a script to check disk usage and send an alert if usage exceeds 80%. The script uses 'df -h /' and parses the output. To maintain portability and avoid common pitfalls, which approach is recommended?

Question 14mediummultiple choice
Read the full Create simple shell scripts explanation →

A script needs to execute a command that might fail, but the script should continue. The administrator wants to capture the exit status for logging. Which code snippet correctly implements this?

Question 15mediummultiple choice
Read the full Create simple shell scripts explanation →

A junior admin writes a script that uses functions. They notice that a variable set inside a function is not available after the function call. What is the likely cause and best practice?

Question 16hardmultiple choice
Read the full Create simple shell scripts explanation →

A sysadmin creates a script to rotate log files. The script uses 'find /var/log -type f -name "*.log" -mtime +30 -exec gzip {} \;' but some log files are not compressed. The script runs as root. What is the most likely reason some files remain uncompressed?

Question 17hardmultiple choice
Read the full Create simple shell scripts explanation →

A script uses 'read' to get user input and then performs an action based on the input. However, when the script is piped (e.g., './script.sh | othercommand'), the read command does not wait for input and the script continues with empty variable. How can this be fixed?

Question 18hardmultiple choice
Read the full Create simple shell scripts explanation →

A complex script uses 'trap' to handle signals. The admin writes 'trap '' SIGINT' to ignore Ctrl+C, but later in the script they want to re-enable the default behavior. Which command restores the default behavior for SIGINT?

Question 19easymulti select
Read the full Create simple shell scripts explanation →

Which TWO of the following are valid ways to make a shell script executable?

Question 20mediummulti select
Read the full Create simple shell scripts explanation →

Which THREE of the following are common practices to improve the reliability of shell scripts?

Question 21hardmulti select
Read the full Create simple shell scripts explanation →

Which TWO of the following are correct statements about exit codes in shell scripts?

Question 22easymultiple choice
Read the full Create simple shell scripts explanation →

Consider the script in the exhibit. The script is run in a directory containing 'a.txt' and 'b.txt' but also has a subdirectory 'backup' with .txt files. What will be the output?

Exhibit

Refer to the exhibit.
```bash
#!/bin/bash
# Script to count lines in files
for file in *.txt; do
  wc -l "$file"
done
```
Question 23mediummultiple choice
Read the full Create simple shell scripts explanation →

A developer runs the script shown in the exhibit and always sees 'Success' printed, even when the previous command fails. What is the most likely cause?

Exhibit

Refer to the exhibit.
```bash
#!/bin/bash
# Script to test a condition
if [[ $? -eq 0 ]]; then
  echo 'Success'
fi
```
Question 24hardmultiple choice
Read the full Create simple shell scripts explanation →

A user executes the script shown in the exhibit with './export_script.sh' and then runs 'echo $MY_VAR' in the same terminal. The output is empty. Why does this happen?

Exhibit

Refer to the exhibit.
```bash
#!/bin/bash
# Script to set environment variable
MY_VAR="hello"
export MY_VAR
```
Question 25easymultiple choice
Read the full Create simple shell scripts explanation →

A script contains: lines=$(wc -l /etc/passwd); echo $((lines+1)). The output is unexpected. What is the problem?

Question 26hardmultiple choice
Read the full Create simple shell scripts explanation →

A script has a syntax error. Which command will help identify the line number of the error without executing the script?

Question 27mediummultiple choice
Read the full Create simple shell scripts explanation →

Which shell built-in can be used to read user input during script execution?

Question 28easymultiple choice
Read the full Create simple shell scripts explanation →

A script needs to read every line from a file and execute a command on each line. Which code block is correct and handles whitespace correctly?

Question 29mediummulti select
Read the full Create simple shell scripts explanation →

Which TWO methods correctly create a variable containing the number of regular files in the current directory (excluding . and ..)?

Question 30hardmulti select
Read the full Create simple shell scripts explanation →

Which THREE of the following are valid and recommended practices when writing shell scripts for RHEL?

Question 31hardmultiple choice
Read the full Create simple shell scripts explanation →

Refer to the exhibit. The script produces the error shown. What is the most likely cause?

Exhibit

Refer to the exhibit.

#!/bin/bash
if [ $var = "value" ]
then
  echo "Match"
fi

Error: [: =: unary operator expected
Question 32mediummultiple choice
Read the full Create simple shell scripts explanation →

You are tasked with creating a script that reads a list of usernames from /tmp/users.txt, one per line, and creates a home directory for each user using `mkdir /home/$username`. The script is:

#!/bin/bash

while read username; do

mkdir /home/$username done < /tmp/users.txt

However, the script fails for usernames that contain spaces (e.g., 'john smith'). The error is 'mkdir: cannot create directory '/home/john': File exists' and then a separate directory for 'smith'. What is the best fix?

Question 33hardmultiple choice
Read the full Create simple shell scripts explanation →

You maintain a script that performs a long-running task and must clean up temporary files if the script is interrupted. The script uses:

#!/bin/bash tempfile=$(mktemp) trap "rm -f $tempfile" EXIT

# long task

sleep 100

You notice that if the script receives SIGINT (Ctrl+C), the temporary file is not removed. Investigation shows that the trap on EXIT is not executed on SIGINT. Which modification should be made?

Question 34easymultiple choice
Read the full Create simple shell scripts explanation →

A new intern created a script to display the current user's home directory:

#!/bin/bash echo "Home directory: $home"

The script outputs 'Home directory: ' with nothing after the colon. What is the most likely cause?

Question 35easymulti select
Read the full Create simple shell scripts explanation →

A system administrator writes a shell script to monitor disk usage and send an alert if any partition exceeds 80%. Which TWO of the following are best practices for implementing this script?

Question 36mediummultiple choice
Read the full Create simple shell scripts explanation →

A system administrator writes the script shown. The /etc directory contains .conf files with spaces in their names (e.g., "my config.conf"). What is the most accurate description of the script's behavior?

Exhibit

Refer to the exhibit.

```bash
#!/bin/bash
for file in $(ls /etc/*.conf); do
  echo "Processing: $file"
done
```
Question 37hardmultiple choice
Read the full Create simple shell scripts explanation →

An organization uses a shell script that runs daily via cron on a central management server to archive logs from 50 remote Red Hat Enterprise Linux servers. The script uses `scp` with SSH key-based authentication (passwordless) to transfer files. Recently, after a security team rotated the SSH host keys on all remote servers, the script started failing with 'Host key verification failed' errors. The administrator needs to restore automated log transfers without compromising security. The remote servers are in a controlled internal network, and the management server's `~/.ssh/known_hosts` file is not centrally managed. Which course of action should the administrator take?

Practice tests

Scored 10-question sessions with instant feedback and explanations.

EX200 Practice Test 1 — 10 Questions→EX200 Practice Test 2 — 10 Questions→EX200 Practice Test 3 — 10 Questions→EX200 Practice Test 4 — 10 Questions→EX200 Practice Test 5 — 10 Questions→EX200 Practice Exam 1 — 20 Questions→EX200 Practice Exam 2 — 20 Questions→EX200 Practice Exam 3 — 20 Questions→EX200 Practice Exam 4 — 20 Questions→Free EX200 Practice Test 1 — 30 Questions→Free EX200 Practice Test 2 — 30 Questions→Free EX200 Practice Test 3 — 30 Questions→EX200 Practice Questions 1 — 50 Questions→EX200 Practice Questions 2 — 50 Questions→EX200 Exam Simulation 1 — 100 Questions→

Practice by domain

Each domain maps to a weighted exam section. Focus on the domain where you are weakest.

Operate running systemsConfigure local storageCreate and configure file systemsDeploy, configure, and maintain systemsManage users and groupsManage securityManage containersCreate simple shell scriptsEssential Tools

Practice by scenario

Filter questions by type — troubleshooting, exhibit, drag-and-drop, PBQ, ACLs, OSPF, and more.

Browse scenarios→

Continue studying

All Create simple shell scripts setsAll Create simple shell scripts questionsEX200 Practice Hub