Skip to main content

010-160 Linux Essentials - Exam 010, (version 1.6)

  • LPI
  • 5 free sample questions

About this exam

010-160 is the LPI exam Linux Essentials - Exam 010, (version 1.6). Paid practice material for this exam is not available yet, but you can try its free sample questions.

Exam code
010-160
Vendor
LPI
Practice questions
Not available yet
Free sample questions
5
Question bank last updated
Not available yet

Try 2 sample questions

Taken from the free sample set for 010-160.

Question 1

Which of the following examples shows the general structure of a for loop in a shell script?

  1. Option A:

    for *.txt as file = > echo $file

  2. Option B:

    for *.txt ( echo $i )

  3. Option C:

    for file in *.txt do
    echo $i done

  4. Option D:

    for ls *.txt exec {} \;

  5. Option E:

    foreach @{file} { echo $i

    }

Show answer and explanation

Correct answer: C

The general structure of a for loop in a shell script is as follows 1 2 :

for variable in list do commands done

The variable is the name of a loop counter or iterator that takes on the values of the items in the list. The list can be a sequence of words, numbers, filenames, or the output of a command. The commands are the body of the loop that are executed for each va l ue of the variable. The do and done keywords mark the beginning and the end of the loop body.

The option C. for file in *.txt do echo $i done follows this structure, with the variable b e ing file, the list being *.txt (which matches all the files with the .txt extension in the cu r rent directory), and the command being echo $i (which prints the value of the variable i, which is presumably set somewhere else in the script).

The other options are incorrect because:

    A. for *.txt as file = > echo $file uses an invalid syntax for a for loop. The as ke y word is not part of the shell script syntax, and the = > symbol is not a valid operator. The correct way to write this loop would be:

for file in *.txt do echo $file done

    B. for *.txt ( echo $i ) uses an invalid syntax for a for loop. The parentheses are not part of the shell script syntax, and the loop body is missing the do and done keywords. The correct way to write this loop would be:

for i in *.txt do echo $i done

    D. for ls *.txt exec {} ; uses an invalid syntax for a for loop. The ls command is not a valid variable name, and the exec {} ; is not a valid command. This looks like a mix of a for loop and a find command. The correct way to write this loop would be:

for file in *.txt do exec $file done

    E. foreach @{file} { echo $i } uses an invalid syntax for a for loop. The foreach keyword is not part of the shell script syntax, and the @{file} and { echo $i } are not valid expressions. This looks like a mix of a for loop and a Perl syntax. The correct way to write this loop would be:

for file in * do echo $file done

[References:, Looping Statements | Shell Script - GeeksforGeeks, How do I write a ‘for’ loop in Bash? - Stack Overflow, ]

Question 2 (choose 2)

Which statements about the directory /etc/skel are correct? (Choose two.)

  1. Option A:

    The personal user settings of root are stored in this directory.

  2. Option B:

    The files from the directory are copied to the home directory of the new user when starting the system.

  3. Option C:

    The files from the directory are copied to the home directory of a new user when the account is created.

  4. Option D:

    The directory contains a default set of configuration files used by the useradd command.

  5. Option E:

    The directory contains the global settings for the Linux system.

Show answer and explanation

Correct answer: C, D

The /etc/skel directory is a skeleton directory that contains the default files and direct o ries that are automatically copied to the home directory of a new user when the account is created by the useradd command 1 2 .  The purpose of this directory is to provide a co n sistent and uniform environment for all new users and to save the system administr a tor’s time and effort in configuring the user settings 1 2 .  The /etc/skel directory can be customized by adding or removing files and directories as needed, depending on the desired default settings for the new users 1 2 .

The other options are incorrect because:

    A. The personal user settings of root are stored in this directory.  This is not true, as the personal user settings of root are stored in the /root directory, which is the home directory of the root user 3 .  The /etc/skel directory does not affect the root user’s se t tings, but only the settings of the new users created by the useradd command 1 2 .

    B. The files from the directory are copied to the home directory of the new user when starting the system.  This is not true, as the files from the directory are copied to the home directory of the new user when the account is created, not when starting the system 1 2 .  The copying process only happens once, when the useradd command is ex e cuted, and not every time the system is started 1 2 .

    E. The directory contains the global settings for the Linux system.  This is not true, as the directory contains the default settings for the new users, not the global settings for the Linux system 1 2 .  The global settings for the Linux system are usually stored in ot h er directories under /etc, such as /etc/default, /etc/sysconfig, /etc/init.d, etc 4 .

[References:, Understanding the /etc/skel directory in Linux – The Geek Diary, /etc/skel directory in Linux - techPiezo, Linux File System Hierarchy - /root directory - LinuxConfig.org, Linux configuration: Understanding *.d directories in /etc | Enable Sysadmin, , , , , ]
See all 5 free sample questions