1.2.2 Lab - Linux Review
1.2.2 Lab - Linux Review
1.2.2 Lab - Linux Review
2
09/04/21
CPE 028-CPE41S2 Engr. Alonica
Villanueva
Objectives
Part 1: Launch the DEVASC VM
Part 2: Review Command Syntax Navigation
Part 3: Review File Management
Part 4: Review Regular Expressions
Part 5: Review System Administration
Background / Scenario
In this lab, you review basic Linux skills including command navigation, file management, regular expressions,
and system administration. This lab is not meant as a substitute for prior Linux experience and does not
necessarily cover all the Linux skills you need for this course. However, this lab should serve as a good
measure of your Linux skills and help direct you to where you may need more review.
Required Resources
1 PC with operating system of your choice
Virtual Box or VMWare
DEVASC Virtual Machine
Instructions
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 1 of 31 www.netacad.com
Lab - Linux Review
b. Use the ls command with the labs argument to display the contents of the labs folder.
devasc@labvm:~$ ls labs
devnet-src
devasc@labvm:~$
c. Use the ls command with the -l option to display a "long display" of the contents of the current directory.
devasc@labvm:~$ ls -l
total 40
drwxr-xr-x 2 devasc devasc 4096 Mar 30 21:25 Desktop
drwxr-xr-x 2 devasc devasc 4096 Apr 15 19:09 Documents
drwxr-xr-x 2 devasc devasc 4096 Apr 15 19:09 Downloads
drwxr-xr-x 5 devasc devasc 4096 Mar 30 21:21 labs
drwxr-xr-x 2 devasc devasc 4096 Apr 15 19:09 Music
drwxr-xr-x 2 devasc devasc 4096 Apr 15 19:09 Pictures
drwxr-xr-x 2 devasc devasc 4096 Apr 15 19:09 Public
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 2 of 31 www.netacad.com
Lab - Linux Review
d. Use the ls command with the -r option to display the contents of the current directory in reverse
alphabetical order.
devasc@labvm:~$ ls -r
Videos snap Pictures labs Documents
Templates Public Music Downloads Desktop
devasc@labvm:~$
e. Multiple options can be used at the same time. Use the ls command with both the -l and -r options to
display the contents of the current directory both in long and reverse order.
devasc@labvm:~$ ls -lr
total 40
drwxr-xr-x 2 devasc devasc 4096 Apr 15 19:09 Videos
drwxr-xr-x 2 devasc devasc 4096 Apr 15 19:09 Templates
drwxr-xr-x 5 devasc devasc 4096 Mar 30 21:24 snap
drwxr-xr-x 2 devasc devasc 4096 Apr 15 19:09 Public
drwxr-xr-x 2 devasc devasc 4096 Apr 15 19:09 Pictures
drwxr-xr-x 2 devasc devasc 4096 Apr 15 19:09 Music
drwxr-xr-x 5 devasc devasc 4096 Mar 30 21:21 labs
drwxr-xr-x 2 devasc devasc 4096 Apr 15 19:09 Downloads
drwxr-xr-x 2 devasc devasc 4096 Apr 15 19:09 Documents
drwxr-xr-x 2 devasc devasc 4096 Mar 30 21:25 Desktop
devasc@labvm:~$
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 3 of 31 www.netacad.com
Lab - Linux Review
f. There are many more options that can be used with the ls command. Use the man command with the
argument ls to see all of the possibilities in the manual. The man command can be used to look up any
command within the system. Use the space bar to advance to subsequent screens. Press q to quit.
devasc@labvm:~$ man ls
(The command line disappears and the manual page for ls opens.)
LS(1) User Commands LS(1)
NAME
ls - list directory contents
SYNOPSIS
ls [OPTION]... [FILE]...
DESCRIPTION
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is speci‐
fied.
-a, --all
do not ignore entries starting with .
-A, --almost-all
do not list implied . and ..
--author
Manual page ls(1) line 1 (press h for help or q to quit)
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 4 of 31 www.netacad.com
Lab - Linux Review
g. You can also use --help argument after most commands to see a shorter summary of all the available
command options.
devasc@labvm:~$ ls --help
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
Mandatory arguments to long options are mandatory for short options too.
-a, --all do not ignore entries starting with .
-A, --almost-all do not list implied . and ..
(Output Omitted)
devasc@labvm:~$
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 5 of 31 www.netacad.com
Lab - Linux Review
j. Use the cd command with the / symbol to change directories to the root directory. Use pwd again to see
that you are now in the root directory.
devasc@labvm:~/Documents$ cd /
devasc@labvm:/$ pwd
/
devasc@labvm:/$
k. Return to the /home/devasc/Documents directory. Tip: You can move one directory at a time or all the
way to a destination. To quickly enter the command, type the first few letters of the directory name and
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 6 of 31 www.netacad.com
Lab - Linux Review
press Tab for the system to automatically enter the rest of the name. Remember that names are case-
sensitive.
devasc@labvm:/$ cd /home/devasc/Documents/
devasc@labvm:~/Documents$
l. Use the .. characters to move up a single directory. Use pwd again to see you are back in the user’s
home directory.
devasc@labvm:~/Documents$ cd ..
devasc@labvm:~$ pwd
/home/devasc
devasc@labvm:~$
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 7 of 31 www.netacad.com
Lab - Linux Review
b. Answer the following questions about the output above. If necessary, search the internet for information of
Linux file permission shown in the output of the ls command.
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 8 of 31 www.netacad.com
Lab - Linux Review
Questions
b. Use the command echo to create a shell script file, that will have the command ls ../Desktop inside the
file. Remember that the greater than (>) character redirects command output to a file.
devasc@labvm:~/Documents$ echo "ls ../Desktop" > myfile.sh
devasc@labvm:~/Documents$
c. The myfile.sh script is stored in the /Documents directory. Use the cat command to view the only
command in the script. This file will be used as an example to modify permissions and ownership.
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 9 of 31 www.netacad.com
Lab - Linux Review
d. Use the command ./myfile.sh to run the script. Access is denied because you must set the permission of
executable on the file.
devasc@labvm:~/Documents$ ./myfile.sh
bash: ./myfile.sh: Permission denied
f. Use the command chmod +x myfile.sh to allow you to execute the file.
devasc@labvm:~/Documents$ chmod +x myfile.sh
devasc@labvm:~/Documents$
h. Use the command sudo chown root myfile.sh to change the ownership of the file to "root".
devasc@labvm:~/Documents$ sudo chown root myfile.sh
devasc@labvm:~/Documents$
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 10 of 31 www.netacad.com
Lab - Linux Review
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 11 of 31 www.netacad.com
Lab - Linux Review
devasc@labvm:~/Documents$
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 12 of 31 www.netacad.com
Lab - Linux Review
f. Use the echo command to overwrite the contents of a file using the single angle bracket.
devasc@labvm:~$ echo "Linux is POWERFUL!" > linux.txt
devasc@labvm:~$
g. Use the cat command to view the contents of the linux.txt file. Notice that the previous state “Linux is
AWESOME!” was overwritten.
devasc@labvm:~$ cat linux.txt
Linux is POWERFUL!
devasc@labvm:~$
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 13 of 31 www.netacad.com
Lab - Linux Review
The a key will allow you to enter edit mode, appending after the cursor’s position, while the i key will allow
you to enter edit mode, inserting at the cursor’s position. You will need to use the Esc key to enter
command mode to move around. Remember that d will delete (cut), y will yank (copy), and p will put
(paste) the current line with the cursor.
c. Save the text to a new file called "linux3.txt". Remember that you will need to be in the command mode
and type a colon ( : ) to enter ex mode so that you can write (save) the document ( :w linux3.txt). You
can then use the quit (exit) command ( :q) to exit the vi editor.
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 14 of 31 www.netacad.com
Lab - Linux Review
d. Use the cat command to view the contents of the linux3.txt file.
devasc@labvm:~$ cat linux3.txt
Linux is Linux
I am AWESOME!
devasc@labvm:~$
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 15 of 31 www.netacad.com
Lab - Linux Review
b. Use the grep command to show how many times root appears in the passwd file. Notice that all three
instances of root are highlighted.
devasc@labvm:~$ grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash
devasc@labvm:~$
c. Use the grep command with the anchor character ^ to find the word, but only at the beginning of the line.
Notice that only the word at the beginning of the line is highlighted.
devasc@labvm:~$ grep '^root' /etc/passwd
root:x:0:0:root:/root:/bin/bash
devasc@labvm:~$
d. Use the grep command with the anchor character $ to find a word at the end of a line.
devasc@labvm:~$ grep 'false$' /etc/passwd
tss:x:106:114:TPM software stack,,,:/var/lib/tpm:/bin/false
lightdm:x:107:117:Light Display Manager:/var/lib/lightdm:/bin/false
hplip:x:115:7:HPLIP system user,,,:/run/hplip:/bin/false
devasc@labvm:~$
e. Use the grep command with the anchor character . to match specific length words with different letters in
them. Notice that not only is daem highlighted, but also dnsm is highlighted.
devasc@labvm:~$ grep 'd..m' /etc/passwd
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
dnsmasq:x:109:65534:dnsmasq,,,:/var/lib/misc:/usr/sbin/nologin
avahi-autoipd:x:110:121:Avahi autoip daemon,,,:/var/lib/avahi-
autoipd:/usr/sbin/nologin
usbmux:x:111:46:usbmux daemon,,,:/var/lib/usbmux:/usr/sbin/nologin
avahi:x:113:122:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/usr/sbin/nologin
colord:x:116:125:colord colour management daemon,,,:/var/lib/colord:/usr/sbin/nologin
pulse:x:117:126:PulseAudio daemon,,,:/var/run/pulse:/usr/sbin/nologin
devasc@labvm:~$
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 16 of 31 www.netacad.com
Lab - Linux Review
f. Use the grep command to find lines where only the numbers 8 or 9 are present. Notice that only the lines
containing an 8, a 9, or both are returned.
devasc@labvm:~$ grep '[8-9]' /etc/passwd
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
uuidd:x:103:109::/run/uuidd:/usr/sbin/nologin
devasc:x:900:900:DEVASC,,,:/home/devasc:/bin/bash
systemd-network:x:999:999:systemd Network Management:/:/usr/sbin/nologin
systemd-resolve:x:998:998:systemd Resolver:/:/usr/sbin/nologin
systemd-timesync:x:997:997:systemd Time Synchronization:/:/usr/sbin/nologin
systemd-coredump:x:996:996:systemd Core Dumper:/:/usr/sbin/nologin
rtkit:x:108:119:RealtimeKit,,,:/proc:/usr/sbin/nologin
dnsmasq:x:109:65534:dnsmasq,,,:/var/lib/misc:/usr/sbin/nologin
devasc@labvm:~$
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 17 of 31 www.netacad.com
Lab - Linux Review
g. Use the grep command to find literal characters. Notice that only the lines containing a comma are
returned.
devasc@labvm:~$ grep '[,]' /etc/passwd
devasc:x:900:900:DEVASC,,,:/home/devasc:/bin/bash
tss:x:106:114:TPM software stack,,,:/var/lib/tpm:/bin/false
rtkit:x:108:119:RealtimeKit,,,:/proc:/usr/sbin/nologin
dnsmasq:x:109:65534:dnsmasq,,,:/var/lib/misc:/usr/sbin/nologin
avahi-autoipd:x:110:121:Avahi autoip daemon,,,:/var/lib/avahi-
autoipd:/usr/sbin/nologin
usbmux:x:111:46:usbmux daemon,,,:/var/lib/usbmux:/usr/sbin/nologin
kernoops:x:112:65534:Kernel Oops Tracking Daemon,,,:/:/usr/sbin/nologin
avahi:x:113:122:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/usr/sbin/nologin
hplip:x:115:7:HPLIP system user,,,:/run/hplip:/bin/false
colord:x:116:125:colord colour management daemon,,,:/var/lib/colord:/usr/sbin/nologin
pulse:x:117:126:PulseAudio daemon,,,:/var/run/pulse:/usr/sbin/nologin
devasc@labvm:~$
h. Use the grep command to find occurrences of zero or more of the pattern preceding it. Notice that only
the lines with either new and ne are returned.
devasc@labvm:~$ grep 'new*' /etc/passwd
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 18 of 31 www.netacad.com
Lab - Linux Review
messagebus:x:100:103::/nonexistent:/usr/sbin/nologin
_apt:x:102:65534::/nonexistent:/usr/sbin/nologin
tcpdump:x:104:110::/nonexistent:/usr/sbin/nologin
systemd-network:x:999:999:systemd Network Management:/:/usr/sbin/nologin
kernoops:x:112:65534:Kernel Oops Tracking Daemon,,,:/:/usr/sbin/nologin
saned:x:114:124::/var/lib/saned:/usr/sbin/nologin
devasc@labvm:~$
devasc@labvm:~$ shutdown -c
devasc@labvm:~$
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 19 of 31 www.netacad.com
Lab - Linux Review
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 20 of 31 www.netacad.com
Lab - Linux Review
b. Use the command ping with the options -c 4 to ping a computer on your local network four times. You
must use a valid IP address of a device on your local network. The following example is using
192.168.1.1, but your network will most likely have different IPv4 addresses.
devasc@labvm:~$ ping -c 4 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=63 time=1.13 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=63 time=2.30 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=63 time=1.31 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=63 time=2.49 ms
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 21 of 31 www.netacad.com
Lab - Linux Review
c. You can also ping a name and Domain Name System (DNS) will resolve the name to an IP address. For
example, ping Cisco’s website. Your VM will send out a DNS request first to get the IP address and then
send the ping packets. The DNS process is not shown in the ping output.
devasc@labvm:~$ ping -c 4 www.cisco.com
PING e2867.dsca.akamaiedge.net (23.204.11.200) 56(84) bytes of data.
64 bytes from a23-204-11-200.deploy.static.akamaitechnologies.com (23.204.11.200):
icmp_seq=1 ttl=58 time=185 ms
64 bytes from a23-204-11-200.deploy.static.akamaitechnologies.com (23.204.11.200):
icmp_seq=2 ttl=58 time=28.8 ms
64 bytes from a23-204-11-200.deploy.static.akamaitechnologies.com (23.204.11.200):
icmp_seq=3 ttl=58 time=28.8 ms
64 bytes from a23-204-11-200.deploy.static.akamaitechnologies.com (23.204.11.200):
icmp_seq=4 ttl=58 time=26.4 ms
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 22 of 31 www.netacad.com
Lab - Linux Review
b. Use the ps with the -e option to display all the processes that are running on the computer.
devasc@labvm:~$ ps -e
PID TTY TIME CMD
1 ? 00:00:01 systemd
2 ? 00:00:00 kthreadd
3 ? 00:00:00 rcu_gp
4 ? 00:00:00 rcu_par_gp
6 ? 00:00:00 kworker/0:0H-kblockd
7 ? 00:00:00 kworker/0:1-events
9 ? 00:00:00 mm_percpu_wq
(output omitted)
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 23 of 31 www.netacad.com
Lab - Linux Review
c. You can pipe any command output to one screen at a time by adding | more. One screen of output
displays with the --more-- shown at the bottom. You can now use the Enter key to display one line at a
time, the space bar to display one screen at a time, or Ctrl+C to exit and return to the command prompt.
devasc@labvm:~$ ps -e | more
PID TTY TIME CMD
1 ? 00:00:01 systemd
2 ? 00:00:00 kthreadd
3 ? 00:00:00 rcu_gp
4 ? 00:00:00 rcu_par_gp
6 ? 00:00:00 kworker/0:0H-kblockd
9 ? 00:00:00 mm_percpu_wq
10 ? 00:00:00 ksoftirqd/0
--More—
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 24 of 31 www.netacad.com
Lab - Linux Review
d. Use the ps with the -ef option to display all the processes that are running on the computer with more
detail.
devasc@labvm:~$ ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 20:57 ? 00:00:01 /sbin/init
root 2 0 0 20:57 ? 00:00:00 [kthreadd]
root 3 2 0 20:57 ? 00:00:00 [rcu_gp]
root 4 2 0 20:57 ? 00:00:00 [rcu_par_gp]
root 6 2 0 20:57 ? 00:00:00 [kworker/0:0H-kblockd]
root 9 2 0 20:57 ? 00:00:00 [mm_percpu_wq]
root 10 2 0 20:57 ? 00:00:00 [ksoftirqd/0]
root 11 2 0 20:57 ? 00:00:01 [rcu_sched]
(output omitted)
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 25 of 31 www.netacad.com
Lab - Linux Review
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 26 of 31 www.netacad.com
Lab - Linux Review
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 27 of 31 www.netacad.com
Lab - Linux Review
d. Now you can use the speedtest-cli command to test your current Internet connection speed.
devasc@labvm:~$ speedtest-cli
Retrieving speedtest.net configuration...
Testing from Cable Company (192.168.100.21)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Comcast (Albuquerque, NM) [494.76 km]: 48.636 ms
Testing download
speed................................................................................
Download: 90.87 Mbit/s
Testing upload
speed.................................................................................
.....................
Upload: 17.87 Mbit/s
devasc@labvm:~$
e. Use the command apt-get upgrade to update all packages and dependencies on the computer.
devasc@labvm:~$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
libnss-systemd libpam-systemd libsystemd0 libyelp0 linux-generic linux-headers-
generic
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 28 of 31 www.netacad.com
Lab - Linux Review
(output omitted)
f. Use the command apt-get purge to completely remove a package from the computer.
devasc@labvm:~$ sudo apt-get purge speedtest-cli
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
speedtest-cli*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 106 kB disk space will be freed.
Do you want to continue? [Y/n]
(Reading database ... 211937 files and directories currently installed.)
Removing speedtest-cli (2.1.2-2) ...
(output omitted)
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 29 of 31 www.netacad.com
Lab - Linux Review
c. Use the manual pages for the passwd command (man passwd) to research the -S option and find the
answer the following questions.
Questions
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 30 of 31 www.netacad.com
Lab - Linux Review
What is the minimum number of days that must pass before the password can be changed?
The minimum number of days that must pass before the password can be changed is 0
What is the number of days after password expiration that the account remains active?
There are no days after password expiration that the account remains active
- 2021 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 31 of 31 www.netacad.com