easyMultiple ChoiceObjective-mapped
220-1202 Practice Question: That they cannot execute a custom shell script…
A user reports that they cannot execute a custom shell script they created in their home directory. The script is owned by the user and has permissions set to 644. Which command should be used to allow the owner to execute the script?
⚠ Common exam trap
Watch out — candidates often choose `chmod 755` (Option A) because it is a common permission set for scripts, but the question specifically asks to allow only the owner to execute, making `chmod u+x` the precise and correct answer.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
chmod u+x script.sh
The script has permissions 644, which means the owner has read/write (6) but not execute. To allow the owner to execute the script, you need to add the execute permission for the owner. The command `chmod u+x script.sh` adds execute permission for the user (owner) only, which is the correct and minimal change to resolve the issue.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
chmod 755 script.sh
Why it's wrong here
The command "chmod 755 script.sh" sets the file permissions to rwxr-xr-x. While this successfully grants execute permission to the owner (user), it also unnecessarily extends execute permissions to the group and others. Although it resolves the immediate problem of the user being unable to execute the script, it violates the principle of least privilege by granting broader permissions than required, making it not the most precise or minimal solution.
- ✓
chmod u+x script.sh
Why this is correct
The command "chmod u+x script.sh" is the most appropriate solution as it precisely adds execute permission solely for the file's owner (user). The 'u' specifies the user (owner), and '+x' adds the execute permission without altering any existing read or write permissions for the owner, group, or others. This ensures the user can execute their script while maintaining the existing, potentially restrictive, permissions for other user categories, adhering to the principle of least privilege.
- ✗
chmod 644 script.sh
Why it's wrong here
The command "chmod 644 script.sh" sets the file permissions to rw-r--r--. In octal notation, '6' for the owner grants read and write, '4' for the group grants read-only, and '4' for others grants read-only. Crucially, this permission set does not include the execute bit for any user category, meaning the script would still be unexecutable. Therefore, applying this command would not resolve the user's issue and likely represents the current, problematic permission state.
- ✗
chown user:user script.sh
Why it's wrong here
The command "chown user:user script.sh" changes the ownership of the file to 'user' and sets its group to 'user'. While ownership is a critical aspect of file management, changing it does not inherently modify the file's permissions. The script would still retain its existing permission bits, which, in this scenario, are presumed to lack execute permission. Consequently, the user would still be unable to execute the script, as this command addresses ownership, not execution rights.
Visual reference
Go deeper
Related to this question
About these practice questions
This 220-1202 question is part of Courseiva's 495-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
Same concept, more angles
2 more ways this is tested on 220-1202
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. A user reports that they cannot execute a custom shell script they placed in their home directory, even though they can read and write to it. The script has permissions -rw-r--r--. Which command should you use to resolve this issue?
easy- A.chmod 644 script.sh
- ✓ B.chmod 755 script.sh
- C.chmod 777 script.sh
- D.chmod u+x script.sh
Why B: The script has permissions -rw-r--r-- (644), which does not include execute for anyone. The correct command is chmod 755 script.sh (option B), which sets rwxr-xr-x, allowing the owner to execute (and others to read/execute). Option D (chmod u+x) also adds execute for the owner, resulting in -rwxr--r-- (744), which does allow the user to run the script. However, in the context of this question, the expected best practice is to use chmod 755, as it is the standard for executable scripts and ensures group/others have minimum necessary read/execute. Option D is considered incorrect because it only adds execute for the owner without adjusting group/others, which is not the typical recommended approach.
Variation 2. A user reports that they cannot execute a shell script they wrote in their home directory. The script has permissions -rw-r--r--. Which command should be used to allow the owner to execute the script?
easy- A.chmod 755 script.sh
- ✓ B.chmod u+x script.sh
- C.chmod +r script.sh
- D.chmod 644 script.sh
Why B: The script currently has permissions -rw-r--r--, meaning the owner has read and write but not execute. The command chmod u+x adds execute permission for the owner (u) without affecting other permissions. This directly addresses the user's inability to execute the script by granting the missing execute bit to the owner.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This 220-1202 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 220-1202 exam.