0% found this document useful (0 votes)
78 views

LPIC 1 LAB CH 1 - Performing Basic Linux Tasks

This document provides instructions for completing a lab on performing basic Linux tasks. The lab covers topics such as entering shell commands, changing directories, viewing and editing files, and assuming superuser privileges. Students are instructed to log into a remote Linux server, execute commands like ls, cat, vim and sudo, and complete tasks like creating files, editing text, and viewing log files and documentation. Help topics like man pages and apropos are demonstrated to assist with finding the appropriate commands.

Uploaded by

tapunan kalat
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views

LPIC 1 LAB CH 1 - Performing Basic Linux Tasks

This document provides instructions for completing a lab on performing basic Linux tasks. The lab covers topics such as entering shell commands, changing directories, viewing and editing files, and assuming superuser privileges. Students are instructed to log into a remote Linux server, execute commands like ls, cat, vim and sudo, and complete tasks like creating files, editing text, and viewing log files and documentation. Help topics like man pages and apropos are demonstrated to assist with finding the appropriate commands.

Uploaded by

tapunan kalat
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Linux LPIC-1 Lab Guide

BEFORE YOU BEGIN


You need to access your Remote Lab Server by following the instructions from this
link

Topic 1: Performing Basic Linux Tasks

Lab 1-1: Entering Shell Commands


BEFORE YOU BEGIN
You have a CentOS 7 system that has already been installed for you, as well as a user account. The
system is presenting you with a CLI.

1. Log in to the CLI.


a) At the localhost login prompt, enter trainee.
b) At the Password prompt, enter Cnctc@2022
c) Verify that you are presented with a [trainee@localhost ~]$ prompt, indicating that
you have successfully logged in.
2. Enter your first command.
a) At the prompt, enter echo 'Hello, World!'
b) Verify that the console printed the string "Hello, World!" back to you.
3. Retrieve information about your current working directory.
a) Enter pwd
b) Verify that your current working directory is /home/trainee
c) Enter ls and note the contents of your current working directory.
At the moment, there doesn't seem to be anything in your home directory.
d) Enter ls -a to display hidden items.
Now, you can see that there are files and folders in this directory, but they are hidden from
a standard directory listing.
e) Enter ls -al and note that you are given more information about each item in the
directory.

@2020 version 1.0 1


Linux LPIC-1 Lab Guide

The name of the file or folder is on the right. The last modified date and time is to the left of
the name, and to the left of that is the size of the file or folder (in bytes). Most of the other
fields relate to permissions and ownership.

4. Change your current working directory.


a) Enter cd /etc
b) Verify that the prompt has changed to [trainee@localhost etc]$
c) Enter pwd to further verify that your current working directory is now /etc
d) Enter cd /var/log to move to the directory where system log files are stored.
e) Enter ls -al to see all of the files and folders that exist in this directory.
f) Enter cd /home/trainee to move back to yourhome directory.

5. Create a file in your home directory.


a) Enter touch myfile to create an empty file in your home directory.
b) Enter ls and verify that myfile is listed in the directory.

6. View some files using the cat command.


a) Enter cat /etc/hostname
b) Verify that the contents of the /etc/hostname file are printed at the CLI.
c) Enter cat /var/log/dmesg
d) Verify that this log file is so long that much of its contents scroll past the screen.
The cat command has no navigational options, so you'll need to use a more advanced
command to view all of the log file.

7. View lengthy files using the less command.

@2020 version 1.0 2


Linux LPIC-1 Lab Guide

a) Enter less /var/log/dmesg


Instead of scrolling, the less command printed only the beginning contents of the file that fit
on the screen. Your prompt has also changed to the name of the file, highlighted.
b) Press Enter or Down Arrow to scroll down one line.
c) Scroll down a few more lines.
d) Press y or Up Arrow to scroll up one line.
e) Scroll up a few more lines.
f) Press Spacebar or Page Down to scroll down an entire screen.
g) Press b or Page Up to scroll up an entire screen.
h) Press q to quit viewing the file and return to your regular prompt.

8. Edit a text file with Vim.


a) Enter vim myfile to open the file you created earlier in the Vim text editor.
b) Press i to switch to insert mode.
c) Type Hello, this is <your name> and replace <your name> with your first name.
d) Press Esc to switch back to command mode.
e) Enter :wq to save the file and quit.
f) Enter cat myfile and verify that the contents of the file are printed to the CLI.

9. Create and edit a text file with GNU nano.


a) Enter nano myfile2 to create and begin editing a new file.
b) Type Hello, this is <your name> and replace <your name> with your first name.
c) Press Ctrl+O, then press Enter to save the file.
d) Press Ctrl+X to quit.
e) Enter cat myfile2 and verify that the contents of the file are printed to the CLI.
f) Enter clear to clear the screen

10. Assume superuser privileges.


a) Enter cat /var/log/boot.log
b) Verify that you are given a "Permission denied" error.
As a regular user, you do not have permission to read this log file. You need to elevate your
privileges to do so.

@2020 version 1.0 3


Linux LPIC-1 Lab Guide

c) Enter su - root
d) At the Password prompt, enter Cnctc@2022
e) Verify that your prompt has changed to [root@localhost ~]#
You are now logged in as the root user, the user with the highest level of privileges
(superuser).
f) Enter cat /var/log/boot.log and verify that you can now read the file.
g) Enter exit to log out as root and log back in to your regular student account.

11. Leverage tab completion to make typing commands more efficient.


a) Enter touch thisisalongfilename.txt
b) Type ls -l th and then press Tab.
c) Verify that the rest of the file name is filled at the command-line.
d) Press Enter to execute the command.

12. View the command history.


a) Type his and press Tab.
b) Verify that the history command is populated at the command-line.
Tab completion works on file, directory, and even command names.
c) Press Enter to execute the command.
d) Verify that a list of the commands you recently entered is printed on the screen.

13. Restart the computer.


a) Enter reboot
b) Verify that the computer restarts, and then prompts you to log in.
c) Log in as trainee with Cnctc@2022 as the password.

@2020 version 1.0 4


Linux LPIC-1 Lab Guide

Lab 1-2: Accessing Help in Linux


BEFORE YOU BEGIN
You are logged in to the CLI as your student account.

1. If necessary, log in as trainee with a password of Cnctc@2022

2. Look for a command that could help you search the contents of a text file.
a) Enter apropos search
b) Verify that multiple commands are listed in the output, each of which includes the
c) term "search" in its name or brief description.
d) You could try to pick out the appropriate command from these results, but changing your
search might narrow them down.
e) Enter clear to clear the screen.
f) Enter apropos pattern
g) Verify that you receive fewer results

3. Looking at these results, which command(s) do you think would best fulfill the capabilities
that you're looking for?
Answers may vary, but one of the grep variants is likely the most appropriate command. The
awk command and its variants could be helpful, but appear to be more advanced.

4. Read the manual page for a command that could be what you're looking for.
a) Enter man grep
b) Verify that you see the manual page for the grep command.
c) Read the SYNOPSIS section to understand how to use the command.
d) Read the DESCRIPTION section to understand what the command does.
e) Navigate up and down the man page using the same keys as the less command.
f) Enter /case to search the man page for the term "case".
g) Press n to navigate to the next instance of the search term.
h) When you're at the end of the man page, press Shift+N to navigate to the previous instance
of the search term.
i) Read the description for the command option that has to do with case.

5. Given what you've read in the man page for grep so far, answer what youthink the
following command does: grep -i hello myfile
This command will return any lines in the file myfile that contain the text "hello", no matter
what case the text is in (case insensitive).

@2020 version 1.0 5


Linux LPIC-1 Lab Guide

6. Search for more information about the grep command.


a) Press q to quit the man page.
b) Enter cd /usr/share/doc
c) Enter ls
d) Verify that there are many subdirectories in this directory, each of which corresponds to a
software package.
e) Type cd grep and press Tab.
f) Verify that the path to the specific version of grep is completed, then press Enter.
g) Enter ls
h) Enter less NEWS
i) Briefly skim the change notes for the grep command.
j) Press q to quit.

7. How confident are you that this command fulfills what you're looking for?
Answers may vary, but the grep command does generally meet your requirements.
However, this doesn't mean it's the only command, or the best command, for the job.

8. You still want to learn more about other commands that your team could use to search
the contents of a text file. Aside from the help options built into Linux, what other sources
can you consult in your research?
Answers may vary, but there is a wide variety of useful sources on the Internet that could
help you find what you're looking for. You could pose specific answers to Q&A sites like Stack
Exchange; ask discussion questions on newsgroups, mailing lists, and forums dedicated to
Linux support; consult supplementary and/or advanced documentation through a resource
like the Linux Documentation Project; or consult distro-specific documentation on the
relevant distro's website

@2020 version 1.0 6

You might also like