Linux Labs
Linux Labs
Lab Purpose:
Lab Tool:
Lab Topology:
Lab Walkthrough:
Task 1:
● ip addr show
Machine's local IPv4 address: 192.168.241.3
● ip route show
● cat /etc/hosts
● cat /etc/resolv.conf
DNS Servers:
Task 2:
Now turn off your Wi-Fi, disconnect your Ethernet cable, or disable
the network connection to your VM. Then run the first three of those
commands again.
The state DOWN for eth0 indicates that network interface isn't
currently active
Task 3:
● host -v 101labs.net
Question: Can you ping 101labs.net? If not, how might you diagnose
the problem?
Task 4:
Now, make sure to stop anything important you might be doing... then
run:
Notes:
Lab Objective:
Learn how to create, copy, rename, and delete files and directories using
Linux commands.
Lab Purpose:
Get hands-on experience with basic file system management commands
needed for navigating and modifying Linux filesystems.
Lab Tool:
Lab Topology:
Step 1: Open your terminal and create a new file called hackingskills using
cat:
cat > hackingskills
Type:
Hacking is the most valuable skill set of the 21st century!
Type:
Everyone should learn hacking
Press Ctrl-D.
Step 3: View the contents of the file:
cat hackingskills
mkdir newdirectory
cp oldfile newdirectory/
cp newdirectory/newfile ~/secretfile
The tilde (~) means your home folder.
rm newdirectory/newfile
rmdir newdirectory
rm -r newdirectory
Notes:
Lab Objective:
Learn how to navigate to parent directories and traverse the directory tree
using relative paths .. and ../...
Lab Purpose:
Lab Tool:
Lab Topology:
Single Linux machine or virtual environment with multiple nested
directories.
ls -l
mkdir -p level1/level2/level3
The -p option in the mkdir command stands for "parents". It allows you to
create parent directories as needed, meaning:
● If any of the specified directories don't exist, mkdir -p will create all
necessary parent directories without error.
● If the directories already exist, it won't throw an error—they're simply
ignored.
cd ..
Step 1: Use ../.. to move up two levels to the root of these directories:
cd ..
cd ~
cd level1
cd level2
Notes:
Lab Objective:
Learn how to effectively view and navigate large text files using more, less,
head, and tail commands.
Lab Purpose:
Lab Tool:
Lab Topology:
Single Kali Linux machine or virtual environment with sample text files.
Step 1: Create a sample text file containing multiple lines, for example:
seq 1 50 > sample.txt
Notes:
Lab Tool:
Lab Topology:
Lab Walkthrough:
Task 1:
cat /etc/ld.so.conf{,.d/*}
/etc/ld.so.conf and the included files specify the directories where shared
libraries are stored.
This syntax is a shortcut for /etc/ld.so.conf /etc/ld.so.conf.d/*.
cat: Concatenates and displays the content of files.
This command shows all directories where the system looks for shared
libraries.
Task 2:
Now run:
● ldd $(which passwd) shows the specific shared libraries that passwd
uses when executed.
● ldd: "List Dynamic Dependencies" — shows all shared libraries linked
to a binary.
● which passwd: Finds the full path of the passwd command.
○ which: searches for a command in your PATH.
○ passwd: the command used to change user passwords.
● $(): Command substitution — runs the command inside and replaces
it with its output.
So, which passwd gives you the path to passwd, and ldd shows all the
shared libraries needed to run it.
This command shows which shared libraries are linked by the passwd tool.
Lab Purpose:
In this lab, you will learn how to create users and groups, as well as set
their passwords.
Lab Tool:
Lab Topology:
Lab Walkthrough:
Task 1:
Here, you’re adding a file to the /etc/skel directory, which determines the
default files in a new user’s home directory. Now:
You should see the output “Hello World.” You created a new user called
foo, and every file in /etc/skel was copied to the new user’s home directory.
Finally, set an initial password for this user with:
Task 2:
When adding a system user, useradd does not add account or password
aging information and sets a user ID appropriate for a system user
(typically below 1000). It also does not create a home directory unless you
specify -m.
Task 3:
Task 4:
sudo rm /etc/skel/hello.txt
sudo rm -r /home/foo
Notes:
Learn how to identify the differences between the root user, standard users,
and system users.
Lab Purpose:
In this lab, you will learn about the different types of Linux users and tools
to identify and audit them.
Lab Tool:
Lab Walkthrough:
Task 1:
cat /etc/passwd
1. Username
2. Encrypted password (rarely used)
3. User ID
4. Group ID
5. Comment
6. Home directory
7. Default shell
Standard user IDs typically begin at 1000 or 500, while most others are
system users used to run specific services.
Task 2:
Now run:
1. Username
2. Encrypted password
3. Date of last password change
You can view this information for your own user with:
Task 3:
Run:
cat /etc/group
This file contains a database of all groups on the system, with four fields
separated by colons:
id
Task 4:
who
● Interpretation:
User ruth is logged in on tty7, which typically corresponds to the
graphical display (the desktop environment). The login time is May 7,
2025, at 03:52.
Interpretation:
last
● Interpretation:
○ ruth logged in on tty7 at 03:52 on May 7, but the session ended
without proper logout (gone - no logout).
○ The system was booted twice on May 2 and May 7.
Lab Purpose:
In this lab, you will learn to use chmod, chown, chgrp, and umask.
Lab Tool:
Kali Linux (latest version)
Lab Topology:
Lab Walkthrough:
Task 1:
ls -l foo
Check the first field; you should see -rw-r--r--. This indicates read/write
permissions for the user who owns the file (rw-), read-only permissions for
the group (r--), and read-only permissions for others (r--). The first
character signifies the file type.
Identify the user and group owners of this file in the third and fourth fields of
the ls -l output.
Basic structure
● The first character indicates the file type:
○ - : Regular file
○ d : Directory
○ l : Symbolic link
○ c : Character special file
○ b : Block special file
○ p : Pipe (named pipe)
○ s : Socket
● Next nine characters: permissions for user, group, others in sets of
three
Permission characters
● r: read
● w: write
● x: execute
● -: no permission
Permission sets
Examples
● -rw-r--r--: user can read/write, group can read, others can read
● -rwxr-xr-x: user has full control, group and others can read and
execute
● -rwx------: user has full control, no one else has access
0 --- no permissions
Now run:
ls -l foo
cat foo
You’ve changed the user ownership to root, and the group ownership
remains the same. Since the file has group- and world-read permissions,
you can still see its contents.
Task 3:
Now run:
ls -l foo
cat foo
Task 4:
Now run:
sudo chgrp root foo
ls -l foo
cat foo
This changes the permissions to read/write for the owning user only. As the
owner is root, you can no longer read the file.
Task 5:
The default permissions for newly created files can be adjusted with
umask:
u=$(umask)
umask 0777
● This masks out all permissions for new files and directories, meaning
no permissions will be granted to anyone** when creating new files**.
touch bar
ls -l bar
umask $u
The bar file should have no permissions set, as you masked them all out.
What is umask?
● When creating a new file, the umask value is subtracted from the
default permissions.
● The result is the actual permissions assigned.
Basic example:
Suppose:
And:
umask 022
For files:
● Default: 666
● 666 minus 777 → 000
● Result: no permissions for owner, group, or others.
For directories:
● Default: 777
● 777 minus 777 → 000
● Result: no permissions at all— owner, group, others all have no
access.
In summary:
Caution:
Task 6:
Lab Objective:
Lab Purpose:
Lab Tool:
Lab Topology:
Lab Walkthrough:
Task 1:
Open the Terminal application and run your favorite text editor, such as vi
or nano. (If you have never used vi or vim, then nano is recommended.)
Type:
nano script.txt
Create a file with the following contents:
#!/bin/bash
echo $n
done
Save (Ctrl + O), press enter to write to file, then exit (Ctrl + X).
Task 2:
chmod +x script.txt
./script.txt 10
Task 3:
Run your script without an argument:
./script.txt
echo $?
Notes:
The first line, starting with #! (called a shebang), denotes which program
will interpret your script. This is typically /bin/bash, but it could also be
another shell (like /bin/zsh) or even another programming language (like
/usr/bin/python). Always include it to ensure compatibility across different
environments.
Lab Objective:
Learn how to use the Apt package manager to install, upgrade, search for,
and uninstall packages.
Lab Purpose:
Lab Tool:
Lab Topology:
Lab Walkthrough:
Task 1:
grep -v -e ^# -e ^$ /etc/apt/sources.list
cat /etc/apt/sources.list
You might not have any updates even if it has been a while since checking:
Task 2:
Let’s say you downloaded the source code for an application and it
complains that “libvorbis.so” is missing. You can use apt-file to check if a
package contains it:
You should find several packages, the most relevant being libvorbis-dev.
Confirm by running:
Notes:
You might be familiar with classic tools like apt-get and apt-cache. While
Apt doesn’t completely replace them, it’s more suitable for interactive usage
than scripting.
Lab Objective:
Learn how to use the dpkg package manager to install, uninstall, and
obtain information on packages.
Lab Purpose:
Lab Tool:
Lab Topology:
Lab Walkthrough:
Task 1:
dpkg -l
This lengthy list is your list of installed packages. To get more information
on a given package, try:
dpkg -s sudo
dpkg -L sudo
dpkg -p sudo
To install a package manually, you would download the .deb file and run:
dpkg -P [package]
Notes:
Lab Objective:
Learn how to access and use major open-source desktop applications on
Kali Linux.
Lab Purpose:
In this lab, you will become familiar with common open-source desktop
tools available in Kali Linux. These tools are widely used for productivity,
media editing, and web browsing in Linux environments.
Lab Tool:
Kali Linux (latest version)
Lab Topology:
A single Kali Linux machine, or virtual machine.
Lab Walkthrough:
ls /usr/share/applications/
Scroll through the list and take note of common applications such as:
● LibreOffice
● GIMP
● Firefox ESR
● Terminal
● File Manager
Question:
Which desktop applications did you open, and what is their primary
function?
Close LibreOffice and verify that the files were saved successfully.
Question:
Which format is better for sharing with users on different platforms, and
why?
Question:
What are some advantages of using GIMP over proprietary tools?
Task 4: Browse the Web with Firefox ESR
Open Firefox ESR.
Visit the following websites:
● https://www.kali.org
● https://libreoffice.org
● https://gimp.org
Question:
How can browser bookmarks and a customized homepage improve your
workflow?
vlc
Question:
What command would you use to remove VLC if you no longer need it?
Notes:
Open-source desktop applications are powerful alternatives to commercial
software. Kali Linux comes with several productivity and multimedia tools
pre-installed, and you can install more applications using the apt package
manager.
Lab Objective:
Learn essential ICT skills and foundational Linux operations using the Kali
Linux environment.
Lab Purpose:
In this lab, you will practice basic Linux command-line skills, file
management, user permissions, and system navigation—critical for
working effectively in any Linux-based environment.
Lab Tool:
Kali Linux (latest version)
Lab Topology:
A single Kali Linux machine, or virtual machine.
Lab Walkthrough:
pwd
ls -l
cd /etc
ls -a
cd ~
Question:
What does the pwd command show? How is ~ used in Linux file paths?
cd ~/lab5
cp notes.txt copy_notes.txt
mv copy_notes.txt final_notes.txt
rm notes.txt
Question:
What command would you use to move a file to a different directory?
whoami
ls -l final_notes.txt
Question:
What does the chown command do, and why is it important?
ps aux
top
Question:
How would you find and kill a misbehaving process?
man ls
Use --help:
mkdir --help
Question:
What is the difference between using man and --help?
Notes:
Mastering basic Linux commands is critical for all IT roles.
Kali Linux is a full-featured Linux OS and can be used for general ICT skill
development, not just penetration testing.
Practice using the terminal regularly to improve your confidence and
efficiency.
Lab Objective:
Learn the basic syntax of Linux commands and understand how quoting
works in the command line to manage strings, files, and commands
properly.
Lab Purpose:
In this lab, you will explore the syntax of Linux commands, including how
to use and differentiate between different types of quotes (single, double,
and backticks) in the command line.
Lab Tool:
Kali Linux (latest version)
Lab Topology:
A single Kali Linux machine, or virtual machine.
Lab Walkthrough:
ls /etc
cat /etc/hostname
ls -l /home
Question:
What is the purpose of the -l flag with the ls command?
cat single_quotes.txt
my_var="Kali Linux"
echo "Welcome to $my_var" > double_quotes.txt
cat double_quotes.txt
Question:
How does the use of single quotes differ from double quotes when
handling variables in the command line?
Question:
What happens when you combine single and double quotes? How does
the command output differ?
Question:
What is the purpose of escaping characters like spaces or dollar signs?
Why is this necessary in some scenarios?
Question:
How do the && and ; operators differ when chaining commands?
Notes:
Lab Objective:
Learn how to use various command-line tools and options to access help
documentation for Linux commands and applications.
Lab Purpose:
In this lab, you will practice using the built-in help utilities in Kali Linux, such
as man, info, --help, and what is, to get assistance and learn about
commands and their options.
Lab Tool:
Kali Linux (latest version)
Lab Topology:
A single Kali Linux machine, or virtual machine.
Lab Walkthrough:
Notes:
man pages are the primary source of detailed documentation for most
Linux commands.
--help is a quick reference for basic usage and options of a command.
info pages can sometimes provide more detailed information than man
pages, but they are less commonly used.
whatis and apropos help you find basic descriptions of commands or
search for commands related to a specific topic.
which shows the full path to the executable file for a command, which
can help diagnose issues related to system paths or command
availability.
Lab Objective:
Learn how to manage directories, navigate the file system, and list files
using various command-line tools in Kali Linux.
Lab Purpose:
In this lab, you will explore basic operations for creating, removing, and
navigating directories, as well as listing files and directories within the Linux
file system.
Lab Tool:
Kali Linux (latest version)
Lab Topology:
A single Kali Linux machine, or virtual machine.
Lab Walkthrough:
Task 1: Navigating the File System
Open your Terminal.
Print the current directory:
pwd
ls
ls -l
ls -a
Question:
What is the difference between ls and ls -a? How do hidden files behave in
Linux?
mkdir test_directory
ls
Question:
Why is it important to know how to handle directories with spaces in their
names?
cd test_directory
pwd
cd ~
cd /
Question:
How does the cd command work with absolute and relative paths? What is
the significance of ~ and /?
rmdir test_directory
Important:
rmdir only removes empty directories.
To delete directories that contain files or subdirectories, use:
rm -r directory_name
Question:
What is the difference between rmdir and rm -r when removing directories?
ls -l
ls -lh
ls -lt
Question:
How do the options -l, -h, and -t modify the output of the ls command?
ls /etc
cd /etc
ls ../
Question:
What is the difference between an absolute path and a relative path in
Linux?
Task 7: Using Tab Completion for Directories
Type part of a directory name, e.g.:
cd Doc
Notice how pressing Tab completes the directory name if it’s unique.
This speeds up navigation and reduces typos.
Question:
How does tab completion improve efficiency when navigating directories?
Notes:
Lab Objective:
Learn how to use pipes (|) and redirection (>, >>, <) in the command
line to search, filter, and manipulate data from files and commands.
Lab Purpose:
In this lab, you will practice combining commands with pipes,
redirecting output to files, and input redirection in Kali Linux. You will
also explore the power of searching and extracting specific data from
files using command-line tools.
Lab Tool:
Kali Linux (latest version)
Lab Topology:
A single Kali Linux machine or virtual machine.
Append additional text to the same file with append redirection (>>):
cat myfile.txt
Question:
What is the difference between > and >> when redirecting output to a
file?
Question:
How does input redirection work, and how is it different from output
redirection?
ls | wc -l
List running processes and search for a specific process like ssh:
Question:
How does piping (|) allow you to chain commands together? Why is
this useful?
Search case-insensitively:
Question:
What is the difference between case-sensitive and case-insensitive
searches with grep?
Question:
How does grep with the -v option change the search behavior?
ls | tee directory_list.txt
cat directory_list.txt
Question:
What is the benefit of using the tee command, and how does it differ
from simple redirection?
Question:
How does chaining multiple commands with pipes help refine your
search or filter output more effectively?
Notes:
Lab Objective:
Learn how to use regular expressions (regex) with the grep command and
other tools in Kali Linux to search for complex patterns in files.
Lab Purpose:
In this lab, you will practice using regular expressions to search and extract
data from files. You will understand how to create powerful search
patterns to match text based on specific criteria.
Lab Tool:
Kali Linux (latest version)
Lab Topology:
A single Kali Linux machine, or virtual machine.
Lab Walkthrough:
Notes:
✔ Regular expressions are powerful tools for pattern matching, making it
easier to search for complex strings in files.
✔ grep is one of the most common utilities for searching using regular
expressions, but there are other tools like sed and awk that provide
extended functionality with regex.
✔ Mastery of regular expressions can greatly improve your ability to
search, manipulate, and extract data from files and command outputs in
Linux.
Lab Objective:
Learn how to convert a series of commands into a reusable script to
automate tasks
in Kali Linux.
Lab Purpose:
In this lab, you will practice creating, editing, and running a simple shell
script. You will learn how to automate a series of commands to make your
workflow more efficient and how to make your scripts executable.
Lab Tool:
Kali Linux (latest version)
Lab Topology:
A single Kali Linux machine, or virtual machine.
Lab Walkthrough:
Notes:
✔ Scripting allows you to automate tasks and make repetitive tasks more
efficient.
✔ Always ensure that your scripts are executable by using chmod +x.
✔ Using variables, conditional statements, loops, and user input can make
your scripts dynamic and interactive.
✔ Debugging with bash -x is a useful way to track down errors in your
scripts.
Lab 20: Managing Scheduled Tasks with cron
Lab Objective:
Lab Purpose:
Tools:
Topology:
cat /etc/crontab
User-specific crontabs:
crontab -l
crontab -e
● Run:
crontab -e
● Explanation:
○ * * * * * → Run every minute.
○ date > ~/foo → Save the current date/time into the file foo in
your home directory.
● Wait a minute, then check the file:
cat ~/foo
● To clean up, remove the cron job and delete the file:
rm ~/foo
Additional notes:
● Access control files (/etc/cron.allow, /etc/cron.deny) restrict or permit
user access to crontab.
● On Kali Linux, by default, most users can edit their cron jobs
unless restricted.
Intermediate Labs
Lab Objective:
Learn about gathering information on and configuring storage devices and
special filesystems.
Lab Purpose:
In this lab, you will learn how to differentiate between various types of
mass storage devices, and about sysfs, udev, and dbus.
Lab Tool:
Kali Linux (latest version)
Lab Topology:
A single Kali Linux machine, or virtual machine.
Lab Walkthrough:
Task 1:
Open the Terminal and run:
ls /sys/block
This will give you a list of block devices on your system. At a minimum, you
should have a device such as sda or xvda. These are your standard disk
devices, like hard disks and USB drives. You may also have an optical
drive, such as sr0, and possibly one or more loopback devices.
To get more information on these devices, run:
lsblk
This will list all of those devices as well as their sizes, types, and mount
points. Your hard drive(s) should be labeled as “disk,” partitions as “part,”
loopback devices as “loop,” and optical or other read-only devices as “rom.”
Task 2:
Choose a device from above; for example, /dev/sda. Run:
Udev is a Linux subsystem that deals with hardware events, like plugging
and unplugging a USB keyboard. Here, we are using yet another tool to
gather information on a hard disk device (or another device of your choice).
Notice the first line from the output, beginning with “P:”. Tying back to
sysfs, this is the path for said device under the /sys filesystem. You can
confirm this with:
ls /sys/[path]
Task 3:
D-Bus is a mechanism for inter-process communication (IPC). Run:
dbus-monitor
Then open an application like Thunderbird. You will see a large number of
messages being sent back and forth between various processes. You might
need to use CTRL + C or q to quit.
Notes:
Challenge: Can you figure out how to suspend the system just by echoing
a value to a file under sysfs?
Lab Objective:
Learn how to manage SysVInit and Systemd, and understand the
differences between them.
Lab Purpose:
SysVInit and Systemd are two different ways of managing Linux startup
processes. SysVInit is considered the “classic” method, while Systemd has
supplanted it in many distros today.
Lab Tool:
Kali Linux (latest version)
Lab Topology:
A single Kali Linux machine, or virtual machine.
Lab Walkthrough:
Task 1:
Kali Linux is one of the distros that has switched to Systemd. However,
many SysVInit-based scripts are still present and active:
ls /etc/init.d
Every file in this directory is a script that starts, stops, checks status, and
possibly other features for a given service. You can see which scripts are
enabled for which runlevels with:
ls -lR /etc/rc*
Take a look at the symlinks listed under /etc/rc5.d. Runlevel 5 is the default
boot runlevel, when you’re booting normally into a desktop with a display
manager. Runlevel 0 (under /etc/rc0.d) contains links to the scripts run
when your computer is halted.
Task 2:
Now run:
These are the services that are enabled at boot within Systemd, and should
be mostly distinct from the ones listed under /etc/rc*. Use CTRL + C or q to
quit.
While SysVInit relies on standard shell scripts, Systemd uses unit files with
its own custom format. As just one example, take a look at:
cat /lib/systemd/system/rsyslog.service
Systemd unit files can have many options. See man systemd.unit for more
information.
Task 3:
Finally, take a look at those system logs with:
journalctl -xe
Journalctl is Systemd’s replacement for the classic syslog. Again, however,
Kali Linux still has quite a few logs in classic text format—see /var/log.
Notes:
Kali Linux has embraced Systemd, similar to other distributions. Unlike
older versions of Ubuntu which once used Upstart as a replacement for
SysVInit, Systemd has now become the standard for managing services.
Lab Objective:
Learn how to use temporary files and directories, symbolic links, and
special permissions.
Lab Purpose:
In this lab, you will work with symbolic links, special file/directory
permissions, and temporary files and directories.
Lab Tool:
Kali Linux (latest version)
Lab Topology:
A single Kali Linux machine, or virtual machine.
Lab Walkthrough:
Task 1:
Open the Terminal and run:
ls -ld /tmp
Notice the permissions: drwxrwxrwt. The "t" at the end indicates what is
called the sticky bit. This means that only users/groups who own a given
file may modify it. This is important on world-writable directories, such as
those holding temporary files, to prevent users from messing with other
users’ files.
Task 2:
Now run:
1. bash
2. ln -sv $(mktemp) mytmp
3. ls -l mytmp
4. rm mytmp
Lab Objective:
Learn how to manipulate file permissions and ownership settings.
Lab Purpose:
In this lab, you will learn to use chmod and chown, as well as view
permissions and ownership settings with ls.
Lab Tool:
Kali Linux (latest version)
Lab Topology:
A single Linux machine, or virtual machine.
Lab Walkthrough:
Task 1:
Open the Terminal and run (you may need to add the user ‘foo’ if you
removed it on the last lab):
ls -l foo
Look at the first field; you should see -rw-r--r--. This indicates the user,
group, and other permissions. The last nine characters, in groups of three,
denote these permissions. In this instance:
● rw- indicates read/write (but not execute) permissions for the user
who owns the file.
● r-- indicates read-only permissions for the group that owns the file.
● r-- indicates read-only permissions for all non-owners, a.k.a. “world”.
The first character indicates the type of file. In this case, it is a regular file;
directories begin with d.
Who are the user and group owners of this file? The third and fourth fields
of ls -l tell us that. By default, it should be your own user and primary group.
Task 2:
Now run:
ls -l foo
cat foo
You’ve just changed the user ownership to root, while keeping the group
ownership. As the file has group- and world-read permissions, you can still
see its contents.
Task 3:
Now run:
ls -l foo
cat foo
Task 4:
Now run:
ls -l foo
cat foo
This chmod command sets the permissions explicitly to read-write for the
owning user only. As that is root, we can no longer read the file.
Task 5:
Finally, clean up with:
sudo rm foo
Notes:
Execute permissions come into play on executable files, as well as
directories. If a user/group cannot "execute" a directory, it cannot view the
contents of that directory or any subdirectories.
Lab Objective:
Learn how to use pipes and redirect input and output in Bash.
Lab Purpose:
Bash has two commonly used features, known as pipes and I/O
redirection, that make life easier when using Linux. In this lab, you will learn
how to make use of these powerful features.
Lab Tool:
Kali Linux (latest version)
Lab Topology:
A single Linux machine, or virtual machine.
Lab Walkthrough:
Task 1:
Open the Terminal application and run:
mkdir lab13
cd lab13
echo "hello world" > hello
cat hello
You just redirected the output from your echo command into the hello file.
The > is a shortcut; the proper version of this would be 1>, where 1 is
called a file descriptor, which references the standard output.
Task 2:
Now run:
cat hello
Based on the new contents of the hello file ("ls: cannot access
‘nonexistent’: No such file or directory"), what can you surmise about the
function of 2>>? Here, 2 is a file descriptor for standard error.
Task 3:
Sometimes, you want to redirect both output and error to the same place.
In ye olden days, you would have to do something like this:
Task 4:
We’ve talked about redirecting output, but what about input? To learn
about that, run the following commands:
goodbye
END-OF-FILE
cat goodbye
In short: < redirects input from a file name, << starts a here document, and
<<< redirects input from another command.
Task 5:
Pipes (|) let you use the output of a command as the input to another
command. In many situations (but not all), | and <<< are kind of a reverse
of one another. For example, the output of...
Try to predict the output of the following command string before you run it
(see Answer 1 below):
Task 6:
cd ~
rm -r lab13
Answer 1:
Notes:
grep searches for matching patterns in a string, while cut splits the input
into pieces. Both are very common tools that you will use more in
subsequent labs.
Lab 26: Redirection and File Descriptors
Lab Objective:
Learn how to redirect input and output in Bash.
Lab Purpose:
Bash has a commonly-used feature, known as I/O redirection, that makes
life easier when using Linux. In this lab, you will learn how to make use of
this powerful feature.
Lab Tool:
Kali Linux (latest version)
Lab Topology:
A single Kali Linux machine or virtual machine.
Lab Walkthrough:
Task 1:
Open the Terminal application and run:
You just redirected the output from your echo command into the hello file.
The > is a shortcut; the proper version of this would be 1>, where 1 is a file
descriptor that references the standard output.
Task 2:
Now run:
Task 3:
Sometimes, you want to redirect both output and error to the same place.
In the past, you would have to do something like this:
Task 4:
We’ve talked about redirecting output, but what about input? To learn
about that, run the following commands:
In short: < redirects input from a file name, << starts a here document, and
<<< redirects input from another command.
Task 5:
You can also create your own file descriptors. Observe:
What this is doing is opening file descriptor 3 (for both reading and writing)
with the file foo and sending output to that. The fourth line then closes the
file descriptor, causing the last echo command to fail.
Task 6:
Finally, clean up:
1. cd ~
2. rm -r lab46
Notes:
To open a file descriptor for reading only, you could use exec 3< file, or for
writing only, exec 3> file.
Lab Objective:
Learn how to open, close, and navigate the vi editor.
Lab Purpose:
In this lab, you will learn about one of the classic (but often opaque to new
users) Linux text editors, vi.
Lab Tool:
Kali Linux (latest version)
Lab Topology:
A single Kali Linux machine or virtual machine.
Lab Walkthrough:
Task 1:
Open the Terminal and run:
1. vi /etc/passwd
Assuming you’ve not run this as root, vi should tell you at the bottom that
the file is read-only. That’s fine, since you won’t be making any changes
right now. Instead, explore just navigating vi:
● Use the h, j, k, and l keys, or the arrow keys, to navigate the cursor
between characters and lines.
● Enter /username, or ?username, to search forward and backward,
respectively, for your username. Use n or N to hop to the next or
previous match, respectively.
● Enter 10G to hop to line 10. Then just enter G to hop to the bottom of
the file.
● Finally, type :q to quit. Or if you’ve somehow accidentally made
changes, type :q! to force quit without saving
Notes:
The EDITOR environment variable defines which editor is used by
programs that ask for one, such as sudoedit. By default this may be set to
nano. If you’re comfortable enough with vi, you may want to change this
variable.
Lab Objective:
Learn how to configure locale settings.
Lab Purpose:
In this lab, you will learn how locales work in Linux and how to configure
their settings and environment variables.
Lab Tool:
Kali Linux (latest version)
Lab Topology:
A single Kali Linux machine or virtual machine.
Lab Walkthrough:
Task 1:
Open the Terminal and run:
1. locale
You should see a number of variables, the first of which being LANG — as
you might guess, this is the locale setting for your default language.
Several other variables are listed below it, naming the settings for
dates/times, phone numbers, currency, and other designations.
To see the locale settings currently supported by your system:
1. locale -a
Your default locale settings are probably some variation of UTF-8, which is
a standard character map on Linux.
Task 2:
If you’re feeling daring (this is not recommended), you can use
update-locale to change your settings to a radically different language
and/or character map. For example:
1. sudo update-locale LANG=<setting>
Notes:
You can use iconv to convert text between character encodings.
Lab Objective:
In this lab, you will learn about signals, including but not limited to kill, and
how to send them to processes.
Lab Tool:
Lab Topology:
Lab Walkthrough:
Task 1:
Sometimes, in Linux, things are not quite as they seem. This sequence of
commands will demonstrate that
echo "Mobs"
echo "Mobs"
What is happening here? Contrary to its name, the kill command doesn’t
necessarily kill processes. Instead, it sends them a signal, which may or
may not be SIGKILL, the signal that immediately terminates a process. In
fact, by default, kill doesn’t even send SIGKILL—it sends SIGTERM
(terminate gracefully), which is basically a computer’s way of saying
“please wrap up everything that you’re doing… or else I’ll have to send
SIGKILL.”
In this sequence, you first sent signal 19, which is SIGSTOP (stop),
followed by signal 18, which is SIGCONT (continue). Given the output of
echo "Mobs", this should now make more sense.
You can see a list of all signals with:
kill -L
Task 2:
Now create a few sleep processes if you haven’t already, and use either
killall or pkill to terminate them all with a single command. Both commands
have the same general function, with slightly different arguments, so it’s
worth experimenting with and reading the man pages for both.
sleep 60 &
sleep 60 &
sleep 60 &
pkill sleep
or:
killall sleep
Notes:
pkill and pgrep have exactly the same searching/matching semantics. This
means you can use pgrep as a “dry run” to find the processes you want to
signal before actually doing so.
Lab Objective:
In this lab you will use chattr to set and unset the immutability property, and
understand what it means.
Lab Tool:
Lab Topology:
Lab Walkthrough:
Task 1:
Now modify it
Hmm… did that not work? That’s funny… can you delete it?
rm lab82.txt
sudo rm lab82.txt
Obviously, if you noted what the word “immutable” actually means, you
understand what’s going on here. You could use lsattr >file@ to check
whether a file has that flag—if so, the fifth field will be marked with i.
Task 2:
mkdir lab82
touch lab82/foo
touch lab82/bar
rm lab82/foo
rm -rf lab82
lsattr -d lab82
Immutability on directories works exactly as you would expect it to, with one
interesting exception. It doesn’t prevent the directory from acting as a
mount point! This means you can mark the mount point for an external
drive as immutable, which will prevent files from being written to it when
that drive is not mounted.
Task 3:
Finally, clean up
rm -rf lab82*
Notes:
Lab Objective:
Learn what hardware goes into building a computer and how to interface
with some hardware from Linux.
Lab Purpose:
● Motherboard
● Processor(s)
● Memory
● Power suppl(y/ies)
● Hard/solid-state disks
● Optical drives
● Peripherals
Lab Tool:
Lab Topology:
Lab Walkthrough:
Task 1:
Open the Terminal and run the following commands to review some of the
hardware (real or virtualized) which is powering your Linux computer
lscpu
lspci
lsusb -t
sudo lshw
Task 2:
Now investigate some related low-level resources, like partitions, drivers
(kernel modules), and resource usage
sudo fdisk -l
lsmod
df -h
free -m
Notes:
If you want hardware information that you don’t know how to find, a good
way to start is by exploring the /proc filesystem. Most of the tools listed
above simply gather and format information from /proc — that is where the
kernel presents it.
Lab Objective:
Learn how to manage and read data from journald, the Systemd logger.
Lab Purpose:
In this lab, you will get to know journald, the Systemd logging system that
is gradually replacing classic syslog variants in most Linux distros.
Lab Tool:
Kali Linux (latest version)
Lab Topology:
A single Kali Linux machine or virtual machine.
Lab Walkthrough:
Task 1:
Open two terminal windows/tabs.
In the first one, run:
journalctl -f
Now go back to the first tab. Did your friendly message show up in the
system logs? Hit Ctrl+C to exit.
systemd-cat is a convenient tool, like logger, that can send output directly
to the journald logs.
Task 2:
Now look at the configuration:
cat /etc/systemd/journald.conf
Use the two tabs from Task 1, or open a second tab if necessary. In the first
tab, run:
bash
tty
ForwardToConsole=yes
TTYPath=[tty]
Replace [tty] with the value printed by the tty command in the other tab.
Save and quit the editor, then run:
bash
Now look back at the first tab again. You should see logs being printed
directly to your console! This can be useful for monitoring system logs
generally, without having to keep a process running.
Task 3:
Clean up the changes made during this lab:
1. Edit /etc/systemd/journald.conf again and delete the two lines you
added.
2. Run the following command to restart the journald service:
bash
Lab Objective:
Learn how to monitor the I/O performance of your storage devices.
Lab Purpose:
In this lab, you will use ioping and iostat to monitor disk I/O performance
on your Kali Linux machine.
Lab Tool:
Kali Linux (latest version)
Lab Topology:
A single Kali Linux machine or virtual machine.
Lab Walkthrough:
Task 1:
First, install a new performance monitoring tool:
Compared with its cousin ping, ioping measures the latency of disk I/O
rather than the latency of a network connection. Run a few commands to
compare the output. Each of these commands will run for ten seconds:
ioping -w 10 -A ./lab71
ioping -w 10 -C ./lab71
ioping -w 10 -L ./lab71
ioping -w 10 -W ./lab71
If you read the man page or run ioping -h, you will discover the meaning of
each of those flags:
Carefully compare the results of each test. Given what you know about disk
operations under the hood, consider why the results might differ
significantly.
rmdir lab71
Task 2:
Now run the following command to get an overview of your disk
performance:
iostat -dh
Depending on your machine, the output may show a long list of loopback
devices (the lines beginning with “loop”). However, right now you are only
interested in your main disk devices, which may include “sda,” “sdb,” or
similar. The output will show five columns indicating historical statistics of
the indicated device: transfers per second, data written/read per second,
and total data written/read.
iostat -dh -x
Make sure to read the man page to learn what all the abbreviations stand
for!
Notes:
Both ioping and iostat have modes for continually printing reports, allowing
you to monitor their output while performing another task.
iostat -dh 5
Lab Objective:
Learn how to monitor memory usage on a Kali Linux system.
Lab Purpose:
In this lab, you will explore monitoring memory usage and the OOM killer,
and cause a bit of mayhem yourself.
Lab Tool:
Kali Linux (latest version)
Lab Topology:
A single Kali Linux machine or virtual machine.
Lab Walkthrough:
Task 1:
Open the Terminal application with two tabs or windows.
In the first tab, run the following command to monitor memory usage
continuously:
Switch back to the first tab while that little one-liner causes all sorts of
problems (as you will soon see). Observe your system’s memory usage
and, perhaps, swap usage climbing. Now go back to the second tab, review
what you typed, and see if you can understand why your system is
consuming memory at such a rapid rate.
After several seconds, the second tab should crash due to a failure to find
enough memory for its very hungry process.
Task 2:
Now, use Ctrl+C to stop the free command. Instead, run the following
command to search for OOM (Out of Memory) killer messages in the kernel
logs:
Ideally, this command should print nothing (though if it did, that’s fine, too).
What you’re looking for here are messages from the kernel’s OOM killer.
You probably won’t find any from the process you just ran, because that
one was short-lived and essentially self-limiting—once the shell could no
longer allocate memory, it terminated that process on its own.
The OOM killer operates when the kernel itself can’t find enough memory
to perform its tasks. If and when it does run, you will see logs in
/var/log/kern*, among other locations.
Notes:
You can use vmstat to serve a similar purpose to free (though it presents
the information in a different format). Finally, you can view the
/proc/meminfo file for extensive details about your system’s memory usage:
cat /proc/meminfo
Here’s the adapted version of Lab 56: OpenVPN for Kali Linux. The
content has been modified to fit the context of using Kali while preserving
the essential objectives and tasks of the lab.
Lab Objective:
Learn how to configure a popular VPN client called OpenVPN.
Lab Purpose:
In this lab, you will configure a Linux OpenVPN client connection.
However, before you can do that, you need something for the client to
connect to.
Lab Tool:
Kali Linux (latest version), and resources for a second VM to be set up
during this lab.
Lab Topology:
Two Linux machines accessible via the same network.
Lab Walkthrough:
Task 1:
Before you can set up an OpenVPN client, you will first need a server for
that client to connect to. Complex VPN server configuration is beyond the
scope of this lab, but fortunately, there’s an easier way:
3. Launch the new VM and run through the setup process, following the
on-screen prompts. Most prompts are self-explanatory, but be sure to
select the “server” profile and correctly type the server’s IP address.
The subnets you choose don’t really matter, as long as they don’t
overlap with your local network. You may skip the TurnkeyLinux API
and the email notifications.
4. Now you have an OpenVPN server running! You can quit the setup
menu and log in via terminal, which you will use in the next task.
Task 2:
At the terminal prompt (as root) on your OpenVPN VM, run the following
command to create client information on the server:
On the client VM (running Kali Linux), run the following commands to install
OpenVPN and copy the configuration file:
IMPORTANT: If this step does not work, ensure that your virtual network is
configured correctly or that there are no connectivity issues on your local
network. By default, neither your lab VM nor the TurnkeyLinux VM should
have firewalls interfering with connectivity.
Task 3:
Now open and view the /etc/openvpn/lab56.conf file in your favorite text
editor. Make sure the first line contains the correct server IP address and
change it if necessary. The first few lines of this file should look something
like this:
After this are possibly a few other options plus your client’s private key,
public certificate, and server certificate(s). These are required for the client
and server to authenticate each other.
The key option here is that very first line, where you specify the remote
server and port. In various situations, you might also need to change the
proto or dev options, but for the most part, this client configuration is pretty
standard.
Task 4:
To start OpenVPN, run the following command:
You will see a lot of output, but if all goes well, the final line should include
"Initialization Sequence Completed."
Open another tab or terminal window to test your connection. First, run:
ip addr show
In this list, you should see a new tunnel device. The name will vary but
typically starts with "tun". On Kali Linux, it should be called "tun0". This tun0
device should have an IP address assigned to it by the OpenVPN server
via DHCP. Take this IP address and replace the last number with a
1—typically, this is the OpenVPN server’s private network IP. (But not
always. To confirm this, run ip addr show on the server itself.)
In any case, this is not the same IP that is in your client configuration. The
server and client are using their own new addresses as part of this Virtual
Private Network.
Once you’ve determined the server’s private IP, try connecting to it:
If you can connect to the OpenVPN server via its VPN address using these
commands, then you know your VPN is functioning correctly.
Task 5:
To close out, hit Ctrl+C on your client’s OpenVPN process to terminate it.
After that, you can remove the /etc/openvpn/lab56.conf file, uninstall
OpenVPN, and shut down the server if you no longer need it. Here are the
commands to assist with that cleanup:
sudo rm /etc/openvpn/lab56.conf
If you want to shut down the OpenVPN server as well, log in to the
OpenVPN VM and use the following command:
sudo poweroff
Notes:
Another common VPN protocol is IPsec. While IPsec can be more complex
to configure and understand, it is also worth learning. It is left as an
exercise for the reader to find (or create!) a “turnkey” IPsec server to test.
Lab Objective:
Learn how to configure package repositories (repos) for your system’s
package manager.
Lab Purpose:
In this lab, you will examine repo configurations and add a third-party repo
to expand the selection of packages available to you.
Lab Tool:
Kali Linux (latest version)
Lab Topology:
A single Kali Linux machine or virtual machine.
Lab Walkthrough:
Task 1:
Run the following command to open the /etc/apt/sources.list file:
This command will open the list of repositories currently configured for your
Kali system. By default, many repos might be commented out. Uncomment
the following line to enable the Kali "contrib" repository, which provides
access to additional packages:
Save and quit the editor, and then run the following command to update
your package list:
Task 2:
The Kali contrib repository contains a variety of tools that are not provided
directly by the main distribution but may be useful for your tasks. For
example, to check a package from this repository, run:
Task 3:
Now you will add a non-existing repository to illustrate how Apt can fail.
First, open your sources list again:
Next, run:
The first error message should inform you that the fake repository doesn’t
have a Release file. This is not a mistake that any actual maintainer would
make, so just work around it for now.
In the last line (the one you just added), immediately after deb, add:
[allow-insecure=yes]
So it reads:
Now, run:
The Release file error will be converted to a warning, and Apt might
complain that it cannot find the necessary index files, indicating that the
repository isn’t functional.
Task 4:
For cleanup, open the sources list for editing again:
sudo apt edit-sources
Delete the last line you added for the fake repository. You may also want to
comment out the Kali contrib line (unless you want to keep it) by adding a #
at the beginning of the line. Then, save and quit. Finally, run:
Notes:
Lab Objective:
Learn how to configure swap space.
Lab Purpose:
Swap space is disk space used by the operating system when RAM is
running low. In this lab, you will configure a swap file.
Lab Tool:
Kali Linux (latest version)
Lab Topology:
A single Linux machine or virtual machine.
Lab Walkthrough:
First, open the Terminal and run the command free -h. Pay attention to the
bottom line, labeled “Swap.” Check if you currently have a swap partition,
and make note of the available swap space as you’ll check it again later.
Next, create and activate a 1GB swap file by running the following
commands sequentially:
mkswap ./lab75.img
You may see some permission warnings; these can be safely ignored in
this lab environment. After activating the swap file, check again with free -h,
and you should see that your available swap space has increased by 1GB.
Finally, to remove the insecure swap file you created, undo your previous
steps by running:
rm lab75.img
Notes:
Ideally, a healthy system rarely or never uses its swap space. Some Linux
administrators today prefer not to set it up at all, but it is always nice to
have some amount of swap space as a failsafe.
Lab Objective:
Lab Purpose:
In this lab, you will learn about two tools that can be used to test system
RAM.
Lab Tool:
Lab Topology:
Lab Walkthrough:
Task 1:
Install memtester
This is a tool which can test memory while your operating system is
running. First, use free -m to figure out how much memory your system
has. Unless you suspect actual problems, you should be conservative here
and test no more than 50% of your RAM. Pass this to memtester as a
number of MB, followed by a number of iterations. For example, if you want
to run a single test of 1024MB, run:
This will take some time, but in the end you will be presented with a
(hopefully clean) report.
Task 2:
Now reboot your system to the GRUB menu and select memtest86+. This
is a Linux package, installed with Kali by default, but run through GRUB. It
works similarly to memtester, running a variety of tests over a number of
iterations. Because it cannot have the OS interfering with its operations, it
is arguably more accurate.
Notes:
Genuine memory problems are hard to diagnose except by trial and error.
This is because problems with other hardware, such as CPU, PSU, or
motherboard, can manifest as memory errors in some tests.
Lab 39: Environment Variables, Types, and History
Lab Objective:
Learn about Bash environment variables, types, and how to use the
shell history.
Lab Purpose:
The Bash command shell is pre-installed on millions of Linux
computers around the world. Understanding how this shell works is
a critical skill for working with Linux.
Lab Tool:
Kali Linux (or another distro of your choice)
Lab Topology:
A single Linux machine, or virtual machine
Lab Walkthrough:
Task 1:
Open the Terminal application, then enter
echo $PATH
The PATH environment variable lists all locations that Bash will
search when you enter a command with a relative path. A relative
path example is bash, compared to /bin/bash, which is an absolute
path. There are other environment variables as well. You can view all
of them, and their values, using the env command:
env
Task 2:
You can add or modify an environment variable with export. For
example
export PATH=$PATH:./
In most cases, this change will disappear when you exit Bash, but the
advantage of export is that child processes will now be able to see
the new or modified variable.
For example
foo=123
export bar=456
bash
echo $foo $bar
This prints 456, because only bar is seen by the child shell.
Task 3:
Another useful Bash command is called type. Use type to figure out
information on other commands or functions
type -a date
type -a if
type -a echo
type -a ls
type will tell you if a command or shell function is a binary file (like
/bin/date), a shell built-in (like help), an alias (which you can view
with alias), or a shell keyword (like if or while).
Task 4:
Enter history to see a history of commands you have typed into
Bash.
To repeat a command, simply enter ! and then the appropriate
number. For example
!12
will execute command number 12 in the history list.
If you accidentally saved a password or other sensitive information to
the history, you may use, for example
history -d 47
to delete command number 47 from the list, or even
history -c
to clear the history altogether.
If you want to save your current shell’s history to another file, use
history -w filename
The default filename Bash saves its history to is .bash_history.
However, by default it only saves at the end of a session. If your
session crashes, or you open multiple sessions, etc., then your shell
history could become incomplete or out of order.
Notes:
If you wish to permanently modify an environment variable or other
shell settings, look into the .bashrc and .bash_profile files.
Lab Objective:
Learn how to automatically mount Linux filesystems.
Lab Purpose:
In this lab, you will learn how to automatically mount a filesystem on a Kali
Linux system at boot by using the /etc/fstab file.
Lab Tool:
Kali Linux (latest version).
Lab Topology:
A single Linux machine or virtual machine.
Lab Walkthrough:
First, you will need another filesystem to mount. This can be an external
disk or a loopback block device that you create for this purpose (refer to
Lab 11 for details). Identify the label or UUID of this device by running sudo
lsblk -f. Once you have the UUID, open /etc/fstab with your preferred text
editor. You will add a line for the new device in /etc/fstab. The details will
vary based on the device, but here is a template for how the line should
look:
(Replace the UUID and mount point with the proper values for your device.)
For example, let's say you find that the UUID for your external drive is
2018-08-14-11-58-42-18. Your line in /etc/fstab might look like this:
After editing the file, save it and close the editor. To ensure the changes
take effect, reboot your machine and then check the mounted filesystems
by running the mount command. If you configured everything correctly, you
should see that your device is mounted at the designated mount point.
Notes:
Lab Objective:
Learn how to manage environment variables in Linux, understand the types
of environment variables, and utilize the command line history features to
improve efficiency in Kali Linux.
Lab Purpose:
In this lab, you will explore environment variables in Linux, including how to
view, set, and manage them. You will also learn how to use the history
command to improve your workflow in the terminal.
Lab Tool:
Kali Linux (latest version)
Lab Topology:
A single Kali Linux machine, or virtual machine.
Lab Walkthrough:
Notes:
✔ Environment variables are crucial for configuring the shell
environment and managing system behavior.
✔ Command history can save time by allowing you to re-run previous
commands without retyping them. It's a powerful tool for productivity.
✔ Remember that security concerns can arise when sensitive
commands or information are saved in history, so it's important to know
how to manage and clear your command history.
Lab Objective:
Learn how to create shell scripts by combining multiple commands, using
control structures like conditionals and loops, and implementing basic
shell scripting principles to automate tasks in Kali Linux.
Lab Purpose:
In this lab, you will learn the fundamentals of shell scripting. You will
convert a series of commands into an executable shell script, apply basic
scripting concepts like conditionals and loops, and create scripts that can
automate tasks in Kali Linux.
Lab Tool:
Kali Linux (latest version)
Lab Topology:
A single Kali Linux machine, or virtual machine.
Lab Walkthrough:
Task 1: Writing a Basic Shell Script
1. Create a New Script File: Open your terminal and create a new
script file using nano (or your preferred text editor):
nano myscript.sh
2. Add the Shebang: The first line of any shell script should be the
shebang (#!/bin/bash), which tells the system to use the Bash shell to
execute the script. Add this to your script:
#!/bin/bash
3. Add Some Simple Commands: Below the shebang, add a couple of
simple commands to the script. For example, use echo to print messages
to the terminal:
#!/bin/bash
echo "Welcome to my shell script!"
echo "Today is: $(date)"
4. Save and Exit: After adding the commands, save the file and exit the
editor (in nano, press CTRL + X, then Y, and press Enter).
Question: What does the $(date) command do in the script? Why is it
useful to include the current date in a script?
count=1
for file in $(ls -1); do
echo "$count. $file"
((count++))
if [ $count -gt 5 ]; then
break
fi
done
2. Save and Run: Save the script and run it to see the first 5 files listed.
Question: How does the for loop work in this script, and what does the
break statement do?
Task 6: Using Functions in Shell Scripts
1. Adding a Function: Modify the script to include a simple function.
For example, create a function that displays system information:
#!/bin/bash
echo "The file directory_listing.txt has been created with the listing."
2. Save and Run: Save the script and run it. Check the contents of the
directory_listing.txt file:
at directory_listing.txt
Question: How does output redirection (>) work in a shell script, and how
can it be used to log command outputs to a file?
Notes:
✔ Shell scripts are powerful tools for automating tasks and managing
system configurations. By combining commands, variables,
conditionals, loops, and functions, you can create flexible and reusable
scripts.
✔ Cron jobs can be used to run scripts at scheduled times, which is
useful for automating system maintenance or periodic tasks.
Lab Objective:
Understand the key factors that influence the choice of an operating system
(OS) for a specific task or environment, and learn how to evaluate different
operating systems based on needs, requirements, and compatibility.
Lab Purpose:
In this lab, you will explore the key aspects of choosing an appropriate
operating system for your needs. You will learn how to compare various
operating systems, taking into account factors like security, hardware
compatibility, software availability, and user requirements.
Lab Tool:
Kali Linux (latest version), Virtual Machines (if necessary), and other OSes
(Windows, macOS, Ubuntu, etc.) for comparison.
Lab Topology:
This lab can be done on a single Kali Linux machine or in a virtual machine
environment, where different operating systems can be installed and
compared.
Lab Walkthrough:
Task 1: Identify Your Use Case
1. Define Your Purpose: Before selecting an operating system, it’s
essential to define the purpose of the system. Ask yourself:
✔ Will the system be used for general-purpose computing, security
testing, gaming, or software development?
✔ Are there specific hardware requirements, such as GPU or
multi-core CPU usage?
✔ What level of security do you need (e.g., secure OS for penetration
testing, high-privacy system for sensitive tasks)?
Write down your system's intended use case. For example:
✔ Penetration testing: Kali Linux, Parrot OS, or Ubuntu with security
tools.
✔ Software development: Ubuntu, Fedora, or macOS for ease of
development.
✔ General use or gaming: Windows 10 or 11, macOS for Apple
hardware.
Question: What is the main function of the machine you are selecting an
OS for? Does your choice of OS align with this purpose?
Notes:
✔ The choice of an operating system should be based on a balance of
factors such as security, hardware compatibility, software needs, user
interface preferences, and cost.
✔ Testing and comparing different operating systems is a great way to
determine which one works best for you and your specific tasks.
✔ Consider using virtualization tools (like VirtualBox or VMware) to test
various operating systems before committing to one for production.
Lab 44 – Basic Security and Identifying User Types
Lab Objective:
Learn the basics of security on a Linux system, including understanding
different user types, their privileges, and how to manage users and groups
to ensure a secure environment.
Lab Purpose:
In this lab, you will explore user management in Linux, focusing on
identifying user types (such as root, regular users, and system users),
understanding user privileges, and learning how to apply security
principles to user management.
Lab Tool:
Kali Linux (latest version) or any Linux distribution
Lab Topology:
A single Kali Linux machine or virtual machine, with administrative access
(root or sudo privileges).
Lab Walkthrough:
Notes:
✔ User management is an essential aspect of Linux system security.
Properly managing user accounts and groups can limit access to
sensitive files and commands, reducing the risk of unauthorized system
modifications.
✔ Sudo is an important security tool, as it helps minimize the risks
associated with using the root account directly.
✔ Regularly review user privileges and account status to ensure that only
authorized users have access to critical system functions.
Lab Objective:
Learn about the special directories and files in a Linux system, understand
their purpose, and explore how they are used in system management and
troubleshooting.
Lab Purpose:
In this lab, you will explore the special directories and files in a Linux
system, understand their unique functions, and learn how to interact with
them. Special directories such as /etc, /proc, /dev, and /sys hold
configuration files, system information, and device files critical for system
management and troubleshooting.
Lab Tool:
Kali Linux (latest version) or any Linux distribution
Lab Topology:
A single Kali Linux machine or virtual machine with root (administrative)
access to view and interact with special directories and files.
Lab Walkthrough:
Notes:
✔ Special directories like /etc, /proc, /dev, and /sys are critical to the
operation of a Linux system. They store important configuration files,
system information, and device interfaces, which are essential for
system management, troubleshooting, and performance monitoring.
✔ Familiarity with these directories and files will make you more efficient in
managing Linux systems and diagnosing problems.
Lab Purpose:
In this lab, you will learn how to determine which PCI devices and
peripherals are installed on a Linux system, how to view their settings, and
how to configure them to ensure proper functioning of the system. You will
also explore tools and commands that help you gather detailed
information about hardware components.
Lab Tool:
Kali Linux (latest version) or any Linux distribution with root access.
Lab Topology:
A single Kali Linux machine or virtual machine with physical or virtual
hardware components that you can examine and configure.
Lab Walkthrough:
Notes:
✔ Understanding PCI devices and peripherals is essential for diagnosing
hardware issues and optimizing system performance.
✔ Linux provides powerful tools like lspci, dmesg, lsusb, and lshw to
interact with hardware, view device status, and configure settings.
✔ Be cautious when manually loading or unloading drivers, as it can affect
the system’s stability if done improperly.
Lab Purpose:
In this lab, you will explore the concept of runlevels and boot targets in
Linux. You will learn to change system runlevels or boot targets to manage
system startup, shutdown, and various operating modes (multi-user,
graphical, etc.). You will also practice safely shutting down or rebooting
the system.
Lab Tool:
Kali Linux (latest version) or any Linux distribution that uses systemd for
managing services and boot targets.
Lab Topology:
A single Kali Linux machine or virtual machine with root (administrative)
access. Ensure you have a terminal or access to the system via SSH to
execute the commands.
Lab Walkthrough:
Notes:
✔ SysV init is deprecated in many modern Linux distributions in favor of
systemd, which offers more flexibility and control over the boot process
and system services.
✔ Runlevels are still used in legacy systems, but most current
distributions (including Kali Linux) use boot targets to define the
system’s state.
✔ Changing run-levels or boot targets
Lab Objective:
Learn how to manage software packages on a Debian-based system using
the apt package management tool. This includes installing, updating,
upgrading, and removing packages.
Lab Purpose:
In this lab, you will practice using APT (Advanced Package Tool), the
package management system for Debian and its derivatives. You will gain
familiarity with basic package management commands, how to search for
packages, and how to manage package dependencies.
Lab Tool:
Kali Linux (latest version) or any Debian-based Linux distribution (Ubuntu,
Linux Mint, etc.).
Lab Topology:
A single Kali Linux machine or virtual machine with internet access.
Lab Walkthrough:
Notes:
✔ APT (Advanced Package Tool) is one of the most commonly used
package management tools on Debian-based distributions. It simplifies
the installation, removal, and management of software packages.
✔ While apt handles both package installation and removal, it's crucial to
use the update command regularly to ensure your system is using the
latest package lists.
✔ Always review package upgrades and removals carefully, especially on
production systems, to avoid inadvertently breaking critical software or
services.
✔ The apt tool handles dependencies automatically, which simplifies
package management significantly, but you should still be cautious
when upgrading critical components.
Lab Objective:
Learn how to set up a Linux operating system as a guest in a virtualization
environment. This lab will cover the installation of Linux in a virtual
machine, configuring virtual hardware, and optimizing performance for
virtualized environments.
Lab Purpose:
In this lab, you will gain practical experience in setting up and managing a
Linux guest operating system (OS) within a virtualized environment, such
as VMware, VirtualBox, or KVM. You will learn how to install a Linux
distribution as a guest OS and optimize its settings for virtualized
environments, improving performance and resource management.
Lab Tool:
Linux Distribution: Any modern Linux distribution (e.g., Kali Linux,
Ubuntu).
Virtualization Software: VMware Workstation, Oracle VirtualBox, or
KVM (Kernel-based Virtual Machine).
Virtual Machine (VM) Host: A physical machine running virtualization
software with sufficient resources (CPU, RAM, disk space).
Guest Additions/Tools: Install any additional tools provided by the
virtualization software for better performance (e.g., VirtualBox Guest
Additions or VMware Tools).
Lab Topology:
Host Machine: A physical machine running virtualization software
(e.g., VMware Workstation or VirtualBox).
Guest Machine: A Linux distribution (e.g., Kali Linux) running as a
virtual machine within the host system.
Lab Walkthrough:
Notes:
✔ Running Linux as a guest in a virtualized environment allows for
easy testing, development, and experimentation without impacting
the host system.
✔ Always allocate enough resources to the guest OS to ensure it
operates smoothly and efficiently.
✔ Installing Guest Additions or VMware Tools can significantly
improve the integration between the host and guest system,
providing better performance and additional features (e.g., shared
clipboard, seamless mouse integration).
✔ Virtualization tools also allow you to take snapshots, making it easier
to return to a previous state in case something goes wrong during
your experimentation.
Lab Objective:
Learn how to work with environment variables, understand their types, and
utilize command history on Linux. This lab will help you manage user
environment settings, control the shell environment, and retrieve and
reuse commands from the command history.
Lab Purpose:
In this lab, you will practice working with environment variables, which
define key settings that affect the behavior of processes in your system.
You will also explore shell history, which allows you to retrieve previously
run commands for convenience and efficiency.
Lab Tool:
Kali Linux (or any Linux distribution)
Terminal (Bash or another shell)
Lab Topology:
Linux System: A single system or virtual machine running a Linux
distribution (e.g., Kali Linux, Ubuntu).
Shell: The Bash shell or any other command-line shell available.
Lab Walkthrough:
Notes:
✔ Environment Variables are critical for configuring your system and
application environments. They control various aspects of the shell and
system behavior.
✔ Command History is a powerful tool for efficiency, allowing you to
quickly reuse and search past commands.
✔ Remember to manage your history and environment variables securely,
especially if your system is shared with others or used in production
environments.
✔ Always set environment variables in appropriate files to ensure they
persist and are available to your processes.
Advanced Labs
Lab 84. – Manage User and Group Accounts and Related System
Files: Special Purpose Accounts
Lab Objective:
Learn how to set up and manage disk space using LVM—a flexible way to
manage storage.
Lab Purpose:
Tools:
● Kali Linux
● lvm2 package (pre-installed or can be installed via sudo apt install
lvm2)
Topology:
Explanations:
Details:
● pvcreate converts loop devices into physical volumes (the base units
for LVM).
● pvdisplay shows details such as size and device name of created
PVs.
Task 3: Create a Volume Group
sudo vgdisplay
Details:
sudo lvdisplay
Details:
rm block.img block2.img
Explanation:
Lab Objective:
Learn about best practices for system auditing and how to implement them.
Lab Purpose:
You will use a tool called Lynis to scan your system for potential issues
related to auditing configurations and apply simple fixes.
Tools:
Topology:
ENABLED="false"
to:
ENABLED="true"
You may find Lynis now raises warnings about the audit daemon.
Lynis might warn that your audit daemon is enabled but with an empty
ruleset. To address this:
-w /var/log/audit -k auditlog
This tells auditd to monitor the /var/log/audit directory and to label this rule
with “auditlog”.
Final Scan
Notes:
● Results from Lynis may vary; some warnings are informational, others
important.
● Feel free to implement recommendations to improve system security
and auditing.
Lab Objective:
Learn how to monitor disk space and inode usage to manage storage
effectively.
Lab Purpose:
Use common Linux tools to check available space and inodes on your
disks and directories.
Tools:
Topology:
Explanation:
You will see used and available space on your main partition(s).
df -hi /dev/sd*
Explanation:
Typically, inode usage is lower than disk space usage, but monitoring both
helps prevent filesystem issues.
du -h a
Explanation:
Explanation:
● It lists all items inside a and sorts them from smallest to largest.
du -h --inodes a | sort -h
Note:
du -hs a
du -hs --inodes a
Notes:
Lab Objective:
Learn how to gather information about your CPU(s) and explore some
kernel parameters related to CPU and system performance.
Lab Purpose:
Use various tools to inspect CPU hardware details and view or modify
kernel settings affecting CPU behavior.
lscpu
Explanation:
Displays detailed CPU architecture information in a user-friendly format,
including number of cores, model name, CPU MHz, flags, etc.
cat /proc/cpuinfo
Explanation:
Shows detailed CPU info, including vendor ID, model, flags, bugs
(Spectre, Meltdown), and more. It’s more verbose and raw but useful for
detailed hardware insights.
Task 2: View Kernel CPU Parameters
Run:
Explanation:
Shows all kernel parameters (sysctl -a) related to CPU (case-insensitive).
The output includes many settings; focus on those relevant for tuning.
sudo sysctl -a
But be cautious: This outputs many parameters (over 900+), some of which
require root privileges or may contain sensitive info.
cat /etc/sysctl.conf
and:
ls /etc/sysctl.d/
sudo sysctl -p
Notes:
Lab Objective:
Learn how to configure and manage software RAID arrays using mdadm.
Lab Purpose:
Tools:
● Kali Linux
Topology:
Next, prepare two virtual disks (loopback files) for RAID setup:
Note:
The output will identify devices like /dev/loop18 and /dev/loop19.
Remember these device names as they will be used in subsequent
commands as >dev1@ and >dev2@.
cat /proc/mdstat
This file shows arrays and their status, along with the disks involved.
mkdir lab84
Replace /dev/loopY with your second loop device — drop the /dev/ and use
just loopX or loopY.
cat /proc/mdstat
The first command fills a file with random data to simulate activity. The -a
command re-adds the disk, triggering a rebuild. The --detail shows the
rebuild status.
Task 5: Clean Up
Unmount and stop the array, detach loop devices, and delete files:
rm disk1.img disk2.img
Notes:
Lab Objective:
Learn how to apply software patches and keep your system up-to-date.
Lab Purpose:
Practice applying system updates and other patches to ensure your system
remains secure and current.
Tools:
● Kali linux
Topology:
● Single Linux machine or virtual machine
Explanation:
This command performs a full upgrade, installing new packages, removing
obsolete ones, and updating existing packages to their latest versions. It
may take some time depending on how many updates are available.
/etc/apt/apt.conf.d/50unattended-upgrades
Note:
By default, this configuration typically only applies security updates, which
is usually what you want for security reasons.
Notes:
Lab Objective:
Learn about best practices for user authentication and how to improve
security in this area.
Lab Purpose:
Use the Lynis security auditing tool to identify and fix weaknesses in user
authentication configurations.
Tools:
● Kali Linux
Topology:
Note:
The output will include various warnings and suggestions. Focus on
security weak points under those sections. The review will steer you toward
the following suggested improvements.
Next, open /etc/login.defs in your favorite editor (with root privileges), for
example:
●
●
●
Question:
Did you get a perfect score? Great! But remember, in a real-world
scenario, such changes affect user policies. For example:
Notes:
● Your scan results may show variations in warnings and suggestions.
● Feel free to implement or revert recommendations based on your
environment.
● Always test configuration changes in a lab environment before
applying them to production servers.
Certainly! Here's Lab 58: Archiving and Unarchiving, with the commands
in plain text and the necessary explanations, formatted for Kali Linux or any
Linux distro.
Lab Objective:
Learn how to create, extract, and examine various archive files and
compression formats.
Lab Purpose:
Tools:
Topology:
mkdir lab58
cd lab58
touch f1 f2 f3 f4 f5 f6 f7 f8 f9
Run:
gzip f*
ls
Explanation:
This compresses each of the nine files individually into f1.gz, f2.gz, ...,
f9.gz.
Note:
gzip is a compression format, not an archiving tool; original files are
replaced by compressed versions.
rm f*
touch f1 f2 f3 f4 f5 f6 f7 f8 f9
Create a tar archive containing these files:
Note:
This creates an archive named files.tar.gz (note: not compressed yet).
Question:
What do you see? You should see the list of files inside.
Explanation:
(Note: this command is a general idea; for actual cpio creation, the steps
are:)
Create an archive:
rm f1
rm f*
dd if=f1 of=f1.bak
Note:
dd works at the block level, similar to copying entire disks or partitions.
dd if=/dev/sda1 of=/dev/sdb1
Task 7: Clean Up
cd ..
rm -r lab58
Notes:
gzip filename
gunzip filename.gz
bzip2 filename
bunzip2 filename.bz2
xz filename
unxz filename.xz
Lab Objective:
Use what you already know to write a simple shell script, from scratch.
Lab Purpose:
Kali linux
Lab Topology:
Lab Walkthrough:
Task 1:
Open the Terminal application, and run your favorite text editor, such as vi
or nano. (If you have never used vi or vim, then nano is strongly
recommended.)
You may wish to reference Lab 15 if you have not already done so. Your
goal is to write a script which accepts one argument—a number—and
prints out two numbers at a time such that:
Example:
./foo.sh 100
Output: 100 0
99 1
98 2
... and so on until 0 100
Answer 1:
● Create your script file, e.g., foo.sh
Notes:
In Lab 15, you read about the exit status. For error-checking purposes, can
you figure out how to use the exit status before your script has exited?
Don’t change formatting, but make this lab 59. Let the bash commands be
plain text, not inside a bash shell.
Lab Objective:
Use what you already know to write a simple shell script, from scratch.
Lab Purpose:
Lab Topology:
Lab Walkthrough:
Task 1:
Open the Terminal application and run your favorite text editor.
You may wish to reference Labs 66 and 67 if you have not already done so.
Your goal is to write a script which accepts three arguments — a directory
path, and two flags to be passed to test. This script should check every file
in the directory (non-recursively) and, if it passes both tests, prints that file’s
name.
Example:
./foo.sh a/mydir -f -w myfile
In this example, the script is looking for files with a/mydir that are regular
files with write permissions granted. myfile passes those tests.
All error conditions should print a friendly message and exit with status 1.
For example, if three arguments are not passed, or the passed directory
doesn’t exist, or one of the test arguments is not valid.
See Answer 1 below for one possible solution.
For an extra challenge, you might print all files, but sort them according to
how many tests they passed.
Answer 1:
#!/bin/bash
test $# -eq 3
if [ $? -ne 0 ]; then
echo "Exactly three arguments are required."
exit 1
fi
if ! [ -d "$1" ]; then
echo "Not a directory."
exit 1
fi
if [ -z "$files" ]; then
echo "I can't read that directory."
exit 1
fi
for f in $files; do
rc1=$?
rc2=$?
exit 1
fi
if [ $rc2 -gt 1 ]; then
exit 1
fi
echo "$f"
fi
done
Notes:
Lab Objective:
Lab Purpose:
In this lab, you will create a Git repo to serve as a basis from which to learn
other Git operations in Labs 62 and 63.
Lab Tool:
Lab Walkthrough:
Task 1:
mkdir myrepo
cd myrepo
git init
Task 2:
If you’ve never used Git on this system before, then you probably haven’t
added your name and e-mail address yet. This isn’t a website signup form,
but a configuration file which tells other collaborators who committed a
given piece of code. Run:
Edit the file with your name and e-mail, then save and quit.
You can also use git config -e to edit the local (repo-specific) configuration
file, which is located at .git/config, but you don’t need to worry about that
right now.
What you may want to do now is edit the .git/description file, which, as you
might guess, is a description of the repo.
Lab Objective:
Learn how to use basic day-to-day Git operations for version control.
Lab Purpose:
In this lab, you will practice working with commit and other operations for
managing code collaboration in Git.
Lab Tool:
Lab Topology:
Lab Walkthrough:
Task 1:
First, you will need a Git repo. If you don’t have one, you may reference
Lab 97, or find an interesting repo on the internet and use git clone to
retrieve it. This lab will assume you are using the repo from Lab 61.
Task 2:
Make sure your working directory is the repo’s directory, e.g., a/myrepo. At
this point, you have a repo, but should not have made any commits yet.
Run the following commands to fix that:
git log
To make further changes, follow the same workflow: edit any files that need
editing, and run git commit again.
git push
This pushes your most recent commits to a remote repo, which is often, but
not always, a central server from which the rest of your team can pick up
the changes.
git pull
Notes:
git show
to show exactly what changes were made by a given commit. The syntax
is:
where [hash] is the hash shown in git log. Or, alternatively, run git show to
show the most recent commit.
Lab Objective:
Learn how to work with branches in Git.
Lab Purpose:
In this lab, you will practice using branch and merge operations for
advanced code collaboration in Git.
Lab Tool:
Lab Topology:
Lab Walkthrough:
Task 1:
First, you will need a Git repo. If you don’t have one, you may reference
Lab 61, or find an interesting repo on the internet and use git clone to
retrieve it. This lab will assume you are using the repo from Lab 61.
Task 2:
The default code branch in Git is called master. Sometimes you want to
“branch off” and work on a large block of code without interfering with
master, maybe for the purposes of experimenting. Make sure your working
directory is the repo’s directory, then do that now with:
This is a shortcut for creating a branch and then checking it out at the same
time. You can confirm that you are now using the lab63 branch with:
git branch
Task 3:
Unfortunately, there’s been a problem. While you were playing around with
this lab, a critical security patch was applied to the master branch:
Task 4:
Now, you may notice, the two branches are out of sync. Each branch has a
commit that the other one doesn’t. That’s where git merge comes into play:
Using:
cat README
you can confirm that the patch from master was applied to lab63.
Finally, you can merge lab99 back into master and remove the branch:
One important case not covered here was merge conflicts, i.e., what
happens when two changes conflict within a merge. Typically, Git will warn
you and indicate the conflict within one or more files, which you can then
examine with:
git diff
and an editor.
Lab Objective:
Lab Purpose:
Lab Tool:
Lab Topology:
Lab Walkthrough:
Task 1:
Add your localhost to the Ansible hosts file, telling it that your local machine
is one of the devices (in this case, the only device) it should manage:
to confirm that Ansible can connect. The result should look something like:
Task 2:
To run a one-off shell command on all Ansible hosts, try something like:
This is a useful feature, but not nearly the most useful. Open your favorite
editor and create an Ansible playbook file called lab100.yml, with the
following content:
● hosts: all
tasks:
○ name: hello copy
copy:
src: hello.txt
dest: a/lab100.txt
Now run:
ansible-playbook lab100.yml
And the lab100.txt file will now exist in your specified location. Running the
same command again will show no changes; removing lab100.txt and
running it again will cause the file to be recreated. Modifying hello.txt and
running the playbook again will cause your changes to be applied.
Notes:
This is only one very small example usage of a complex and powerful tool.
Ansible is well worth understanding if you aspire to manage Linux
machines professionally.
Lab Objective:
Lab Purpose:
Lab Tool:
Lab Topology:
Lab Walkthrough:
Task 1:
First, install Puppet:
Unlike Ansible’s default setup (see Lab 100), Puppet uses a client-server
model with a “puppetmaster” server from which nodes pull their manifests.
Thus, in a production environment, you would set up this puppetmaster
server and install the Puppet client on each node you want to manage.
Some configuration:
This is a somewhat non-trivial process to get both the Puppet client and
server talking to each other on the same machine. In a typical installation,
you would follow mostly the same steps, by requesting a certificate from
the client and then signing it from the server.
Task 2:
node default {
file { '/tmp/lab101.txt':
content => 'Hello World!',
}
}
The lab101.txt file will now exist in /tmp. Running the same command again
will show no changes; removing lab101.txt and running it again will cause
the file to be recreated. Modifying the file and running it again will cause
your changes to be reverted.
Notes:
This is only one very small example usage of a complex and powerful tool.
Puppet is well worth understanding if you aspire to manage Linux machines
professionally.
Lab Objective:
Learn how to use temporary files and directories, symbolic links, and
special permissions.
Lab Purpose:
In this lab, you will work with symbolic links, special file/directory
permissions, and temporary files and directories.
Lab Tool:
Lab Topology:
A single Linux machine, or virtual machine
Lab Walkthrough:
Task 1:
ls -ld /tmp
drwxrwxrwt
The t at the end indicates what is called the sticky bit. This means that only
users/groups who own a given file may modify it. This is important on
world-writable directories, such as those holding temporary files, to prevent
users from messing with other users’ files.
Task 2:
Now run:
ls -l mytmp
rm mytmp
In addition to /tmp, there is also /var/tmp, which is typically used for larger
and/or longer-lasting temporary files. /tmp is usually cleaned on every
reboot—the same is not necessarily true for /var/tmp.
Lab Objective:
Lab Purpose:
In this lab, you will learn how to monitor a number of metrics for both
foreground and background processes.
Lab Tool:
Lab Topology:
Lab Walkthrough:
Task 1:
If you weren’t careful to terminate all of your sleep processes from Lab 48,
you might have a stray or two running. Let’s find out:
ps -ef
Well, that’s a lot of output! You could maybe filter it through a grep sleep or
use ps without arguments, but there’s a better way:
pgrep -a sleep
pgrep supports regex and has a number of matching options to make sure
you find the right process(es).
Task 2:
A sleep process isn’t going to use many system resources, but plenty of
other processes might. It’s important to know how to monitor those.
free -h
This gives you an output of system memory usage. The most generally
useful columns here are “total”, “used”, and “available”. The “available”
column offers an estimate of memory which is free for starting new
processes without swapping. That isn’t the same as “free” memory, which is
often low on Linux systems. This is because the OS can take advantage of
this memory for performance reasons, while still holding it as “available” for
user processes.
watch -n 10 free -h
top
It is strongly recommended to spend some time reading the top man page,
as this is one of the most featureful system monitoring tools that is installed
by default.
Notes:
uptime, despite the name, is another quick way to get system load.
However, top also shows this, as well as lots of other useful information.
Lab Objective:
Lab Purpose:
In this lab, you will learn about managing print queues and jobs using
CUPS and the LPD compatibility interface.
Lab Tool:
Lab Topology:
Lab Walkthrough:
Task 1:
Verify with:
lpstat -t
—you should see “device for PDF: cups-pdf /” as part of the output. Or, if
you plug in a real printer, it should be auto-detected. (If not, then it would be
easier to print to PDF for the purposes of this lab.)
You may see something like $HOME/PDF as the directory where your
“printed” files will end up. You can change this if you like. If you do, finalize
it with:
Task 2:
Locate the file in the directory you identified above (it may have an odd
name, like stdinBBBtuBPDF-MobB1.pdf), and open it in a PDF viewer or
web browser.
You should find a basic PDF file with your text printed in the top left corner.
If you didn’t change anything, this should be under PDF/ in your home
directory.
Task 3:
lpr -T gibberish
lpq
The previous command should tell you the Mob (printer) number (third
column) of the queued job. Then run:
lprm [number]
You canceled the job (if you do it quickly enough—there is a timeout), but it
will still show up as “completed” via:
lpstat -W completed
Notes:
lpadmin can be used to add and configure printers which are not
auto-detected. For example, you would add a cups-pdf printer manually
with:
Lab Objective:
Lab Purpose:
In this lab, you will learn how to get a running task’s priority, change its
priority, and set the priority of a task to be run.
Lab Tool:
Lab Topology:
Task 1:
ps -l
ps -l
pkill sleep
What you’ve done here is start a sleep process with a “niceness” value of
19. This is the most “nice” a process can be—in other words, the least
demanding in terms of priority. Then you changed its priority, with renice, to
the “meanest” possible value of -20, or the most demanding in terms of
priority. The default priority for all user processes is 0, and you must be root
to run a process with higher priority. ps -l will list your running processes
with their priorities.
Notes:
You can also use top to list and sort processes by their priority values.
Lab Objective:
Lab Purpose:
In this lab, you will learn how to troubleshoot a Linux host as a network
client, using various tools.
Lab Tool:
Lab Topology:
Lab Walkthrough:
Task 1:
You’ve worked with ip in previous labs to get network information, but it’s
worth reiterating. It is a powerful tool with a lot of uses. Run the following
commands now to get a feel for what kinds of information you can gather
from it:
ip address
ip maddress
ip route
ip netconf
Task 2:
iftop is a tool to monitor bandwidth usage, while iperf is a tool to test how
much bandwidth you have (and, in the process, fills up enough for iftop to
measure). Start:
sudo iftop
in its own terminal tab/window and leave that running for now.
iperf requires a separate client and server to get any meaningful results.
Fortunately, a number of public servers exist — visit https://iperf.cc to
choose one near you, then run:
While you’re waiting, switch to the other tab to see what kind of bandwidth
patterns are shown by iftop. When it’s done, iperf will produce a report of
your machine’s bandwidth capabilities. Kill both processes before moving
on.
Task 3:
mtr is a handy diagnostic tool that combines many of the uses of ping and
traceroute. Its output is pretty self-explanatory:
mtr 101labs.net
Task 4:
whois 101labs.net
Often, but not always, the domain owner’s contact information is hidden
behind a registrar’s privacy feature. What may be more useful, however, is
the ability to discover an abuse contact in case of spam, phishing, or other
nefarious activity originating from a domain.
whois 184.168.221.43
Occasionally you may have a need to discover the owners and abuse
contacts behind an IP or block of IPs — this command will do that.
Lab Objective:
Lab Purpose:
In this lab you will monitor CPU load and other metrics over time using a
tool called sar.
Lab Tool:
Lab Topology:
Lab Walkthrough:
Task 1:
NOTE: If sysstat was not previously installed, you should now give it at
least 20-30 minutes to gather some data. This tool is most useful when it
can collect data over a longer period of time.
Task 2:
Not enough information for you? Well, you’re in luck, because sar can do a
lot more. Run:
The man pages explain a lot more, but this command will print information
about queues, load averages, context switches, power management…
basically everything you’d ever want to know about your CPU without
getting into other hardware—and yes, sar can monitor that too!
Notes:
Many other tools, such as top or uptime, can show you a real-time view of
CPU usage.
Lab Objective:
Lab Purpose:
In this lab, you will learn how to debug your system (or get a glimpse at
what’s going on) by viewing log messages.
Lab Tool:
Lab Topology:
Task 1:
dmesg
The man (manual) page for dmesg states that it is used to “examine or
control the kernel ring buffer.” To put it simply, you can use dmesg to view
boot logs and other logs your distro considers important.
Task 2:
Run:
ls -aR /var/log
This is the main storage directory for all system logs (although, see the
Notes). If you peruse some of the log files, you may find some of the same
logs that were printed by dmesg. In particular, look at:
/var/log/syslog
Configuration of rsyslog is outside the scope of this lab, but through rsyslog
you can record logs of all severities, write them to different files, e-mail
them, or even print emergency alert messages to the console for all users
to see.
Task 3:
sudo -i
three times. When prompted for your password, do each of the following
once:
● Type Ctrl+C to cancel the command.
● Intentionally mistype your password.
● Type your password correctly.
Check the tab where tail is running to see what is logged as a result of your
actions. This is a simple, but effective, method of keeping tabs on sudo
users on a system.
Notes:
Lab Objective:
Lab Purpose:
Lab Tool:
Lab Topology:
Lab Walkthrough:
Task 1:
Now take a peek at the actual firewall rules UFW has set up:
If you did Lab 65, you have a pretty good idea of the (sparse) rulesets that
your OS had set up by default. Enabling UFW alone made a lot of changes!
The rules themselves aren’t terribly complex, but the way they are
presented can make them difficult for a human to analyze directly. You can
see this output, slightly modified, with:
Task 2:
It’s not obvious from the last command, but UFW has added two DROP
rules (one for TCP, one for UDP) to the ufw-user-input chain.
You can also add rules for applications based on profiles, even if those
applications change their listening ports or if you don’t remember what
those ports are:
Task 3:
This will clear UFW’s rules, but not its chains. To do that, run:
sudo iptables -F
sudo iptables -X
Note that UFW only ever operates on the filter table, so you don’t need to
worry about any other rules or chains polluting the other tables.
Notes:
You can change some of UFW’s options, including default policies and
whether it manages the built-in chains (INPUT, OUTPUT, FORWARD) in
/etc/default/ufw. The application profiles, should you need to change their
ports, are stored in /etc/ufw/applications.d/.
Lab Objective:
Lab Purpose:
In this lab, you will learn how to configure various system processes and
how to manage and monitor those processes while they are running.
Lab Tool:
Lab Topology:
Lab Walkthrough:
Task 1:
ls /boot
The contents will vary, but generally what you will see is a Linux kernel file
(name starting with vmlinuz), initrd file, System.map, a GRUB configuration
directory, and sometimes a copy of the kernel configuration. Everything in
this directory, including the grub config file (/boot/grub/grub.cfg), is
related—as you might expect—to your system boot processes. This is one
directory you don’t want to mess with unless you know what you’re doing!
Task 2:
Next, run:
ls /etc
In Linux parlance, ‘etc’ stands for ‘editable text configuration.’ /etc is the
primary directory tree for all system configuration — with few exceptions,
nearly all configurations are stored in, or linked from, /etc.
Task 3:
ps -ef
top
These are three common tools to monitor processes and their resource
usage. (Got a runaway process that won’t quit via normal means? Try kill or
pkill.)
Notes:
/dev contains special files called device nodes, which are linked to device
drivers. /sys and /proc contain files through which the kernel communicates
with user space. You can read from them to get system information, but
rarely should you write to them directly, especially without understanding
what you are doing.
Lab Objective:
Lab Purpose:
In this lab, you will examine some common networking principles, namely
ports and services, using Linux command-line tools.
Lab Tool:
Lab Topology:
Task 1:
sudo ss -Saputn
The first column lists what protocol each connection follows. Most likely this
will be either UDP or TCP, which you may recall are faster/connectionless
and more-reliable/connection-oriented, respectively. Columns 5 and 6 list
your IP:port and the remote host’s IP:port. TCP and UDP each have 65,535
ports available, some of which are assigned (either officially, by IANA, or
unofficially by common use) to various services.
Look at the port numbers and try to identify which services are using each
“server” port. The server port is important, because the client port (the port
from which a client first makes a connection) is usually dynamic. It may
help to look at column 7 to see what process on your machine is using the
connection.
Task 2:
Programs commonly use the /etc/services file to map service names to the
port(s) they should listen or connect on. The file is human-readable, so you
should look yourself.
By looking through:
cat /etc/services
Can you identify what services your machine was listening for, or
connecting to, in Task 1?
Can you identify which ports are used by common services, such as HTTP,
SSH, LDAP, SNMP, and SMTP?
Task 3:
Another very common protocol is one that you won’t find any listening ports
for… because it doesn’t have ports! This is ICMP, a.k.a. “ping” (though in
reality, it is used for much more than pinging).
ping -c 5 localhost
Go back to the first tab, and you should see the requests and replies from
your pings—and maybe some other ICMP traffic too, if you’re lucky.
Notes:
If you couldn’t see any traffic or get any ICMP replies in the last task, a
firewall on your machine may be to blame. Blocking ICMP traffic
indiscriminately like that is a poor practice, so it's an exercise to the student
to figure out how to open that up a little. (Hint: iptables)
Lab Objective:
Lab Purpose:
In this lab, you will learn about standard shell scripting syntax, such as
tests and control flow.
Lab Tool:
Lab Topology:
A single Linux machine, or virtual machine
Lab Walkthrough:
Task 1:
Open your favorite editor via the terminal and create a file called lab76.sh:
nano lab76.sh
#!/bin/sh
i=0
do
echo $i
i=$(($i+1))
done
do
test -s /etc/$file
then
fi
done
This highly contrived and not very useful script contains a number of
important features. The first is test, which can test a wide variety of
conditions depending on its flags and return a 0 or 1 (true or false) exit
status. That exit status can, in turn, be used by control flow syntax—if
statements, or for or while loops. A simpler kind of if statement is the && or
|| syntax, a boolean ‘and’ or ‘or’, respectively.
chmod +x lab76.sh
./lab76.sh
You should see the numbers 0-4 printed out, followed by a large amount of
text output, depending on what’s in your /etc directory.
Notes:
Lab Objective:
Learn basic Linux commands and shell syntax.
Lab Purpose:
Lab Tool:
Lab Topology:
Lab Walkthrough:
Task 1:
The echo command simply prints out all of the “words,” or arguments, that
you give to it. This might not seem very useful, until...
Task 2:
quote='cat /etc/issue'
backquote=cat /etc/issue
echo $quote
echo $backquote
Here, quote and backquote are variables. In the first two lines, we set them
to the values 'cat /etc/issue' and `cat /etc/issue`, respectively. (We’ll get to
the difference between quotes and backquotes in a minute.) In the last two
lines, we reference the variables by putting $ before them, and print out
their contents.
Task 3:
hello
“echo hello”
echo “$hello”
echo ‘$hello’
echo “$hello”
Double quotes allow for variables to have their values referenced. Single
quotes are always literal, while backquotes execute the command
(including variable references) within those quotes.
Task 4:
Notes:
In some cases, you will want to reference variables with the ${variable}
syntax. This is equivalent to $variable, but the reasons for choosing one
over the other are beyond the scope of this lab.
$(echo hello)
Lab Objective:
Learn how to use basic regular expressions for complex string pattern
matching.
Lab Purpose:
Lab Tool:
Lab Topology:
Lab Walkthrough:
Task 1:
Open the Terminal application and create a text file first (copy and paste
won’t work for the below)
Task 2:
Now, try to predict what the output of each command will be before running
it (see Answers 1-7 below):
Answer 1:
Answer 2:
Answer 3:
Answer 4:
Answer 5:
\x1fhtml!
Answer 6:
(No output)
Answer 7:
Notes:
Regexr is a great resource for practicing your regular expressions. See
man 7 regex for more information on regex as supported by your distro.
Lab Objective:
Learn how to use extended regular expressions for complex string pattern
matching.
Lab Purpose:
Lab Tool:
Lab Topology:
Lab Walkthrough:
Task 1:
Task 2:
Now, try to predict what the output of each command will be before running
it (see Answers 1-7 below):
egrep >0-3@ lab94.txt
egrep (short for grep -E) uses extended regex, instead of basic regex,
which is the default.
Task 3:
Finally, apply some of what you’ve learned about regex to these sed
substitution commands. Again, what will the output be (see Answers 8-10
below)"
Answer 1:
Answer 2:
Answer 3:
abc123 456def password 01234567890 A1B2C3D4E5 6F7G8H9I0J
Answer 4:
Answer 5:
\x1fhtml!
Answer 7:
Answer 8:
Bello Borld!
Answer 9:
Hello World!
Answer 10:
He**o World!
pa**word 01234567890 A1B2C3D4E5 6F7G8H9I0J Quoth the raven
'Nevermore.'
Notes:
Lab Objective:
Lab Purpose:
In this lab, you will practice changing boot parameters for the purpose of
resetting the root password.
Lab Tool:
Lab Topology:
Lab Walkthrough:
IMPORTANT: This is one lab where the exact steps may vary greatly
between distros, your particular bootloader configuration, and even different
versions of Kali. If you run into problems, Google may be enlightening.
Task 1:
Reboot until you reach the GRUB boot menu. If you cannot see the GRUB
boot menu, follow your distro-specific instructions to modify your boot
configuration so that the menu is visible.
Task 2:
Hit ‘e’ to edit the Kali Linux boot commands (this should be the first menu
item). Scroll down to the line beginning with linux. On that line, replace the
ro option with rw init /bin/bash, then hit Ctrl+X to boot.
Task 3:
You should boot into a root prompt with your root file system mounted.
Now simply run:
passwd
reboot -f
Notes:
Lab Objective:
Learn how to manage input and output in the Linux shell by using
redirection and file descriptors. This lab will introduce you to the concepts
of stream redirection and how to use file descriptors to control how data is
read from and written to files.
Lab Purpose:
In this lab, you will explore how to manipulate the standard input, output,
and error streams using redirection and pipes. You will also learn how to
handle file descriptors to redirect or suppress output and control where
input comes from in your shell commands.
Lab Tool:
Kali Linux (or any Linux distribution)
Terminal (Bash or any other shell)
Lab Topology:
Linux System: A single system or virtual machine running a Linux
distribution (e.g., Kali Linux, Ubuntu).
Shell: The Bash shell or any other command-line shell available.
Lab Walkthrough:
Notes:
● Redirection is a powerful tool in the shell, enabling you to control
where input and output come from and where they go. This is crucial for
automating tasks and managing files.
● File Descriptors allow processes to interact with the system in a
structured way. Understanding them will enable you to manage
input/output more efficiently.
● Pipes allow you to chain commands together, making it easier to
perform complex tasks in a single line of code. This is a hallmark of
powerful shell scripting.
● Standard Input, Output, and Error: Understanding these concepts is
key to managing shell processes effectively. It helps in debugging,
logging, and automating tasks.
Lab Objective:
Learn how to create partitions, format them with filesystems, and mount
them on a Linux system. In this lab, you will work with the fdisk, mkfs, and
mount commands to create partitions, set up filesystems, and manage
storage devices.
Lab Purpose:
In this lab, you will gain hands-on experience in partitioning a disk, creating
filesystems, and mounting partitions on Linux. Understanding how to
manage disk partitions is critical for configuring storage, setting up new
systems, and managing data.
Lab Tool:
Kali Linux (or any Linux distribution)
Terminal (Bash or any other shell)
A disk or virtual disk (for testing)
Lab Topology:
Linux System: A single system or virtual machine running a Linux
distribution (e.g., Kali Linux, Ubuntu).
Disk: You can either use a virtual machine with an unpartitioned disk
or a physical disk.
Lab Walkthrough:
Notes:
● Partitioning a disk divides it into logical sections that can be used
independently.
● Filesystems define how data is stored and retrieved on a disk.
Common filesystems include ext4, xfs, and btrfs.
● Mounting a partition allows the system to use it. It connects the
partition to a directory in the file system hierarchy.
● fstab ensures partitions are automatically mounted at boot time.
Lab Objective:
Learn how to manually mount and unmount filesystems in Linux. You will
understand how to use the mount and umount commands to manage
filesystems, and how to work with various mount options.
Lab Purpose:
In this lab, you will gain hands-on experience with manually mounting and
unmounting filesystems. Understanding how to control mounting is
essential for managing storage devices and configuring Linux systems for
various use cases.
Lab Tool:
Kali Linux (or any Linux distribution)
Terminal (Bash or any other shell)
A disk or virtual disk (for testing purposes)
Lab Topology:
Linux System: A single system or virtual machine running a Linux
distribution (e.g., Kali Linux, Ubuntu).
Disk/Partition: You can either use a physical disk or a virtual disk (for
example, /dev/sdb1) for testing purposes.
Lab Walkthrough:
Task 1: List Available Disks and Partitions
Before mounting a partition, it's important to identify available disks and
partitions.
● List Disks and Partitions Using lsblk: The lsblk command shows all
available block devices on your system:
lsblk
This will list devices such as /dev/sda, /dev/sdb, etc., and their
partitions (e.g., /dev/sdb1, /dev/sdb2).
● List Detailed Information Using fdisk: Use fdisk -l to list detailed
partition information:
sudo fdisk -l
This will display detailed information about the disk partitions, including
their filesystem type, partition size, and partition table type.
Question: What information can you gather from the fdisk -l command, and
how does it help in identifying partitions for mounting?
Notes:
● Mounting a filesystem connects it to the Linux file hierarchy, allowing
access to its files.
● The **mount** command is versatile and supports many options for
customizing how filesystems are mounted.
● Unmounting a filesystem is essential to avoid data corruption,
especially when disconnecting drives or shutting down.
● Force unmounting should be used with caution, as it can result in loss
of data if the filesystem is in use.
● NTFS filesystems are often used with Windows systems, and special
handling may be required to mount them on Linux.
Lab 84 – Manage User and Group Accounts and Related System Files:
Special Purpose Accounts
Lab Objective:
Learn how to manage special-purpose user and group accounts in Linux.
These accounts typically include system accounts, service accounts, and
accounts used by various system processes and applications.
Lab Purpose:
In this lab, you will explore special-purpose accounts such as those used
by system services, processes, and applications. Understanding how to
manage these accounts is important for system administration, security,
and maintaining proper user permissions in a Linux environment.
Lab Tool:
Kali Linux (or any Linux distribution)
Terminal (Bash or any other shell)
Lab Topology:
Linux System: A single system or virtual machine running a Linux
distribution (e.g., Kali Linux, Ubuntu).
Terminal: Used for running commands and managing user and group
accounts.
Lab Walkthrough:
Notes:
● System Accounts are typically used for background services and
system processes, and they usually have UIDs below 1000.
● Service Accounts are associated with specific software or services
and often have restricted login capabilities (e.g., /usr/sbin/nologin as the
shell).
● Groups control access to resources and permissions, and managing
groups ensures proper isolation of system services.
● Managing special-purpose accounts involves not only creation and
deletion but also ensuring appropriate permissions for system security
and stability.
Lab Objective:
Learn how to configure and manage system logs using Rsyslog in Linux.
You will understand how Rsyslog works, configure logging for various
services, and troubleshoot by analyzing logs.
Lab Purpose:
This lab focuses on Rsyslog, a system logging daemon that provides a
centralized logging mechanism for various system processes. By the end
of this lab, you will be able to configure log sources, set up log forwarding,
and perform basic troubleshooting using log files.
Lab Tool:
Kali Linux (or any Linux distribution)
Terminal (Bash or any other shell)
Lab Topology:
Linux System: A single system or virtual machine running a Linux
distribution (e.g., Kali Linux, Ubuntu).
Rsyslog Daemon: The Rsyslog service should be installed and
running by default in most Linux distributions.
Lab Walkthrough:
Notes:
● Rsyslog is a powerful and flexible tool for logging system messages. It
allows you to control how logs are stored and forwarded, making it an
essential tool for system administrators.
● Log rotation ensures that log files do not consume excessive disk
space by regularly rotating them and keeping a limited number of old
logs.
● Logs are crucial for system monitoring and troubleshooting, and
Rsyslog provides the central mechanism for managing these logs in
Linux systems.
GITHUB LABS
Lab Objective:
Learn the fundamentals of Git and GitHub, including how to initialize a
repository, stage changes, commit files, and understand version control
basics.
Lab Purpose:
In this lab, you will create a local Git repository, add files to it, make
commits, and explore the basic workflow of version control using Git. This
foundational knowledge is essential for collaborative development and
code management.
Lab Tool:
Git (latest stable version), GitHub account, and a terminal or command-line
interface.
Lab Topology:
A local machine with Git installed. Optionally, access to GitHub via a web
browser or GitHub Desktop.
Lab Walkthrough:
Task 1:
Initialize a local Git repository in a new directory. Use the following
commands:
mkdir my-first-repo
cd my-first-repo
git init
Question: What does the `git init` command do? What changes occur in
your directory after running it?
Task 2:
Create a new file in your repository and add some content to it. For
example:
echo "Hello Git!" > hello.txt
Then, use the following commands to add and commit the file:
git add hello.txt
git commit -m "Initial commit with hello.txt"
Question: What is the difference between `git add` and `git commit`? Why
is it important to stage files before committing?
Notes:
- Initializing a repository with `git init` allows you to begin versioning files
locally.
- Commits record snapshots of your file changes and are used for tracking
project history.
Lab 2 – Remote Repositories
Lab Objective:
Understand how to connect a local repository to GitHub and explore the
GitHub user interface to navigate repositories, branches, and commits.
Lab Purpose:
In this lab, you will learn how to push a local Git repository to GitHub,
create and link a remote, and use the GitHub UI to view project data such
as branches and commit history.
Lab Tool:
Git (CLI), GitHub.com (web interface).
Lab Topology:
A local Git repository and a GitHub account with a new or existing
repository.
Lab Walkthrough:
Task 1:
Initialize a local Git repository and push it to GitHub.
Steps:
1. Create a directory and initialize Git:
mkdir my-project && cd my-project
git init
2. Create a file, add and commit:
echo "# My Project" > README.md
git add .
git commit -m "Initial commit"
3. Create a repository on GitHub.
4. Add the remote and push:
git remote add origin https://github.com/your-username/my-project.git
git push -u origin main
Task 2:
Explore the GitHub UI.
Question: What information can you view about each commit? How does
the GitHub UI help you track branch activity and changes over time?
Notes:
Connecting a local Git repository to a remote GitHub repository enables
online collaboration and version tracking. The GitHub UI is a powerful tool
to visualize and manage repositories, branches, and development
progress.
Task 3:
Check the status and log of your repository to view tracked changes and
commit history:
git status
git log
Question: What information does `git status` provide? What details can you
observe in the `git log` output?
Task 4:
Create a second file and repeat the process of adding and committing.
Then, make a change to the first file and commit again.
echo "Another file" > second.txt
git add second.txt
git commit -m "Add second file"
echo "Update to hello.txt" >> hello.txt
git add hello.txt
git commit -m "Update hello.txt with more text"
Question: How does Git track changes between commits? How can you
view what was changed using Git?
Task 5:
Explore the .git directory and discuss its contents. Use:
ls -a
cd .git
ls
Question: What kind of data is stored in the `.git` folder? Why should this
folder not be modified manually?
Notes:
Git is a powerful version control system that enables efficient collaboration
and code tracking. Understanding the basic Git workflow—including
initializing repositories, committing changes, and viewing history—is
essential for any developer or IT professional. This lab provides hands-on
experience with core Git commands to build a solid foundation for more
advanced version control techniques.
Lab Objective:
Learn how to create and switch branches using Git CLI and demonstrate
the GitHub Flow model including branching, pull requests (PR), and
merging.
Lab Purpose:
In this lab, you will use Git on the command line to create and manage
branches, simulate collaborative development using GitHub Flow, and
understand how pull requests facilitate code review and merging in a team
environment.
Lab Tool:
Git (latest stable version), GitHub account, web browser, and a terminal or
command-line interface.
Lab Topology:
A local Git repository linked to a remote GitHub repository.
Lab Walkthrough:
Task 1:
Ensure your local repository is connected to GitHub. Check the current
branch:
git branch
Question: What is your current branch? What does the asterisk (*)
indicate?
Task 2:
Create and switch to a new branch for a feature:
Task 3:
Push your branch to GitHub:
git push -u origin feature-xyz
Navigate to GitHub and open a Pull Request (PR) for your `feature-xyz`
branch.
Task 4:
Review and merge the PR on GitHub. Once merged, pull the updated main
branch:
Task 5:
Clean up the feature branch locally and remotely:
Notes:
The GitHub Flow is a lightweight, branch-based workflow that supports
collaboration and code review. It encourages the use of short-lived
branches and pull requests for structured development. Mastering this flow
is essential for modern software teams and continuous integration
practices.
Lab Objective:
Understand the difference between Git and GitHub, and explore advanced
Git concepts such as stashing, rebasing, tagging, and gitignore.
Lab Purpose:
This lab will help you distinguish between Git as a local version control
system and GitHub as a remote repository hosting platform. You will also
explore several advanced Git features that improve your workflow and
project management.
Lab Tool:
Git (latest stable version), GitHub account, and a terminal or command-line
interface.
Lab Topology:
A local Git repository connected to a GitHub remote repository.
Lab Walkthrough:
Task 1:
Compare Git and GitHub. Research and write down the differences
between the two.
Question: How does Git manage your code locally? What does GitHub add
to the development process that Git alone cannot provide?
Task 2:
Use git stash to temporarily save changes:
echo "Temporary change" >> temp.txt
git add temp.txt
git stash
Question: How does rebasing differ from merging? What are the benefits
and risks of using rebase?
Task 4:
Create a tag for a release version:
git tag -a v1.0 -m "Release version 1.0"
git push origin v1.0
Task 5:
Create and use a .gitignore file to exclude specific files or directories:
echo "*.log" > .gitignore
echo "node_modules/" >> .gitignore
git add .gitignore
git commit -m "Add .gitignore file"
Notes:
Git is a powerful local version control tool, while GitHub offers remote
repository management and collaboration features. Understanding the
distinction and mastering advanced Git functionalities will significantly
improve your productivity and code management. These skills are essential
for real-world software development workflows.
Lab 5 – README and Markdown Formatting
Lab Objective:
Learn how to create and format a README file using Markdown to
effectively document your GitHub repository.
Lab Purpose:
In this lab, you will add a README file to your repository and use
Markdown syntax to format text, insert links, create lists, and embed
images. This helps communicate your project purpose, usage, and setup
instructions clearly to others.
Lab Tool:
Text editor (VS Code, nano, or any Markdown editor), Git, GitHub.
Lab Topology:
A local Git repository with a GitHub remote.
Lab Walkthrough:
Task 1:
Create a new file called README.md in your repository root:
touch README.md
Task 2:
Add a project title and description using Markdown headers and text
formatting. Example content:
# Project Title
This is a sample project to demonstrate how to use Markdown in a
README file.
Question: How do Markdown headers work (e.g., #, ##, ###)? What are the
differences in size and hierarchy?
Task 3:
Create a usage section with bullet points and code blocks. Example:
# Usage
- Clone the repository
- Navigate to the directory
- Run the application
```
git clone https://github.com/your-username/your-repo.git
cd your-repo
npm start
```
Task 4:
Add links and images using Markdown. Example:
# Resources
[GitHub Docs](https://docs.github.com)

Task 5:
Commit and push your README.md file:
git add README.md
git commit -m "Add README with Markdown formatting"
git push origin main
Notes:
README files are often the first thing users see when they visit your
repository. Markdown makes it easy to structure content, add visuals, and
improve readability. A professional README reflects the quality and
usability of your project.
Lab Objective:
Learn how to use GitHub Desktop to clone repositories, commit changes,
push updates, and manage collaborators with appropriate permissions.
Lab Purpose:
This lab introduces GitHub Desktop as a visual tool for working with GitHub
repositories. You will learn how to perform essential Git operations and
manage collaborators on a GitHub repository to facilitate teamwork and
secure project access.
Lab Tool:
GitHub Desktop, GitHub account, web browser.
Lab Topology:
A remote GitHub repository cloned, edited, and managed using GitHub
Desktop.
Lab Walkthrough:
Task 1:
Install GitHub Desktop from https://desktop.github.com and log in using
your GitHub credentials.
Question: What are the benefits of using GitHub Desktop over the Git
command line for beginners?
Task 2:
Clone an existing GitHub repository using GitHub Desktop:
Question: Where is the local copy stored, and how can you confirm it’s
cloned correctly?
Task 3:
Make a small change in the local repo (e.g., add text to a README file).
Save the file and commit the changes using GitHub Desktop.
Question: What does committing and pushing achieve? Where can the
changes be seen online?
Task 4:
Add a collaborator to your repository:
Task 5:
Have your collaborator clone the repo via GitHub Desktop, make a change,
and push it. Observe the collaboration process.
Question: What challenges might arise in collaboration, and how does
GitHub help resolve them (e.g., file history, PRs, merge conflict resolution)?
Notes:
GitHub Desktop is a beginner-friendly tool for managing Git repositories. It
simplifies the process of cloning, committing, and pushing code. Adding
collaborators and controlling permissions is essential for teamwork,
ensuring security and effective collaboration.
Lab Objective:
Learn how to customize GitHub repository settings and apply basic branch
protection rules to improve project organization and maintain code quality.
Lab Purpose:
This lab guides you through updating repository metadata (like description
and topics) and configuring basic branch protection rules such as requiring
pull request reviews. These practices help teams collaborate more
effectively and protect critical branches from unintended changes.
Lab Tool:
Web browser, GitHub account.
Lab Topology:
A GitHub-hosted repository with branch protection settings enabled via the
web interface.
Lab Walkthrough:
Task 1:
Navigate to your repository on GitHub. In the top section of your repo page,
click the "Settings" tab.
Task 2:
Scroll down in Settings to "Features" and ensure features like Issues,
Discussions, and Wiki are enabled or disabled according to your team’s
needs.
Question: Why might you disable certain features like the Wiki or
Discussions?
Task 3:
Click on "Branches" in the left sidebar. Under "Branch protection rules",
click "Add rule". Configure the following:
Task 4:
Create a test branch and attempt to push changes directly to `main`.
Observe what happens if branch protections are enabled.
Question: What message or restriction do you encounter? How does this
reinforce collaborative workflows like pull requests?
Notes:
Repository settings are crucial for discoverability, security, and team
workflows. Branch protections reduce errors and enforce quality standards
by ensuring changes go through peer review or testing. These features
promote consistency and collaboration across teams.
Lab Objective:
Learn how to create, manage, and convert GitHub issues and discussions
to facilitate communication, task tracking, and team collaboration.
Lab Purpose:
This lab introduces GitHub Issues and Discussions as tools for project
planning and community engagement. You will learn how to use labels,
assignees, and pinning to organize issues, and how to convert between
issues and discussions to support different types of collaboration.
Lab Tool:
Web browser, GitHub account.
Lab Topology:
A GitHub-hosted repository with Issues and Discussions features enabled.
Lab Walkthrough:
Task 1:
Navigate to your GitHub repository and go to the "Issues" tab.
Click "New Issue" and create an issue with a meaningful title and
description. Assign the issue to yourself and apply relevant labels (e.g.,
bug, enhancement, question).
Task 2:
After creating your issue, click the three dots (•••) at the top-right and select
"Pin issue".
Question: When might you want to pin an issue? How does pinning impact
visibility for team members or contributors?
Task 3:
Click the "Convert to Discussion" option on your issue. Choose the
appropriate category (e.g., Q&A, ideas).
Task 4:
Go to the Discussions tab, find your newly converted discussion, and
interact with it (e.g., reply, react, or close it). Then click "Convert back to
Issue".
Question: What happens to the content and structure when converting back
to an issue? Are any changes lost or preserved?
Notes:
Issues and Discussions support collaborative project management in
different ways. Issues are best for task tracking and bugs, while
Discussions are better for brainstorming and community input. GitHub’s
conversion features let you switch formats as needs evolve.
Lab 9 – Pull Requests and Code Review
Lab Objective:
Learn how to link pull requests to issues, conduct code reviews, and
understand draft pull requests and pull request statuses.
Lab Purpose:
This lab guides you through the GitHub workflow of creating a pull request
(PR) linked to an issue, requesting a review, and navigating draft PRs and
status indicators. This process is essential for collaborative development
and ensuring code quality.
Lab Tool:
Web browser, GitHub account.
Lab Topology:
A GitHub-hosted repository with at least one open issue and a newly
created branch to submit pull requests from.
Lab Walkthrough:
Task 1:
Ensure there is an open issue in your repository. Create a new branch
locally or on GitHub, make a small change (e.g., update a file), and push
the branch.
Task 2:
Request a review from a collaborator. The reviewer should leave
comments, approve the PR, or request changes.
Respond to the comments and, if necessary, make further commits to the
branch.
Question: How does the code review process contribute to code quality and
team learning?
Task 3:
Create a new pull request but select "Create draft pull request".
Observe the "Draft" label and how it limits merging until marked as "Ready
for review".
Question: When is it appropriate to use a draft PR? What are the benefits
of starting with a draft rather than a regular PR?
Task 4:
Explore PR status checks (e.g., "All checks have passed", "Waiting for
review"). Enable or simulate a CI check if applicable.
Question: How do status checks affect the ability to merge a PR? Why are
automated checks important in collaborative projects?
Notes:
Pull requests are central to GitHub collaboration, allowing developers to
propose changes, request feedback, and merge contributions safely.
Linking PRs to issues ensures traceability, and using draft PRs and review
workflows maintains quality across teams.
Lab Objective:
Learn how to conduct detailed code reviews by commenting on specific
lines of code within a pull request on GitHub.
Lab Purpose:
This lab teaches how to provide constructive feedback by reviewing
individual lines of code in a pull request. Reviewing code at this granular
level improves quality and facilitates team communication during
development.
Lab Tool:
Web browser, GitHub account.
Lab Topology:
A GitHub-hosted repository with an open pull request containing code
changes to review.
Lab Walkthrough:
Task 1:
Open an existing pull request in your repository. Navigate to the "Files
changed" tab to view the modified files.
Click the "+" icon next to a line of code to add an in-line comment. Provide
feedback or ask a question.
Task 2:
Add multiple comments across different lines in the pull request, then click
"Submit review" and select either "Comment", "Approve", or "Request
changes".
Question: When would you choose each review option? How does each
one affect the PR and the contributor?
Task 3:
Respond to a review comment from another collaborator. Discuss how this
feedback cycle leads to better code and understanding.
Question: How should developers handle feedback they disagree with?
What’s the best approach to maintaining positive team communication
during reviews?
Notes:
In-line code comments provide targeted feedback that helps developers
understand exactly what needs improvement. GitHub’s code review tools
support professional collaboration, encourage discussion, and ensure
higher code quality through collective input.
Lab Objective:
Learn how to use repository templates to start new projects and explore
GitHub Gist and forking for sharing and reusing code.
Lab Purpose:
This lab introduces repository templates and gist as tools to promote
re-usability and quick project setup. You’ll create a new project from a
template and explore how forking gist enables collaboration and
modification of shared code snippets.
Lab Tool:
Web browser, GitHub account.
Lab Topology:
A GitHub-hosted repository marked as a template, and the GitHub Gist
platform.
Lab Walkthrough:
Task 1:
Navigate to a repository marked as a template on GitHub (or mark one of
your own repos as a template).
Click the "Use this template" button to create a new repository based on it.
Customize the repo name and settings during creation.
Question: What are the benefits of using a repository template over starting
from scratch? How might this be useful for on-boarding team members?
Task 2:
Visit https://gist.github.com/ and create a new public or secret gist with at
least one file. Add a brief description and meaningful content.
Question: What types of code or content are best suited for gist versus full
repositories?
Task 3:
Search for another user’s public gist and click "Fork" to create your own
copy. Modify the content in your forked version and save it.
Notes:
Repository templates provide consistent project structures and are ideal for
reusable codebases or starter kits. Gist offer lightweight sharing for code
snippets or single files, with forking enabling easy modification. Both tools
enhance development efficiency and sharing.
Lab 12 – Branch Management
Lab Objective:
Learn how to manage branches by creating a new branch, switching
contexts, and adding files in GitHub or via the Git CLI.
Lab Purpose:
This lab focuses on branch management as a key part of working with Git.
By creating a new branch and adding files to it, developers can safely test
and build features in isolation from the main code-base.
Lab Tool:
GitHub.com, GitHub Desktop, or Git CLI.
Lab Topology:
A GitHub repository with write access for performing branch operations.
Lab Walkthrough:
Task 1:
Navigate to your GitHub repository or open it in GitHub Desktop/CLI.
Create a new branch called "feature/new-content".
Task 2:
Add a new file (e.g., README-update.md or test.txt) to the new branch.
Commit and push the changes to GitHub.
Using the CLI:
echo "Test content" > test.txt
git add test.txt
git commit -m "Added test file to new branch"
git push origin feature/new-content
Question: How does Git track changes per branch, and what happens
when you switch between branches with different files?
Notes:
Branching allows multiple streams of development to occur without
interfering with each other. This enables safer experimentation and easier
code reviews before merging into production branches.
Lab Objective:
Understand how to enforce code reviews by configuring a CODEOWNERS
file in a GitHub repository.
Lab Purpose:
This lab introduces the CODEOWNERS file, which designates users or
teams responsible for reviewing code in specific parts of a repository. It
automates review requests and enforces collaborative workflows.
Lab Tool:
GitHub.com or GitHub CLI, text editor.
Lab Topology:
A GitHub repository with at least two collaborators or teams, and branch
protection rules enabled.
Lab Walkthrough:
Task 1:
Create a `.github` directory in the root of your repository if it doesn’t exist
already.
Task 2:
Enable branch protection on the default branch and require code reviews.
Check "Require pull request reviews before merging" and optionally enable
"Require review from Code Owners".
Notes:
The CODEOWNERS file is a powerful GitHub feature for automating
reviews and managing contributions across large or multi-team projects.
When paired with branch protection rules, it ensures accountability and
helps maintain high-quality code standards.
Lab 14 – Advanced GitHub Features
Lab Objective:
Explore advanced GitHub features that help manage and track project
progress effectively.
Lab Purpose:
This lab focuses on using GitHub’s advanced project management tools
such as Projects, Milestones, Labels, and Insights to plan, track, and
measure development progress.
Lab Tool:
GitHub.com (web interface).
Lab Topology:
An active GitHub repository with Issues and Pull Requests.
Lab Walkthrough:
Task 1:
Create a new GitHub Project board.
Navigate to the "Projects" tab in your repository and click "New Project".
Choose either a Kanban or Table layout.
Add at least three columns (e.g., To Do, In Progress, Done) and move
existing issues or PRs to appropriate columns.
Task 2:
Create a Milestone and assign it to issues or pull requests.
Task 3:
Use Labels to categorize issues and pull requests.
Filter issues/PRs using labels to understand the nature and status of your
project’s tasks.
Question: How can label systems be customized to suit different teams and
workflows?
Task 4:
Explore GitHub Insights.
Notes:
Advanced GitHub features support agile planning, progress tracking, and
productivity measurement. Teams that use Projects, Milestones, and
Insights efficiently can coordinate development better and meet project
deadlines more reliably.
Lab Objective:
Understand the use of draft pull requests and their statuses, create and
fork gists, and provide code-specific comments during code reviews.
Lab Purpose:
This lab combines key GitHub collaboration tools to enhance the
development workflow. You’ll learn how to initiate work with draft pull
requests, share and collaborate using gists, and conduct detailed code
reviews by commenting on specific lines.
Lab Tool:
GitHub.com (web interface), GitHub CLI (optional).
Lab Topology:
An active GitHub repository and access to GitHub Gists.
Lab Walkthrough:
Task 1:
Create a draft pull request.
Review the pull request page to observe the "Draft" label and limited merge
actions.
Task 2:
Understand and track pull request statuses.
Observe the change from "Draft" to "Ready for review" when you mark a
draft PR as ready.
Note CI checks, review statuses, and merge conflicts under the PR status
box.
Visit https://gist.github.com/ and create a new gist with some code content.
Find another user’s gist and click "Fork" to create your copy.
Task 4:
Comment on specific lines of code in a pull request.
Open an active pull request and click on the "Files changed" tab. Hover
over a line and click the blue "+" icon to comment.
Notes:
Using draft PRs allows early collaboration while clearly indicating
incomplete work. Gists simplify sharing small code snippets, and inline PR
comments make code reviews precise and actionable, fostering better
communication and code quality.
Why the lab. Why the command. Case studies to use commands and labs.
Scenarios. How the command can be used to solve networking cybersec
devops issues. Explanation should be at the beginning of each lab.
don't change formatting but make this lab 79 suited for kali linux. let the
bash commands be plain text not inside a bash shell