Command Line Interface
Project Introduction
This project was focused on learning the command line interface of Linux and MacOS. Since Linux is the backbone of networks, IoT systems, and most servers, a strong understanding of the CLI is essential for working with networks.
The project included various small activities to teach the class about the CLI, including:
-
Map the Maze Part I: Conceptual overview of file system and introduction to CLI commands.
-
Ubuntu CLI Tutorial: Practice with using CLI commands in an Ubuntu VM
Prerequisites
In order to run Ubuntu on the M1 Mac minis in the computer lab, UTM was installed and Ubuntu was run inside a VM using Ubuntu with UTM, QEMU, and Apple Hypervisor for Apple Silicon.
Also, MKDocs had to be installed on the Mac minis in order to build documentation and push it to GitHub. Unfortunately, simply running pip3 install mkdocs
installed the mkdocs package installed it at ~/Library/Python/3.12, the user-specific folder that hosts packages tied to the system-wide python. However, by default, ZSH does not know about this folder, so the ZSH configuration profile had to be edited to point to this folder. Anytime mkdocs needed to be run, python3 -m mkdocs
had to be specified rather than just being able to run mkdocs
. To fix this issue, the process was:
-
Type
find ~/Library/Python -name mkdocs
to find the specific path where mkdocs is installed. It should return/Users/*username*/Library/Python/3.xx/bin/mkdocs
-
Open the ZSH configuration file with
nano ~/.zshrc
, then add this line:export PATH="$HOME/Library/Python/3.xx/bin:$PATH"
-
Refresh the ZSH profile with
source ~/.zshrc
-
Run
mkdocs --version
to confirm it works. It should return something likemkdocs, version 1.6.1 from /Users/*username*/Library/Python/3.xx/lib/python/site-packages/mkdocs (Python 3.xx)
After completing these steps, MKDocs commands should be able to run by simply specifying mkdocs
+ command (build, serve, gh-deploy, etc.) rather than writing out python3 -m mkdocs
. Although functionality remains unchanged, MKDocs is much easier and more convenient to work with after making these changes.
Map the Maze Part I
This assignment was an introduction to the file system of a computer. Important terms learned in this assignment include:
Term | Definition |
---|---|
Root Directory | Very top of the file system |
Folder/Directory | Container used to organize files and other folders |
File | Single digital object that holds data in various formats; contains a name and an extension |
Path | "Address" of a file or folder inside the file system; either an absolute or relative path |
Absolute Path | Complete address of a file or directory (starting from root) |
Relative Path | Location of a file or directory starting from the working directory |
Drawing a Filesystem
The first activity in this assignment was to draw out a file system with the root at the top, a home folder, 3 sub-folders, and 2 sample files.
This section of the assignment was a simple introduction to the file system on a computer and helped in visualizing how a file system works.
Text-Based Filesystem & Partner Activity
The next activity was to type up a file system similar to the one that was drawn earlier then to trade file systems with a partner and ask them how they would find specific files in the file system.
MacOS Terminal Commands
After learning about the file system, we learned about essential MacOS/Linux commands and their purposes for the CLI, such as:
Command | Purpose |
---|---|
pwd |
Prints working directory (absolute path) |
ls |
Lists files and directories within the current directory |
cd |
Changes working directory to specified directory |
mkdir |
Makes a new directory within the current working directory |
`touch`` | Makes a new file in the current working directory or an |
cp |
Copies specified files to a specified directory |
mv |
Moves specified files to a specified directory |
open |
Opens any file or folder within the directory if just a file/folder name is given, or any file on the computer if an absolute path is specified |
rm |
Permanently removes specified files |
rmdir |
Permanently removes specified directories |
Ubuntu CLI Tutorial
After learning about essential Linux & MacOS CLI commands, we practiced using them in an Ubuntu VM to get familiar with both the commands and using Ubuntu.
Following this Ubuntu tutorial made by Canonical, I practiced using the command line in Ubuntu. I used commands like ls
, cd
, rm
, touch
, cp
, and a couple more.
Map the Maze Part II
This activity was completed mostly within the Ubuntu VM and involved creating files and directories, editing them with nano
, and transferring files between the host and VM.
The instructions for the activity were:
- Run
pwd
to show current directory- Outputs
/home/ubuntu
(username is ubuntu in the VM)
- Outputs
- Use
cd Documents
to enter the documents folder and runpwd
to show path- Outputs
/home/ubuntu/Documents
- Outputs
- Make a folder titled MazeGame in Documents and enter it with
mkdir MazeGame
andcd MazeGame
- Create 3 clue files with
touch clue1.txt clue2.txt clue3.txt
- Add "Congratulations! You found the first clue." to clue1.txt with
nano clue1.txt

- Share a file with the host by copying clue1.txt to ~/hostshare/ with
cp clue1.txt ~/hostshare/
On the first attempt, clue1.txt did not show up on the Mac anywhere after putting in in the hostshare folder in the VM. In order to enable file sharing between the host and VM, I needed to follow the following steps:
- Make a folder anywhere on the Mac, then go into UTM settings and set that folder as the shared directory for the VM

-
In the VM, type
sudo mount -t davfs http://127.0.0.1:9843/ ~/hostshare/
in order to set ~/hostshare as a shared directory between the host (M1 Mac mini) and the VM -
Restart the VM, then mount the shared disk inside UTM by selecting a shared folder
Once these steps were completed, files were able to be shared between the host and VM through ~/hostshare in the VM and the folder on the Mac that was selected as a shared directory in UTM's settings.
House Sitting Activity
The final activity in this project was the House Sitting Activity, where CLI commands were used to execute tasks within a "house" in the file system.
Prerequisites
Before starting, open terminal, change directories to Downloads with cd Downloads
, then clone the project by typing sudo git clone https://github.com/thewangclass/CK-Building-Content-Knowledge-Workshop
. Once this is completed, the house can be explored by following the instructions.
Procedure
- Walk to the house and go inside.
- Use
cd house
- Use
- Where can we go?
ls
returns bedroom1, bedroom2, garage, kitchen, and main_entrance
- Go inside the main entrance
- Use
cd main_entrance
- Use
- See if there is anything around in the main entrance, such as instructions.
ls
returns instructions.txt, unopened_mail1.txt, unopened_mail2.txt, unopened_mail3.txt, and shoerack
- Open the instructions.
- Use
cat instructions.txt
to display the contents in the terminal.
- Use
- Leave the main entrance and go back to the house level.
- Use
cd ..
to go up one level in the file system in order to access other rooms
- Use
- Go inside the kitchen
- Use
cd kitchen
- Use
- Check out what's inside the kitchen.
ls
returns apple, banana, cereal, crackers, donut, milk, orange
- "Eat" 2 items of food by removing them.
- Use
rm -r apple donut
to remove them. The-r
argument afterrm
tells therm
command to act recursively and remove all of the arguments, not just the first one.
- Use
- You smell something, but you cannot see it. Find out what it is.
- Use
ls -a
in order to list all files, including hidden ones. This reveals everything from just writingls
, but also includes .rotten_bananas, a hidden file (files beginning with a period are hidden).
- Use
- Throw away the bananas.
- Use
rm .rotten_bananas
to delete the file
- Use
- Check the bedrooms to make sure everything is okay.
- Use
cd ..
to move up one level, then usecd bedroom1
to enter bedroom 1.
- Use
- Conduct a thorough search to look for anything unusual.
- Use
ls -a
to reveal everything, including hidden files. There's a hidden file titled .secret_diary.txt. Reveal the contents usingcat .secret_diary.txt
- Use
- Now, enter bedroom 2 and explore it
- Use
cd ..
to move up one level thencd bedroom2
to enter the 2nd bedroom. - Then, use
ls -a
to reveal all files. There was only regular items such as a chair, desk, and messy bed. - Explore each item with
ls -a [name]
in order to list out the contents of each item. Desk should have a file titled search_desk.txt.
- Use
- The lights just went out and you are lost. Figure out where you currently are.
- Use
pwd
to print your location (directory)
- Use
- Navigate to the garage to figure out what is wrong with the lights.
- Use
cd ..
thencd garage
to go to the garage.
- Use
- The lights suddenly come back. What is in the garage?
- Use
ls -a
to list the garage's contents. There are 3 cardboard boxes, 4 garbage bags, and a hose in the garage.
- Use
- Remove all of the garbage as a favor to your friend.
- Use
rm -r garbage1 garbage2 garbage3
to get rid of all the garbage bags. Then,cd
into each cardboard box and see which ones have garbage in them. Userm -r
on whichever boxes have garbage in them to delete them.
- Use
- Return to the main entrance.
- Use
cd ../..
to go up 2 levels, then usecd main_entrance
to enter the main entrance.
- Use
- Leave a note for your friend.
- Use
touch goodbye_note.txt
to create a file, then usenano goodbye_note.txt
to add a message.
- Use
- There may be a hidden room in the house that was not previously explored. Look for it.
- Use
cd ..
to go up one level, then usels -a
to reveal all files/directories. It should reveal .hidden_basement. - Enter the hidden basement with
cd .hidden_basement
, then list all files/directories withls -a
. This should reveal .hidden_stash.
- Use
Reflection
This project was a thorough introduction and exploration of the CLI for MacOS and Linux, and taught important commands such as cd
, ls
, and many more. The CLI is essential in networking environments since servers never have any kind of GUI to interact with. Instead, people interact with servers solely throught the CLI. Therefore, in order to work with IoT devices, servers, and basically anything related to networking, a strong grasp of how to use the CLI effectively is imperative. While working with a CLI was a bit intimidating at first, it was easy enough to get familiar with the commands and effectively carry out tasks.