RED HAT SYSTEM ADMINISTRATION I
1.7. Lab: Accessing the Command Line
Document Version: 2015-12-28
Copyright © 2015 Network Development Group, Inc.
[Link]
NETLAB Academy Edition, NETLAB Professional Edition, and NETLAB+ are registered trademarks of Network Development Group, Inc.
“Red Hat,” Red Hat Linux, and the Red Hat “Shadowman” logo are trademarks or registered trademarks of Red Hat, Inc. in the US
and other countries.
1.7. Lab: Accessing the Command Line
Contents
Introduction ........................................................................................................................ 3
Outcomes ............................................................................................................................ 3
Lab Topology ....................................................................................................................... 4
Lab Settings ......................................................................................................................... 5
1 Performance Checklist ................................................................................................ 6
12/28/2015 Copyright © 2015 Network Development Group, Inc. [Link] Page 2
1.7. Lab: Accessing the Command Line
Introduction
In this lab, you will use the Bash shell to efficiently execute commands using shell
metacharacters.
Outcomes
Practice using shell command line editing and history functions to efficiently
execute commands with minor changes.
Change the password of the student user to T3st1ngT1me.
Execute commands used to identify file types and display parts of text files.
12/28/2015 Copyright © 2015 Network Development Group, Inc. [Link] Page 3
1.7. Lab: Accessing the Command Line
Lab Topology
12/28/2015 Copyright © 2015 Network Development Group, Inc. [Link] Page 4
1.7. Lab: Accessing the Command Line
Lab Settings
The information in the table below will be needed in order to complete the lab. The
task sections below provide details on the use of this information.
Virtual Machine IP Address Account Password
(if needed) (if needed)
Server1 Machine [Link] student student
Desktop1 Machine [Link] student student
12/28/2015 Copyright © 2015 Network Development Group, Inc. [Link] Page 5
1.7. Lab: Accessing the Command Line
1 Performance Checklist
Before you begin...
Access the graphical login screen of the Desktop1 virtual machine.
The topology includes two virtual machines that are accessible to users. Take care to
perform the tasks as instructed, including using the appropriate virtual machine as
directed.
1. Log in as student using the password student.
a. At the GNOME login screen, click the student user account. Enter
student when prompted for the password.
b. Click Sign In once the password has been typed in.
12/28/2015 Copyright © 2015 Network Development Group, Inc. [Link] Page 6
1.7. Lab: Accessing the Command Line
2. Open a terminal window that will provide a bash prompt.
Select Applications → Utilities → Terminal.
3. Change student's password to T3st1ngT1me.
[student@desktop1 ~]$ passwd
12/28/2015 Copyright © 2015 Network Development Group, Inc. [Link] Page 7
1.7. Lab: Accessing the Command Line
4. Display the current time and date.
[student@desktop1 ~]$ date
5. Display the current time in the following format: HH:MM:SS A/PM.
[student@desktop1 ~]$ date +%r
6. What kind of file is /usr/bin/clean-binary-files? Is it readable by humans?
[student@desktop1 ~]$ file /usr/bin/clean-binary-files
12/28/2015 Copyright © 2015 Network Development Group, Inc. [Link] Page 8
1.7. Lab: Accessing the Command Line
7. Use the wc command and bash shortcuts to display the size of /usr/bin/clean-
binary-files.
The easiest shortcut to use is the Esc key + . (period) in order to reuse the argument
from the previous command. This can save you a lot of time when entering commands.
[student@desktop1 ~]$ wc <Esc>.
[student@desktop1 ~]$ wc /usr/bin/clean-binary-files
8. Display the first 10 lines of /usr/bin/clean-binary-files.
You can use the Esc key + . (period) shortcut again to reuse the previous argument.
[student@desktop1 ~]$ head /usr/bin/clean-binary-files
9. Display the last 10 lines at the bottom of the /usr/bin/clean-binary-files file.
[student@desktop1 ~]$ tail /usr/bin/clean-binary-files
12/28/2015 Copyright © 2015 Network Development Group, Inc. [Link] Page 9
1.7. Lab: Accessing the Command Line
10. Repeat the previous command, but use the -n 20 option to display the last 20
lines in the file. Use command line editing to accomplish this with a minimal
amount of keystrokes.
Up Arrow displays the previous command. Ctrl+a makes the cursor jump to the
beginning of the line. Ctrl+Right Arrow jumps to the next word, then add the -n 20
option and press Enter to execute the command.
[student@desktop1 ~]$ tail –n 20 /usr/bin/clean-binary-files
11. Execute the date command without any arguments to display the current date
and time.
[student@desktop1 ~]$ date
12/28/2015 Copyright © 2015 Network Development Group, Inc. [Link] Page 10
1.7. Lab: Accessing the Command Line
12. Use bash history to display just the time.
Display the list of previous commands with the history command to identify
the specific date command to be executed. Execute the command with
the !number history command.
The number in your history will likely differ from the example shown.
[student@desktop1 ~]$ history
13. Finish your session with the bash shell.
[student@desktop1 ~]$ exit
12/28/2015 Copyright © 2015 Network Development Group, Inc. [Link] Page 11