Skip to main content

101-500 LPIC-1 System Administrator Exam 101, Part 1 of 2, (version 5.0)

  • LPI
  • 5 free sample questions

About this exam

101-500 is the LPI exam LPIC-1 System Administrator Exam 101, Part 1 of 2, (version 5.0). Paid practice material for this exam is not available yet, but you can try its free sample questions.

Exam code
101-500
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 101-500.

Question 1

Which of the following commands replaces each occurrence of ' bob ' in the file letter with ' Bob ' and writes the

result to the file newletter?

  1. Option A:

    sed ' /bob/Bob ' letter > newletter

  2. Option B:

    sed s/bob/Bob/ letter < newletter

  3. Option C:

    sed ' s/bob/Bob ' letter > newletter

  4. Option D:

    sed ' s/bob/Bob/g ' letter > newletter

  5. Option E:

    sed ' s/bob, Bob/ ' letter > newletter

Show answer and explanation

Correct answer: D

The command that replaces each occurrence of ‘bob’ in the file letter with ‘Bob’ and writes the result to the file newletter is sed ‘s/bob/Bob/g’ letter > newletter. This command uses the following options and syntax:

    s: Specifies the substitution operation.

    /: Separates the pattern and the replacement strings.

    bob: The pattern to be searched and replaced.

    Bob: The replacement string.

    g: The global flag that indicates all occurrences of the pattern in each line should be replaced, not just the first one.

    letter: The name of the input file.

    : Redirects the output to a file.

    newletter: The name of the output file.

The output of this command will be a new file called newletter that contains the same text as letter, except that every ‘bob’ is replaced by ‘Bob’. For example, if the file letter contains the following text:

Dear bob, I hope this letter finds you well. I am writing to inform you that your subscription to our magazine has expired. If you wish to renew it, please send us a check for $50 by the end of this month. Otherwise, we will have to cancel your subscription and remove you from our mailing list. Thank you for your cooperation and support. Sincerely, Alice

The file newletter will contain the following text:

Dear Bob, I hope this letter finds you well. I am writing to inform you that your subscription to our magazine has expired. If you wish to renew it, please send us a check for $50 by the end of this month. Otherwise, we will have to cancel your subscription and remove you from our mailing list. Thank you for your cooperation and support. Sincerely, Alice

The other commands are incorrect for the following reasons:

    A. sed ‘/bob/Bob’ letter > newletter: This command is missing the s option and the second / delimiter, and will produce an error message.

    B. sed s/bob/Bob/ letter < newletter: This command is using the wrong redirection operator ( < instead of > ), and will try to read the input from newletter instead of letter, and write the output to the standard output instead of newletter.

    C. sed’s/bob/Bob’ letter > newletter: This command is missing a space between sed and the first ' , and will produce an error message.

    E. sed ‘s/bob, Bob/’ letter > newletter: This command is using a comma (,) instead of a slash (/) as a delimiter, and will produce an error message.

[References:, [LPI Exam 101 Detailed Objectives], Topic 103: GNU and Unix Commands, Objective 103.7: Perform basic file management, Weight: 4, Key Knowledge Areas: Use of sed to edit files in place., How to Use the sed Command on Linux, Topic: Substituting Text., , , ]

Question 2 (choose 2)

After moving data to a new filesystem, how can the former path of the data be kept intact in order to avoid

reconfiguration of existing applications? (Choose TWO correct answers.)

  1. Option A:

    By creating an ACL redirection from the old to the new path of the data.

  2. Option B:

    By creating a hard link from the old to the new path of the data.

  3. Option C:

    By creating a symbolic link from the old to the new path of the data.


  4. Option D:

    By running the command touch on the old path.

  5. Option E:

    By mounting the new filesystem on the original path of the data.

Show answer and explanation

Correct answer: C, E

The former path of the data can be kept intact by creating a symbolic link from the old to the new path of the data or by mounting the new filesystem on the original path of the data. A symbolic link is a special file that points to another file or directory. It can be used to create a shortcut to the new location of the data without changing the applications that access it. Mounting the new filesystem on the original path of the data means that the data will appear as if it is still in the same location, but it is actually stored on a differ ent device or partition. This can be done by editing the /etc/fstab file or using the mount command.  References :

    [LPI Linux Essentials - 1.3 Basic File Management]

    [LPI Linux Essentials - 1.4 Finding Files]

    [LPI Linux Essentials - 2.1 Using Devices, Linux Filesystems, Filesystem Hierarchy Standard]

    [LPI Linux Essentials - 2.2 Mounting, Unmounting Filesystems]

    [LPI Linux Essentials - 2.3 Disk Partitions]

See all 5 free sample questions