GSEC practice question 5 of 35
You work as a Network Administrator for McNeil Inc. The company has a Linux-based network. David, a Sales Manager, wants to know the name of the shell that he is currently using. Which of the following commands will he use to accomplish the task?
Full set: 383 questionsDomain Linux: Security and Administration
In Unix-like operating systems, including Linux, environment variables store information about the shell session. The $SHELL environment variable specifically holds the path to the user's default login shell (e.g., /bin/bash, /bin/zsh). The echo command is a shell built-in that prints its arguments to the standard output. Therefore, executing echo $SHELL (or $shell, assuming a common typo in the question, as environment variables are case-sensitive and typically uppercase) retrieves the value of this variable and displays it on the screen, directly answering the user's question about which shell they are using.
A. mv $shell: This command is used to move or rename files. It would incorrectly attempt to move the shell's executable file.
C. rm $shell: This is the remove command. It would dangerously attempt to delete the shell's executable file, not display its name.
D. ls $shell: This command lists file attributes. It would show details about the shell executable file, not simply print its name as requested. ---
1. MIT OpenCourseWare. (2020). The Missing Semester of Your CS Education, Lecture 2: Shell Tools and Scripting. Massachusetts Institute of Technology. Retrieved from https://missing.csail.mit.edu/2020/shell-tools/. In the "Shell Variables" section, it states, "To see the value of a variable, you can use the echo command... For example, the $SHELL variable has the path of the shell program itself."
2. GNU Bash Reference Manual. (2022). 5.2 Bash Variables. Free Software Foundation. Retrieved from https://www.gnu.org/software/bash/manual/htmlnode/Bash-Variables.html. The documentation lists SHELL as a variable to which "Bash assigns... the full pathname of the current user’s login shell." The manual also documents echo as the standard command for displaying values.
3. Sobell, M. G. (2012). A Practical Guide to Linux Commands, Editors, and Shell Programming. Prentice Hall. In Chapter 4, "The Bourne Again Shell," the text explains shell and environment variables, explicitly mentioning that echo $SHELL is used to display the user's login shell. (Specific reference: Chapter 4, Section: "Standard Shell Variables").
Keep practicing
Take the free GSEC practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other GSEC practice questions
- Question 1What is the key difference between Electronic Codebook mode and other block cipher modes …
- Question 2Which of the following systems acts as a NAT device when utilizing VMware in NAT mode?
- Question 4You are doing some analysis of malware on a Unix computer in a closed test network. The I…
- Question 6Which of the following services resolves host name to IP Address?
- Question 7What does PowerShell remoting use to authenticate to another host in a domain environment?
- Question 8You work as a Network Administrator for McRobert Inc. You want to know the NetBIOS name o…
