350-201 Question 274
Select 2You are troubleshooting a potential security issue on a Linux-based server. You suspect that a malicious script has been created in the /tmp directory and want to list all files in that directory to verify. Additionally, you need to check if the MY_ENV environment variable has been set, as it may be part of the script's behavior. Which of the following Bash commands would you use to efficiently complete both tasks?
- A
ls /tmp
- B
echo $MY_ENV
- C
export MY_ENV
- D
cd /tmp && ls
- E
cat /tmp/MY_ENV
Show answer and explanation
Correct answers: A, B
Explanation
To troubleshoot the issue, you need to list the files in the /tmp directory to identify any malicious scripts and check the value of the MY_ENV environment variable. The ls /tmp command lists the directory contents, while echo $MY_ENV reveals the value of the environment variable. These commands directly address the tasks and are efficient for the scenario.
- A. Correct.
Correct. The
ls /tmpcommand lists all files in the/tmpdirectory, which is essential for identifying any malicious files. - B. Correct.
Correct. The
echo $MY_ENVcommand displays the value of theMY_ENVenvironment variable, allowing you to verify if it has been set. - C. Incorrect.
Incorrect. The
export MY_ENVcommand is used to set or export theMY_ENVenvironment variable, not to check its current value. - D. Incorrect.
Incorrect. The
cd /tmp && lscommand lists files in/tmpafter changing the directory, but it is redundant compared to just usingls /tmp. While functional, it is less efficient for this scenario. - E. Incorrect.
Incorrect. The
cat /tmp/MY_ENVcommand attempts to display the contents of a file namedMY_ENVin the/tmpdirectory, which is not relevant to checking an environment variable or listing files.