Which command sets the variable USERNAME to the value bob?

Prepare for the LPI Linux Essentials 010-160 Test with our comprehensive quiz platform offering flashcards and multiple choice questions. Hints and explanations provided for each question. Get exam-ready with ease!

To set a variable in a shell environment, the syntax requires the variable name to be followed by an equal sign and the value you wish to assign to that variable, without any spaces around the equal sign. In this case, assigning the value 'bob' to the variable 'USERNAME' is correctly done by simply using the syntax 'USERNAME=bob'.

This form of variable assignment is concise and directly assigns the value to the variable within the current shell session. It's important to remember that this method does not export the variable to child processes; it is available only in the current shell unless specifically exported.

Other options presented do not conform to the correct syntax for variable assignment within a shell environment. For instance, using 'SET USERNAME=bob' is not a valid command in most Unix-like shells; it is more commonly associated with Windows batch scripting. Similarly, 'USERNAME: bob' is not a valid syntax for setting variables in shell scripting. The 'export USERNAME=bob' command, while it correctly exports the variable to child processes, does not simply set the variable but rather sets and exports it in one command, which is not what is being asked in the question context.

Thus, 'USERNAME=bob' stands out as the correct

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy