“My progress through Cisco’s Linux Unhatched labs"
This repository documents my journey through Cisco’s Linux Unhatched labs, including commands, insights, and screenshots.
All labs successfully completed and documented with screenshots 🎉
- Commands:
ls,ls -l,ls -r,ls -lr
What They Do:
ls: Lists directory contentsls -l: Lists contents in long format, showing permissions, ownership, and timestampsls -r: Lists contents in reverse orderls -lr: Combines both options—lists contents in long format and reverse order
Insights:
- Got "Permission denied" when running
lsin some directories → learned about file permissions - Typing
ls-rgave an error → spacing matters (ls -ris correct)
- Commands:
clear,pwd,cd,cd ..,cd .,cd ~
What They Do:
clear: Clears the terminal screen (tidies up the workspace).pwd: Prints the working directory (shows your current location in the filesystem).cd [path]: Changes directory to the specified path.cd /: Moves to the root directory (the top of the filesystem tree).cd ..: Moves up one level to the parent directory.cd .: Refers to the current directory (not very useful withcd, but important later).cd ~: Returns to the home directory of the current user (/home/sysadmin).
Concepts Learned:
- Directories in Linux are like folders in Windows/Mac.
- A path is a list of directories separated by
/. - Absolute paths always start with
/(e.g.,/home/sysadmin). - Relative paths use shortcuts:
..→ parent directory.→ current directory~→ home directory of the logged-in user
Insights:
- Learned that Linux always starts you in your home directory (
/home/sysadmin) when you log in assysadmin. - Understood the difference between absolute and relative paths.
- Practiced navigating between directories using
cdand shortcuts.
- Commands:
ls,ls -l,ls -lt,ls -lS,ls -lr,ls -lSr
What They Do:
ls: Lists files in the current directory (alphabetical by default).ls -l: Long listing with details (file type, permissions, hard link count, owner, group, size, timestamp, filename).ls -lt: Sorts by timestamp (newest first).ls -lS: Sorts by file size (largest first).ls -lr: Reverses the order (alphabetical Z→A).ls -lSr: Sorts by size, smallest first.
Concepts Learned:
- File types:
- Permissions: Control read (
r), write (w), and execute (x) access for owner, group, and others. - Ownership: Split into user (creator/owner) and group.
- Hard link count: Number of directory entries pointing to a file (directories always have at least 2).
- File size: Shown in bytes; directories often show multiples of the filesystem block size (commonly 4096 bytes).
- Timestamps: Show last modification time.
- Symbolic links: Display with
->pointing to the target file.
Insights:
/var/logis a great practice directory because it contains many file types, different owners/groups, and varied sizes/timestamps.- Sorting options (
-t,-S,-r) make it easier to analyze files by time, size, or order. - Learned that a directory’s size reflects the space used to store its entries, not the total size of files inside.
Why /var/log is used:
- Contains a wide variety of files (regular files, directories, links).
ls -l /var/logwill list every file and directory entry, even if they have different owners, groups, or permissions.- You can always see the files and their details (permissions, ownership, size, timestamps), but you may not be able to open or read all of them without the right privileges (e.g., some require root).
- Safe to explore with
lsbecause you’re only listing, not modifying. - Logs reflect real system activity, so sorting and listing options show meaningful differences.
- Other directories (like
/home) may not have enough variety to demonstrate permissions, ownership, and sorting.
📦 Block Size Visualization
Even a tiny file (like 1 byte) still consumes a full filesystem block (commonly 4096 bytes).
This is why directories often show sizes like 4096 or 8192 — it reflects the space used for their entries, not the total size of files inside.
- Commands:
su,su -,su -l,su --login,exit,sudo,sudo -u
What They Do:
su: Switches to another user account (default is root) by opening a new shell.su -,su -l,su --login: Starts a login shell with the new user’s environment fully configured.exit: Logs out of the current shell and returns to the previous user.sudo: Executes a single command with administrative privileges (without switching users).sudo -u [user] [command]: Executes a command as a specified user.
Concepts Learned:
- Administrative access is required for sensitive commands (e.g., system-level operations).
suvssudo:suopens a new shell as another user (usually root).sudoruns a single command as another user (default is root), without switching shells.
- Login shell options (
su -,su --login) ensure the new shell uses the target user’s environment. - Password security: Passwords (like
netlab123) are required but not shown when typed. - Prompt change: When using
su, the shell prompt changes to reflect the new user (e.g.,root@localhost). - Steam Locomotive (
sl) command was used to demonstrate permission control:- Fails when run as
sysadmin. - Succeeds when run as
rootviasuorsudo.
- Fails when run as
Insights:
- Switching users with
sugives full root access, which can be risky if not handled carefully. - Using
sudois safer for one-off commands—it limits the scope of elevated access. - Learned how to verify which user is active based on the shell prompt.
- Practiced using
exitto safely return to the original user.
- Commands:
cd,ls -l
What They Do:
cd ~/Documents: Navigates to the Documents folder in the home directory.ls -l hello.sh: Displays file details including type, permissions, owner, group, size, and timestamp.
Concepts Learned:
- File types:
-for regular files,dfor directories. - Permissions are grouped into Owner, Group, and Others—each with
r(read),w(write),x(execute). - Only one permission set applies based on your relationship to the file.
- Ownership fields show who owns the file and which group it belongs to.
Insights:
- Permissions affect how users interact with files and directories.
- Example:
-r--rw-rwxmeans the owner has read-only access, while others have more. - Owner permissions take precedence—even if the owner is in the group.
- Commands:
chmod,ls -l,./hello.sh
What They Do:
chmod u+x hello.sh: Adds execute permission for the user owner of the file.ls -l hello.sh: Verifies permission changes../hello.sh: Executes the script from the current directory.
Concepts Learned:
- chmod stands for “change mode” (not “change permission”) because permissions were historically called modes of access.
- Symbolic method of
chmoduses:u,g,o,ato target user, group, others, or all.+,-,=to add, remove, or set exact permissions.r,w,xfor read, write, and execute.
- Only the file owner or root can change permissions.
- Without execute permission, a script like
hello.shcannot be run—even if readable. - Adding
xfor the user owner enables script execution.
Insights:
- Using
chmod u+xis a safe way to grant execution rights without affecting group or others. ./hello.shruns the script from the current directory—this avoids relying on the system’s PATH.- After permission is granted, the script runs successfully and prints “Hello World!”
Commands: chown, sudo, ls -l, ./hello.sh
What They Do:
chown [OWNER] FILE: Changes the user owner of a file (requiressudo).sudo chown root hello.sh: Transfers ownership ofhello.shto root.ls -l hello.sh: Verifies ownership change.sudo ./hello.sh: Executes the script as root since only root has execute permission.
Insights:
- Only root can change file ownership.
- After ownership changes, permissions must be reassessed—execution may fail if the new owner is the only one with
xpermission. - Using
sudoallows execution under root privileges.
Commands: cat, head, tail
What They Do:
cat [FILE]: Displays the entire file—best for small files.head [FILE]: Shows the first 10 lines.tail [FILE]: Shows the last 10 lines.head -n [number] [FILE]: Views a specific number of lines from the top.tail -n [number] [FILE]: Views a specific number of lines from the bottom.
Insights:
- Use
catfor quick checks. - Use
headandtailfor large or frequently updated files. -noption customizes output length for better control.
Commands: cp, diff, ls
What They Do:
cp [SOURCE] [DESTINATION]: Copies a file from one location to another.cp /etc/passwd .: Copies/etc/passwdinto the current directory (.= current directory).cp /etc/passwd passwd_backup: Creates a copy namedpasswd_backupin the current directory.ls: Lists files to confirm the copy exists.
Commands: diff
What They Do:
diff FILE1 FILE2: Compares two files line by line.diff /etc/passwd passwd_backup: Confirms whether the backup is identical to the original.- If there's no output, the files are identical.
- If there is output, it shows the differences line by line.
To successfully copy a file:
- ✅ Read permission on the source file.
- ✅ Execute permission on the source directory.
- ✅ Write + execute permission on the destination directory.
Common writable directories:
- Your home directory (
~/) /tmp— a shared space for temporary files
- Create backups before editing.
- Transfer files to external devices.
- Use existing files as templates for new ones.
- Compare versions using
diff.
Commands: mv, ls, cd
What They Do:
mv [SOURCE] [DESTINATION]: Moves a file from one location to another.mv people.csv Work: Movespeople.csvinto theWorkdirectory.mv numbers.txt letters.txt alpha.txt School: Moves multiple files into theSchooldirectory.mv animals.txt zoo.txt: Renamesanimals.txttozoo.txtwithin the same directory.ls: Lists files to confirm the move or rename.cd ~/Documents: Navigates to the working directory.
Commands: ls
What They Do:
ls Work: Confirms thatpeople.csvwas successfully moved.ls School: Verifies that multiple files were moved.ls: Shows thatanimals.txtwas renamed tozoo.txt.
To successfully move a file:
- ✅ Write + execute permission on the source directory.
- ✅ Write + execute permission on the destination directory.
Why It Matters:
- Without execute permission, you can’t access the directory.
- Without write permission, you can’t modify its contents (e.g., move or rename files).
- Organize files into folders (e.g., move documents into
WorkorSchool). - Rename files for clarity or versioning.
- Clean up clutter by relocating files.
- Batch move multiple files with a single command.
Commands: rm, ls, cd, -r, -R
What They Do:
rm [OPTIONS] FILE: Removes files or directories.rm filename: Deletes a regular file.rm -r directory: Recursively removes a directory and all its contents.cd ~/Documents: Changes into theDocumentsdirectory.ls: Lists files to verify removal.
Important:
Unlike desktop systems, Linux does not have a “trash can.”
When you delete a file with rm, it is permanently removed.
🔐 Permission Requirements
- To successfully delete a file:
- ✅ Write + execute permission on the directory containing the file.
Example:
sudo rm -rf /Impact & Recovery Impact:
- System files, user data, and boot components are wiped.
- Even basic tools needed for recovery are deleted.
Why Recovery Is Hard:
- OS becomes unbootable.
- No shell or package manager remains.
- Recovery requires a full backup or clean reinstall.
How to Protect Yourself
- Back up files regularly.
- Use safer deletion:
rm -i filename- Avoid
sudowith destructive commands. - Lock critical files:
chattr +i filenameCommands: grep, cd, cp, cat
What They Do:
grep [OPTIONS] PATTERN [FILE]: Searches text and displays lines matching a pattern.cd ~/Documents: Changes into theDocumentsdirectory.cp /etc/passwd .: Copies the/etc/passwdfile to the current directory.cat filename: Displays the contents of a file.
Example:
cd ~/Documents
cp /etc/passwd .
grep sysadmin passwdOutput:
sysadmin:x:1001:1001:System Administrator,,,,:/home/sysadmin:/bin/bash
This line is the /etc/passwd entry for the sysadmin user.
Regular expressions enhance search capability in grep.
Basic Regex Characters:
| Character | Meaning |
|---|---|
. |
Any single character |
[ ] |
Any one specified character |
[^ ] |
Any one not specified character |
* |
Zero or more of the previous character |
^ |
Match pattern at the beginning of a line |
$ |
Match pattern at the end of a line |
Extended Regex Characters (use grep -E or egrep):
| Character | Meaning | |
|---|---|---|
+ |
One or more of the previous pattern | |
? |
The preceding pattern is optional | |
{ } |
Specify minimum, maximum, or exact matches | |
| ` | ` | Logical OR |
( ) |
Group expressions |
Search for a literal pattern:
grep sysadmin passwdAnchor Characters:
grep '^root' /etc/passwd # Match lines starting with "root"
grep 'r$' alpha-first.txt # Match lines ending with "r"Match a single character (.):
grep 'r..f' red.txtMatches: reef, roof
Match character ranges ([]):
grep '[0-9]' profile.txtMatches lines containing numbers.
Negate characters ([^ ]):
grep '[^0-9]' profile.txtMatches lines with non-numeric characters.
Match repeated characters (*):
grep 're*d' red.txtMatches: red, reed, reeed
Multiple options with ranges:
grep 'r[oe]*d' red.txtMatches: red, rod, reed
If no file is provided, grep reads from standard input:
grep patternType text and press Ctrl + D to end input.
cd ~Summary:
grepfilters and searches for text patterns efficiently.- Regular expressions allow complex searches.
- Use quotes (
' ') to protect patterns from shell interpretation.
Command: shutdown [OPTIONS] TIME [MESSAGE]
Purpose:
Safely brings the system down while notifying all logged-in users and preventing new logins before shutdown.
-
Switch to the root account:
su -
(Password: netlab123) -
Run an immediate shutdown:
shutdown nowOutput Example:
The system is going down for maintenance NOW! -
Schedule a shutdown:
shutdown +5→ in 5 minutesshutdown 01:30→ at 1:30 AMshutdown now→ immediately
-
Add a custom message:
shutdown +1 "Goodbye World!"
date → displays current system time (often in UTC).
Example: Sat Oct 3 22:15:58 UTC 2020
- Requires root privileges
- Accepts time formats:
now,+minutes, orhh:mm - Optionally includes a broadcast message
- Safely stops or reboots the system
Commands: ifconfig, ping, iwconfig
Purpose:
View and test network connections, IP addresses, and interface activity.
-
ifconfig→ Displays active network interfaces and configuration.- Example:
eth0with IPv4192.168.1.2means the interface is active (UP). lo(loopback) is used for internal network communication (address127.0.0.1).
- Example:
-
iwconfig→ Similar toifconfig, but for wireless interfaces. -
ping [IP or HOSTNAME]→ Tests connectivity by sending network packets.ping -c 4 192.168.1.2→ Sends 4 packets to the target.- Successful replies confirm network reachability.
- “Destination Host Unreachable” means no response.
- Use
Ctrl + Cto stop continuous ping tests. - Ping may fail if a system or network blocks ICMP for security.
- You can also ping domain names (e.g.,
ping yahoo.com) to verify DNS resolution.
Use exit to return to the normal user shell after finishing tests.
Command: ps [OPTIONS]
Purpose:
Displays active processes on the system, showing what’s running and under which user.
-
ps→ Shows processes running in the current terminal.
Example output includes:- PID – Process ID (unique identifier)
- TTY – Terminal associated with the process
- TIME – Total CPU time used
- CMD – Command that started the process
-
ps -e→ Displays all processes on the system. -
ps -ef→ Displays detailed information about each process, including parent processes and command options.
- Each command executed creates a process that runs with the user’s privileges.
- Regular users can only control their own processes.
- The
rootuser can manage or stop any process. - Look for the
pscommand itself listed in the output — it’s included because it’s a running process too.
Commands: apt-get, apt-cache, dpkg, sudo
Purpose:
Manage software installation, updates, and removal on Debian-based systems like Ubuntu.
-
Package Management:
Handles installing, updating, and removing software efficiently.
Ubuntu uses the APT system, a front-end to dpkg. -
Administrative Access:
Most commands requiresudoprivileges (password:netlab123).
-
Update Package List:
sudo apt-get update
Refreshes the list of available packages. -
Search for Packages:
apt-cache search [keyword]
Example:apt-cache search cow→ finds the cowsay package. -
Install a Package:
sudo apt-get install cowsay -
Run Installed Program:
cowsay 'NDG Linux Unhatched'
🐄 → Outputs a talking ASCII cow with your message. -
Upgrade Installed Packages:
sudo apt-get upgrade
Updates all packages to their latest versions. -
Remove or Purge Packages:
sudo apt-get remove cowsay→ removes package but keeps configs.sudo apt-get purge cowsay→ completely removes package and configs.
apt-get installautomatically updates a package if a newer version exists.- Always run
apt-get updatebefore installing or upgrading. - The
dpkgcommand handles low-level package operations but is rarely used directly.
Commands: passwd, su, exit
Purpose:
Manage and update user passwords. Regular users can change their own passwords, while the root user can change any account’s password.
-
Password Update:
passwdprompts for the current password and a new one (entered twice).
No characters appear while typing for security reasons. -
View Password Status:
passwd -S [username]
Displays password details such as status, last change date, and expiry info.
| Field | Example | Meaning |
|---|---|---|
| User Name | sysadmin | Account name |
| Password Status | P | P = active, L = locked, NP = no password |
| Change Date | 12/20/2017 | Date password was last changed |
| Minimum | 0 | Days before user can change password again |
| Maximum | 99999 | Days before password expires |
| Warn | 7 | Days before expiry warning |
| Inactive | -1 | Days account remains active after expiry |
-
Switch to Root:
su root(password:netlab123) -
Change Another User’s Password:
passwd [username] -
Exit Root Mode:
exit
Commands: >, >>, cat, echo, ls
Purpose:
Redirect command input and output streams to files or other destinations using I/O redirection.
-
I/O Redirection:
Changes the default input/output behavior of commands. -
File Descriptors:
Type Name Description STDIN (0) Standard Input What the command reads (keyboard input). STDOUT (1) Standard Output Normal output (shown in terminal). STDERR (2) Standard Error Error messages from failed commands.
-
Overwrite Output:
[COMMAND] > [FILE]
Redirects output to a file, overwriting existing content.
Example:
cat food.txt > newfile1.txt -
Append Output:
[COMMAND] >> [FILE]
Redirects output to a file, appending new content instead of overwriting.
Example:
echo "This food is good." >> newfile1.txt
-
View contents of a file:
cat food.txt -
Copy file output using redirection:
cat food.txt > newfile1.txt -
Add a line to a file:
echo "I like food." >> newfile1.txt -
Check updated content:
cat newfile1.txt
- Using
>overwrites existing file content. - Use
>>to append without deleting existing data. - You must have write permissions to redirect output to a file.
- Useful for saving command results or logs.
Commands: vi, vim, :w, :q, :q!, :wq, ZZ
Purpose:
Create and edit text files using the vi/vim text editor — available on all Linux systems.
-
vi (Visual Editor):
Universal text editor in Linux and UNIX.- Always available on any system.
- Works in both CLI and GUI.
- Modern versions use vim (vi improved).
-
Pronunciation:
“vee-eye,” not “vye.”
(vistands for visual, but is pronounced as letters.)
| Mode | Description | Enter / Exit |
|---|---|---|
| Command Mode | Navigate and execute actions | Default mode; press Esc to return |
| Insert Mode | Add or modify text | i, a, o, etc. |
| Ex Mode | File operations and settings | Start with : |
| Key | Action |
|---|---|
h |
Move left |
j |
Move down |
k |
Move up |
l |
Move right |
w |
Forward one word |
b |
Back one word |
^ |
Start of line |
$ |
End of line |
G |
Last line |
nG |
Go to line n |
Ctrl+G |
Show current line number |
(Arrow keys also work.)
| Action | Command | Description |
|---|---|---|
| Delete | d, dd, dw, d3w |
Remove text (cuts to buffer) |
| Change | c, cc, cw |
Delete + enter Insert mode |
| Yank (Copy) | y, yy, yw |
Copy text to buffer |
| Put (Paste) | p / P |
Paste after / before cursor |
| Command | Description |
|---|---|
/text |
Search forward |
?text |
Search backward |
n / N |
Next / previous match |
| Command | Description |
|---|---|
i |
Insert before cursor |
I |
Insert at line start |
a |
Append after cursor |
A |
Append at line end |
o |
New line below |
O |
New line above |
Press Esc to return to command mode.
| Command | Purpose |
|---|---|
:w |
Save changes |
:w filename |
Save as new file |
:q |
Quit (only if no changes) |
:q! |
Quit without saving |
:wq or ZZ |
Save and quit |
:e filename |
Open another file |
:1 or :n |
Go to line n |
- Add
!to force an action (e.g.,:q!to quit without saving). ZZ= save and quit (same as:wq).vimadds syntax highlighting, undo, and more features.
-
NASA Uses Linux 🚀
The International Space Station runs on Linux for stability and reliability. -
Curiosity Rover on Mars 🔭
The Mars rover also relies on Linux to carry out its mission on the Red Planet. -
Why Linux?
NASA migrated key functions from Windows to Linux because they needed an operating system that was:- Stable
- Reliable
- Open-source and customizable
Linux isn’t just powering servers and desktops — it’s literally running in outer space!
- Command Used:
aptitude moo - What It Does: Displays a humorous message—“There are no Easter Eggs in this program.”
- Insight: This is a hidden joke built into the
aptitudepackage manager. If you keep adding-vflags (likeaptitude -v moo,aptitude -vv moo), you’ll uncover more playful responses.
Each lab includes:
- A brief summary of what was learned
- Key commands used
- Screenshots for visual reference





































