Linux Shell Basics & Environment – Full Quiz
← Back to Quiz Home
This quiz contains 15 questions focused on shell variables, environment variables,
PATH configuration, and aliases.
These concepts are heavily used by DevOps engineers in daily operations.
Which variable is accessible only within the current shell session?
Shell variables are local to the current shell instance and are not inherited by child processes.
Which command creates an environment variable?
The export command promotes a shell variable to an environment variable, making it available to child processes.
Which command displays all environment variables?
The env command lists all the current environment variables.
Which command displays a specific environment variable?
To view the value of a specific variable, use echo followed by the variable name prefixed with $.
Which environment variable defines where Linux searches for commands?
The PATH variable contains a colon-separated list of directories where the shell looks for executable files.
Which command displays the current PATH?
echo $PATH prints the contents of the PATH environment variable.
Why can most Linux commands be executed from any directory?
Commands like ls and cp are stored in directories (like /bin or /usr/bin) that are included in the PATH variable.
Which command gives execute permission to a script?
chmod +x adds the execute permission to the file, allowing it to be run as a program.
Why does ./script.sh work but script.sh fails?
By default, the current directory (.) is not in the PATH for security reasons, so you must specify the path explicitly (e.g., ./).
Which file is executed when a new terminal session starts?
~/.bashrc is a script that runs whenever you start a new interactive shell session (like opening a new terminal window).
Which file is used to persist aliases and environment variables?
Adding aliases or export commands to ~/.bashrc ensures they are available in every new shell session.
Which command creates a shortcut command?
The alias command allows you to define a shortcut or abbreviation for a longer command.
Which command removes an alias?
The unalias command removes a previously defined alias.
Which file interpreter is defined by the shebang?
The shebang #!/bin/bash at the top of a script tells the system to execute the file using the Bash shell.
Which command is the default shell for most Linux distributions?
Bash (Bourne Again SHell) is the most common default shell in Linux environments.
Which operator redirects output and overwrites the existing file?
The single arrow > redirects the output of a command to a file, replacing any existing content.
Which operator appends output to the end of a file without deleting its content?
The double arrow >> appends the command output to the existing content of a file.
Which operator is used to pass the output of one command as input to another?
The pipe operator | connects the standard output of the first command to the standard input of the second.
Which special variable holds the exit status of the last executed command?
The $? variable stores the exit code (0 for success, non-zero for failure) of the most recent command.
Quiz Progress
0 / 0 questions answered
(0% )
0 correct
Quiz Complete!
0%
Reset quiz
📚 Study Guides
📬 Weekly DevOps, Cloud & Gen AI quizzes & guides