What does the shell parameter $0 store?

Study for the OSCP Linux Exam. Use our flashcards and multiple-choice questions to test your skills. Each query comes with detailed hints and explanations to enhance your preparedness. Get ready to conquer the exam!

Multiple Choice

What does the shell parameter $0 store?

Explanation:
The value stored in this shell parameter is the name or path used to invoke the current shell or script—the first word on the command line. That means inside a script, it’s the script’s own filename (or the command used to run it), and in an interactive shell, it’s the shell program itself (for example, bash or sh). This is why you’ll often see $0 used in usage messages or to determine the script’s location relative to its own path. So this matches the idea of the first word of the entered command, which identifies what was started. It’s not the collection of all arguments (that’s $@ or $*), not the exit status of the last command (that’s $?), and not the process ID (that’s $$).

The value stored in this shell parameter is the name or path used to invoke the current shell or script—the first word on the command line. That means inside a script, it’s the script’s own filename (or the command used to run it), and in an interactive shell, it’s the shell program itself (for example, bash or sh). This is why you’ll often see $0 used in usage messages or to determine the script’s location relative to its own path.

So this matches the idea of the first word of the entered command, which identifies what was started. It’s not the collection of all arguments (that’s $@ or $*), not the exit status of the last command (that’s $?), and not the process ID (that’s $$).

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy