220-1101-AND-220-1102 practice question 28 of 35

A developer is creating a shell script to automate basic tasks in Linux. Which of the following file types are supported by default?

Full set: 800 questions
Answer options
A: .py
B: .js
C: .vbs
D: .sh Correct answer
Correct Answer:
D. .sh
Explanation

In the Linux operating system, the standard and conventional file extension for a shell script is .sh. Shell scripts are text files containing a series of commands that are executed by a command-line interpreter, such as Bash (Bourne-Again SHell). While Linux can execute a script file regardless of its extension if it has the correct permissions and a valid shebang (e.g., #!/bin/bash) on the first line, the .sh extension is the universally recognized convention for identifying these files by default for developers and system administrators.

Why Incorrect

A. .py is the extension for Python scripts, which are executed by the Python interpreter, not a native command-line shell.
B. .js is the extension for JavaScript files, which are typically executed by a web browser's engine or a server-side environment like Node.js.
C. .vbs is the extension for VBScript files, a scripting language developed by Microsoft and primarily used within the Windows operating system.

References

1. University Courseware: Michigan Technological University, Department of Computer Science. (n.d.). Linux Shell Scripting Tutorial v1.0.0. Section 1.2, "Creating and Running a Shell Script". The document states, "It is a convention to give shell scripts an extension of .sh". Retrieved from https://pages.mtu.edu/~shene/NSF-3/e-Book/SHELL/slide-part-1.pdf

2. Official Vendor Documentation: Red Hat. (2022). Red Hat Enterprise Linux 8: Configuring basic system settings. Chapter 26, "Writing a simple shell script". All examples provided in this official documentation, such as myscript.sh, use the .sh extension. Retrieved from https://access.redhat.com/documentation/en-us/redhatenterpriselinux/8/html/configuringbasicsystemsettings/writing-a-simple-shell-scriptconfiguring-basic-system-settings

3. Official Project Documentation: The Linux Documentation Project. (2014). Bash Guide for Beginners. Chapter 1.2, "What is a shell script?". The guide consistently uses the .sh extension in its examples to denote shell scripts, establishing it as the standard convention. Retrieved from https://tldp.org/LDP/Bash-Beginners-Guide/html/sect0102.html

Scroll to Top