Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to run echo Hello only if ls succeeds.
Linux CLI
ls [1] echo Hello Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '||' runs the second command only if the first fails.
Using ';' runs commands regardless of success.
Using '|' pipes output, not for conditional chaining.
✗ Incorrect
The '&&' operator runs the second command only if the first command succeeds.
2fill in blank
mediumComplete the code to run echo Failed only if cat file.txt fails.
Linux CLI
cat file.txt [1] echo Failed Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '&&' runs the second command only if the first succeeds.
Using ';' runs commands regardless of success.
Using '|' pipes output, not for conditional chaining.
✗ Incorrect
The '||' operator runs the second command only if the first command fails.
3fill in blank
hardFix the error in the command to run echo Done after mkdir test regardless of success.
Linux CLI
mkdir test [1] echo Done Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '&&' runs second command only on success.
Using '||' runs second command only on failure.
Using '|' pipes output, not for chaining commands.
✗ Incorrect
The ';' operator runs the second command regardless of the first command's success or failure.
4fill in blank
hardFill both blanks to run echo Success if grep 'hello' file.txt succeeds, else run echo Fail.
Linux CLI
grep 'hello' file.txt [1] echo Success [2] echo Fail
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using ';' runs all commands regardless of success.
Using '|' pipes output, not for conditional chaining.
Swapping '&&' and '||' changes logic.
✗ Incorrect
Use '&&' to run 'echo Success' if grep succeeds, and '||' to run 'echo Fail' if grep fails.
5fill in blank
hardFill both blanks to run echo Start, then run ls /tmp if echo Start succeeds, else run echo Error.
Linux CLI
; echo Start [1] ls /tmp [2] echo Error
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '|' instead of ';' causes piping, not sequencing.
Mixing order of '&&' and '||' changes logic.
Using only ';' runs all commands regardless of success.
✗ Incorrect
Use ';' to run 'echo Start' first, then '&&' to run 'ls /tmp' if 'echo Start' succeeds, and '||' to run 'echo Error' if 'ls /tmp' fails.