Section 6 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 & viewed this section's videos.
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. Try a simple regular expression (regex) search using grep on the password file, by typing
grep home /etc/passwd and pressing Enter. If the word "home" is not found, try substituting a
different word, such as your username (which you can determine from the whoami command).
3. Try another basic regular expression (BRE) by searching for a word at the end of each password file
record, by typing grep nologin$ /etc/passwd and pressing Enter. If the word "nologin" is not found,
try substituting the word "false" or "bash" for the last word.
4. Search for a word in the password file's records' beginning, by typing grep ^nobody /etc/passwd and
pressing Enter. If the word "nobody" is not found, try substituting a different word, such as your
username (which you can determine from the whoami command).
5. Try an extended regular expression (ERE), by typing grep -E (nologin$|bash$) /etc/passwd and
pressing Enter. You should get an error message.
6. Recall your previous command and add quotes in the correct location to shell quote special characters, so
your command now looks like this: grep -E "(nologin$|bash$)" /etc/passwd
And press Enter. Now you should get some results without any error messages.
7. Try using the older variant of the grep -E command for a ERE search, by typing
egrep "(nologin$|bash$)" /etc/passwd and pressing Enter. It's OK if your system does not have the
egrep program and you get a command not found error message.
8. Try substituting the first instance of the colon (:) in the password file's records for a $, by typing
sed 's/:/$/' /etc/passwd and pressing Enter.
9. Now substitute every instance of the colon (:) in the password file's records for a $, by typing
sed 's/:/$/g' /etc/passwd and pressing Enter.
10. Look at the absolute directory reference of the sed program, by typing which sed and pressing Enter.
11. Find files and information, such as it's man page file locations, for the sed program, by typing
whereis sed and pressing Enter.
12. View the file type of the whereis command by typing type whereis and pressing Enter. Most likely you
will see that the whereis command is currently hashed and receives its absolute directory location.
13. View the file type of the cd command by typing type cd and pressing Enter. You should see that the cd
command is a built into the shell.
14. Find the whereis command files, by typing locate whereis and pressing Enter.
15. This command may take a while to run, and it is OK if you get error messages. Find the whereis
command files, by typing find / -name whereis and press Enter.
16. Recall your last command and send the error messages to the "black hole" to make the output easier to
read by modifying the command so it looks like this: find / -name whereis 2>> /dev/null
And pressing Enter.