200-901 Question 131
Select 3You are tasked with organizing a project directory on a Linux server. The project directory must contain subdirectories for 'logs', 'data', and 'scripts'. Additionally, you need to create a hidden file named '.env' inside the project directory to store environment variables. Which set of Bash commands will accomplish this?
- A
mkdir project && cd project && mkdir logs data scripts && touch .env
- B
mkdir project && cd project && mkdir logs data scripts && echo '' > .env
- C
mkdir project && mkdir logs data scripts && touch project/.env
- D
mkdir project && cd project && mkdir logs; mkdir data; mkdir scripts; touch .env
- E
mkdir project && cd project && mkdir logs data && mkdir scripts && echo 'ENV=prod' > .env
Show answer and explanation
Correct answers: A, B, D
Explanation
To complete the task, the commands must create the 'project' directory, navigate into it, create the 'logs', 'data', and 'scripts' subdirectories, and then create an empty '.env' file. Options 1, 2, and 4 fulfill all these requirements, using valid Bash commands. Option 3 creates the subdirectories outside the 'project' directory, while Option 5 adds content to the '.env' file, which does not meet the requirement for an empty file.
- A. Correct.
Correct. This sequence of commands creates the 'project' directory, navigates into it, creates the required subdirectories, and then creates the '.env' file.
- B. Correct.
Correct. This achieves the same result as Option 1, but instead of using the 'touch' command, it uses 'echo' with an empty string to create the '.env' file.
- C. Incorrect.
Incorrect. While this creates the required directories and the '.env' file, the subdirectories are created at the same level as the 'project' directory, not inside it.
- D. Correct.
Correct. This uses multiple 'mkdir' commands to create the subdirectories and correctly creates the '.env' file within the project directory.
- E. Incorrect.
Incorrect. While this creates the subdirectories and the '.env' file, the 'echo' command writes 'ENV=prod' into the file, which violates the requirement of creating an empty '.env' file.