Section 5 Lab
LPIC-1, Exam 1 (101-500)
By Christine Bresnahan
Recommended Linux Distributions for this exercise:
• CentOS version 7
• Ubuntu Desktop 18.04LTS
Note: For a successful lab session, it is assumed you are using the recommended Linux distribution(s) and
the recommended version, and that your Linux systems are booted. In addition, it is assumed that you can log
into the system as a standard user as well as either the root account or a user with super user privileges. Also,
you should have successfully completed the prior sections’ labs and sessions as well as viewed the videos in
this section.
Follow these actions to explore concepts and commands covered in this section (but please feel free to
explore as much as you want. And don’t forget that you can get help on the usage of these commands
through the man pages. Type in man and follow it with the utility name, then press Enter to view
information on the utility):
1. Log into either your Ubuntu or CentOS distro tty2 terminal, using the username and password you
created when you installed the system.
2. Start the process of creating a simple text file, by typing echo "Hello World" > [Link] and pressing
Enter.
3. Add a second line to the file, by typing echo "Berry Good" >> [Link] and pressing Enter.
4. Add a third line to the file, by typing echo "Zero Problems" >> [Link] and pressing Enter.
5. Add a fourth line to the file, by typing echo "Apple Tough" >> [Link] and pressing Enter.
6. View the file’s contents, by typing cat [Link] and pressing Enter.
7. Try using STDIN redirection by typing tr o O < [Link] and pressing Enter.
8. Try using STDOUT redirection by typing cat [Link] > [Link] and pressing Enter.
9. View the new file's contents by typing cat [Link] and pressing Enter. This file's contents should
be the exact same as the [Link] file's contents.
10. Append content via STDOUT redirection by typing echo "Appended text" >> [Link] and
pressing Enter.
11. View the appended text by typing cat [Link] and pressing Enter. You should see the text from the
preceding step at the file's end.
12. Cause an error message to display to STDERR by typing cat [Link] and pressing Enter.
You should see an error message display to your screen.
13. Trying using STDERR redirection, by typing cat [Link] 2>> [Link] and pressing
Enter. If done properly, this command will append the error message to the end of the [Link] file.
14. View the file's contents by typing cat [Link] and pressing Enter. You should see the text from the
preceding step at the file's end.
15. Add more text to the [Link] file, by typing cat [Link] >> [Link] and pressing Enter.
16. View the file's contents by typing cat [Link] and pressing Enter. You should see the text from the
preceding step at the file's end.
17. Determine how many times the word "Hello" is in the file using a pipe redirection, by typing
grep Hello [Link] | wc -l and pressing Enter. (If you have trouble with this command, make sure you
are using a lowercase L as an option on the wc command, and not a number one.) The resulting number
should be the number of times the word "Hello" is in the file.
18. Try saving the information from the above step as well as viewing it using pipe redirection and the tee
command, by typing grep Hello [Link] | wc -l | tee [Link] and pressing Enter.
19. View the [Link] file, by typing cat [Link]. Does the number contained in the file match the number
you received in the previous step? It should.
20. Using redirection and command building try to remove all the text files you just created in this lab, by
typing rm -i $(ls *.txt) and pressing Enter. Only type in y and press Enter for files you wish to delete.