Linux+ Networking Chapter 8

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Ajeff
A
Ajeff
Community Contributor
Quizzes Created: 39 | Total Attempts: 57,812
Questions: 20 | Attempts: 836

SettingsSettingsSettings
Linux Plus Networking Quizzes & Trivia

Linux+ Networking Chapter 8


Questions and Answers
  • 1. 

    Because Standard Error and Standard Ouput represent the results of a command and Standard Input represents the input required for a command, only Standard Error and Standard Ouput can be redirected to/from a file. True or False?

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    Standard Input can also be redirected to/from a file. When a command requires input from the user, it can be redirected from a file using the "

    Rate this question:

  • 2. 

    Before a user-defined variable can be used by processes that run in subshells, that variable must be ____________.

    • A.

      Imported

    • B.

      Validated by running the env command

    • C.

      Exported

    • D.

      Redirected to the BASH shell

    Correct Answer
    C. Exported
    Explanation
    Before a user-defined variable can be used by processes that run in subshells, that variable must be exported. Exporting a variable makes it available to child processes, including subshells, so that they can access and use the variable's value.

    Rate this question:

  • 3. 

    The alias command can be used to make a shortcut to a single command.  True or False?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    The alias command is used in computer systems to create shortcuts or alternative names for a command or a set of commands. By using the alias command, users can create a shorter or more convenient name for a command, making it easier to remember and use. Therefore, the statement that the alias command can be used to make a shortcut to a single command is true.

    Rate this question:

  • 4. 

    Which of the following files is always executed immediately after a user logs in to a Linux system and receives a BASH shell?

    • A.

      /etc/profile

    • B.

      ~/.bash_profile

    • C.

      ~/.bash_login

    • D.

      ~/.profile

    Correct Answer
    A. /etc/profile
    Explanation
    The file /etc/profile is always executed immediately after a user logs in to a Linux system and receives a BASH shell. This file is a system-wide configuration file that sets environment variables and runs commands that are applicable to all users on the system. It provides a global configuration for the BASH shell and initializes the user's environment.

    Rate this question:

  • 5. 

    Which command could you use to see a list of all environment and user-defined shell variables as well as their current values?

    • A.

      Ls /var

    • B.

      Env

    • C.

      Set

    • D.

      Echo

    Correct Answer
    C. Set
    Explanation
    The command "set" can be used to see a list of all environment and user-defined shell variables along with their current values.

    Rate this question:

  • 6. 

    Every if construct begins with if and must be terminated with?

    • A.

      End

    • B.

      Endif

    • C.

      Stop

    • D.

      Fi

    Correct Answer
    D. Fi
    Explanation
    The correct answer is "fi" because in programming, "fi" is used to terminate an if construct in certain programming languages like Bash. "fi" is the counterpart of "if" and it signifies the end of the conditional statement. Without the "fi" keyword, the if construct would be incomplete and the program may throw an error.

    Rate this question:

  • 7. 

    Which of the following will display the message welcome home if the cd /home/user1 command is successfully executed?

    • A.

      Cd /home/user1 && echo “welcome home”

    • B.

      Cat “welcome home” || cd /home/user1

    • C.

      Cd /home/user1 || cat “welcome home”

    • D.

      Echo “welcome home” && cd /home/user1

    Correct Answer
    A. Cd /home/user1 && echo “welcome home”
    Explanation
    The correct answer is "cd /home/user1 && echo “welcome home”". This is because the "&&" operator in the command ensures that the second command (echo "welcome home") is only executed if the first command (cd /home/user1) is successful. So if the cd /home/user1 command is successfully executed, it will display the message "welcome home".

    Rate this question:

  • 8. 

    The current value for the HOME variable is displayed by which of the following commands? (Choose all that apply.)

    • A.

      Echo HOME=

    • B.

      Echo ~

    • C.

      Echo $HOME

    • D.

      Echo ls HOME

    Correct Answer(s)
    B. Echo ~
    C. Echo $HOME
    Explanation
    The correct answers are "echo ~" and "echo $HOME".

    The command "echo ~" will display the current value of the HOME variable by expanding the tilde (~) character, which represents the home directory.

    The command "echo $HOME" will directly display the value of the HOME variable, as the variable is preceded by a dollar sign ($).

    Rate this question:

  • 9. 

    Which of the following file descriptor numbers represents stdout?

    • A.

      2

    • B.

      0

    • C.

      1

    • D.

      3

    Correct Answer
    C. 1
    Explanation
    The correct answer is 1 because in Unix-like operating systems, file descriptor number 1 represents stdout, which is the standard output.

    Rate this question:

  • 10. 

    Which of the following operators reverses the meaning of a test statement?

    • A.

      #!

    • B.

      -o

    • C.

      -a

    • D.

      !

    Correct Answer
    D. !
    Explanation
    The operator "!" is used to reverse the meaning of a test statement. It is a logical operator called the "not" operator, which negates the value of a boolean expression. For example, if a test statement is true, using "!" before it will make it false, and vice versa.

    Rate this question:

  • 11. 

    What would be the effect of using the alias command to make an alias for the date command named cat in honor of your favorite pet?

    • A.

      It cannot be done as there already is an environment variable cat associated with the cat command.

    • B.

      It cannot be done as there already is a command cat on the system.

    • C.

      When you use the cat command at the command prompt with the intention of viewing a text file, the date appears instead.

    • D.

      There is no effect until the alias is imported as it is a user-declared variable.

    Correct Answer
    C. When you use the cat command at the command prompt with the intention of viewing a text file, the date appears instead.
    Explanation
    Using the alias command to create an alias for the date command named cat would cause the date command to be executed instead of the cat command when using the cat command to view a text file. This means that instead of displaying the contents of the text file, the current date and time would be displayed.

    Rate this question:

  • 12. 

    How do you indicate a comment line in a shell script?

    • A.

      There are no comment lines in a shell script.

    • B.

      Begin the line with #!.

    • C.

      Begin the line with !.

    • D.

      Begin the line with #.

    Correct Answer
    D. Begin the line with #.
    Explanation
    In a shell script, a comment line is indicated by beginning the line with a # symbol. This symbol tells the shell to ignore everything after it on that line. It is commonly used to add explanatory or descriptive notes within the script, which are not executed as part of the code.

    Rate this question:

  • 13. 

    You have redirected Standard Error to a file called Errors. You view the contents of this file afterward and notice that there are six error messages. After repeating the procedure, you notice that there are only two error messages in this file. Why?

    • A.

      After you open the file and view the contents, the contents are lost.

    • B.

      The system generated different Standard Ouput.

    • C.

      You did not append the Standard Error to the Error file and as a result, it was overwritten when the command was run a second time.

    • D.

      You must specify a new file each and every time you redirect as the system creates the specified file by default.

    Correct Answer
    C. You did not append the Standard Error to the Error file and as a result, it was overwritten when the command was run a second time.
    Explanation
    When redirecting the Standard Error to a file called Errors, if you do not append the Standard Error to the Error file, the file gets overwritten when the command is run again. This means that the previous error messages are replaced with the new ones, resulting in only two error messages being present in the file after repeating the procedure.

    Rate this question:

  • 14. 

    The sed and awk commands are filter commands commonly used to format data within a pipe. True or False?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    The sed and awk commands are indeed filter commands commonly used to format data within a pipe. These commands allow users to manipulate and transform text data in various ways, such as searching for patterns and replacing text (sed) or extracting and manipulating columns of data (awk). Therefore, the statement "The sed and awk commands are filter commands commonly used to format data within a pipe" is true.

    Rate this question:

  • 15. 

    What is wrong with the following command string ls /etc/hosts   >listofhostfile?

    • A.

      Nothing is wrong with the command.

    • B.

      The file descriptor was not declared; unless 1 for Standard Ouput or 2 for Standard Error is indicated, the command will fail.

    • C.

      The ls command is one of the commands that cannot be used with redirection; you must use | to pipe instead.

    • D.

      The file listofhostfile will always only contain Standard Error as a file descriptor was not declared.

    Correct Answer
    A. Nothing is wrong with the command.
    Explanation
    The given command string "ls /etc/hosts >listofhostfile" is correct and does not have any issues. It lists the contents of the /etc/hosts file and redirects the output to a file named listofhostfile.

    Rate this question:

  • 16. 

    Which of the following is not necessarily generated by every command on the system? (Choose all that apply.)

    • A.

      Standard Input

    • B.

      Standard Deviation

    • C.

      Standard Ouput

    • D.

      Standard Error

    Correct Answer(s)
    A. Standard Input
    B. Standard Deviation
    Explanation
    Standard Input and Standard Deviation are not necessarily generated by every command on the system. Standard Input is the input stream where a command receives its input, and Standard Deviation is a statistical measure of the amount of variation or dispersion in a set of values. While Standard Output and Standard Error are commonly generated by commands to display output and error messages respectively, the presence of Standard Input and Standard Deviation depends on the specific command and its functionality.

    Rate this question:

  • 17. 

    Which construct can be used in a shell script to read Standard Input and place it in a variable?

    • A.

      Read

    • B.

      Sum

    • C.

      Verify

    • D.

      Test

    Correct Answer
    A. Read
    Explanation
    The "read" construct can be used in a shell script to read Standard Input and place it in a variable. This allows the script to accept user input and store it for further processing or manipulation. By using the "read" command, the script can prompt the user for input and then store that input in a variable for later use in the script.

    Rate this question:

  • 18. 

    1. A variable identifier must ____________.

    • A.

      Not begin with a number

    • B.

      Not begin with a capital letter

    • C.

      Start with a number

    • D.

      Start with an underscore “_”

    Correct Answer
    A. Not begin with a number
    Explanation
    A variable identifier must not begin with a number because in most programming languages, variable names cannot start with a numeric digit. They must start with a letter or an underscore. This is because starting a variable name with a number can cause confusion and may lead to syntax errors.

    Rate this question:

  • 19. 

    What does >> accomplish when entered on the command line after a command?

    • A.

      It redirects both Standard Error and Standard Ouput to the same location.

    • B.

      It does not accomplish anything.

    • C.

      It redirects Standard Error and Standard Input to the same location.

    • D.

      It appends Standard Ouput to a file.

    Correct Answer
    D. It appends Standard Ouput to a file.
    Explanation
    When the ">>" symbol is entered on the command line after a command, it appends the Standard Output of that command to a file. This means that the output of the command will be added to the end of the specified file, rather than overwriting the file or creating a new one. This is useful when you want to continuously add new content to a file without losing the existing content.

    Rate this question:

  • 20. 

    Consider the following shell script:                 echo -e “What is your favorite color?--> \c”                  read REPLY                 if [ “$REPLY” = “red”  –o  “$REPLY” = “blue” ]                 then                    echo “The answer is red or blue.”                 else                      echo “The answer is not red nor blue.”                 fi  What would be displayed if a user executes this program and answered Blue when prompted?

    • A.

      The answer is red or blue.

    • B.

      The answer is not red nor blue.

    • C.

      The code would cause an error.

    • D.

      The answer is red or blue. The answer is not red nor blue.

    Correct Answer
    B. The answer is not red nor blue.
    Explanation
    The correct answer is "The answer is not red nor blue." This is because the user is prompted to enter their favorite color and if their input is "Blue", the condition in the if statement will evaluate to false. Therefore, the script will execute the else block and display "The answer is not red nor blue."

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 22, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Jun 18, 2009
    Quiz Created by
    Ajeff
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.