1.2.2 Lab - Linux Review
1.2.2 Lab - Linux Review
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
© 2020 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 1 of 15 www.netacad.com
Lab - Linux Review
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
drwxr-xr-x 5 devasc devasc 4096 Mar 30 21:24 snap
drwxr-xr-x 2 devasc devasc 4096 Apr 15 19:09 Templates
drwxr-xr-x 2 devasc devasc 4096 Apr 15 19:09 Videos
devasc@labvm:~$
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:~$
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
© 2020 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 2 of 15 www.netacad.com
Lab - Linux Review
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)
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:~$
h. Use the pwd command to display the current working directory.
devasc@labvm:~$ pwd
/home/devasc
devasc@labvm:~$
i. Use the cd command to change the directory to /home/devasc/Documents.
devasc@labvm:~$ cd Documents
devasc@labvm:~/Documents$
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
© 2020 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 3 of 15 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:~$
© 2020 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 4 of 15 www.netacad.com
Lab - Linux Review
Questions
© 2020 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 5 of 15 www.netacad.com
Lab - Linux Review
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$
g. Use the command ./myfile.sh to run the script.
devasc@labvm:~/Documents$ ./myfile.sh
chromium_chromium.desktop exo-terminal-emulator.desktop
cisco-packet-tracer_cisco-pacet-tracer.desktop labs.desktop
code.desktop postman_postman.desktop
drawio_drawio.desktop
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$
i. Display the permissions of the myfile.sh file.
devasc@labvm:~/Documents$ ls -l
total 4
-rwxrwxr-x 1 root devasc 14 Apr 16 21:28 myfile.sh
devasc@labvm:~/Documents$
© 2020 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 6 of 15 www.netacad.com
Lab - Linux Review
devasc@labvm:~/Documents$ ls
myfile_renamed_and_copied.sh myfile_renamed.sh
devasc@labvm:~/Documents$
© 2020 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 7 of 15 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.
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:~$
© 2020 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 8 of 15 www.netacad.com
Lab - Linux Review
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:~$
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:~$
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.
© 2020 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 9 of 15 www.netacad.com
Lab - Linux Review
© 2020 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 10 of 15 www.netacad.com
Lab - Linux Review
© 2020 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 11 of 15 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--
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]
© 2020 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 12 of 15 www.netacad.com
Lab - Linux Review
(output omitted)
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................................................................................
© 2020 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 13 of 15 www.netacad.com
Lab - Linux Review
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)
© 2020 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 14 of 15 www.netacad.com
Lab - Linux Review
Questions
© 2020 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 15 of 15 www.netacad.com