Which of the following commands sets the variable USERNAME to the value bob?
Options:
A.
set USERNAME bob
B.
$USERNAME==bob
C.
var USERNAME=bob
D.
USERNAME<=bob
E.
USERNAME=bob
Answer:
E
Explanation:
Explanation:
The correct command to set the variable USERNAME to the value bob is USERNAME=bob. This command assigns the string bob to the variable name USERNAME, using the equal sign (=) as the assignment operator. There is no space around the equal sign, and the variable name and value are case-sensitive. This command sets a shell variable, which is only valid in the current shell session. To make the variable an environment variable, which can be inherited by child processes and subshells, you need to use the export command, such as export USERNAME=bob. The other commands are not valid for setting variables in Linux. The set command is used to set orunset shell options and positional parameters, not variables. The $ sign is used to reference the value of a variable, not to assign it. The == sign is used for comparison, not assignment. The var keyword is not used in Linux, but in some other programming languages. The <= sign is used for redirection, not assignment. References:
Linux Essentials - Linux Professional Institute (LPI)
How to Set and List Environment Variables in Linux | Linuxize