Welcome, Linux Explorer!
These projects are designed to give you hands-on experience with the core concepts of Linux. Start with the basics to build your confidence before moving on to the projects.
π₯οΈ Getting Started: Setting Up Your Linux Environment
Before diving into Linux commands and projects, youβll need a Linux system to experiment with. The easiest way to do this on a Windows computer is by using VirtualBox to run Ubuntu inside a virtual machine.
Your Challenge
Download and install VirtualBox on your Windows machine, then create a new virtual machine and install Ubuntu. There are many beginner-friendly guides and videos online to help you through the process. Rather than following only one tutorial step by step, try to explore, experiment, and resolve issues on your own. This is part of learning how Linux users think and solve problems.
Questions to Explore
- Which version of Ubuntu should I install β Desktop or Server?
- How much memory (RAM) and disk space should I allocate to my virtual machine?
- What should I do if Ubuntu doesnβt start properly the first time?
Use these questions as opportunities to search online, read community forums, and test different approaches. Developing this problem-solving habit will help you far beyond this project.
Tip
Once you have Ubuntu running, take a few minutes to look around β open the terminal, browse the file explorer, and get comfortable with the environment. Youβll be using it throughout all the upcoming projects.
π‘ Linux Fundamentals
Before you start, it's helpful to understand a few key concepts that form the basis of a Linux system.
What is Linux?
At its heart, Linux is an operating system, just like Windows or macOS. It's the software that manages all the hardware and resources on your computer. Linux is a powerful and flexible system used in everything from smartphones and servers to supercomputers.
The Command Line, Terminal & Bash
Instead of clicking icons, you use a command line to tell the computer what to do. The terminal is the program that gives you a window to the command line. When you type a command into the terminal, a program called a shell processes it. Bash (Bourne Again SHell) is the most common shell on Linux. In simple terms: you use the terminal to access the command line, which is interpreted by the Bash shell.
The File System Hierarchy
Linux organizes all files and directories in a single tree-like structure, starting from the root directory, which is represented by a single forward slash
(/
). This structure is consistent across all Linux systems, making it easy to navigate.
Linux Directory Tree (Simplified)
/ (root) β The top-level directory of the Linux filesystem
βββ bin β Essential user binaries (commands like ls, cp, mv)
βββ boot β Boot loader files, kernel, etc
βββ dev β Device files (representing disks, USBs, etc.)
βββ etc β System configuration files and scripts
βββ home β User home directories
β βββ user1
β β βββ Desktop
β β βββ Documents
β β βββ Downloads
β β βββ Pictures
β βββ user2
β βββ Desktop
β βββ Documents
β βββ Downloads
β βββ Pictures
βββ lib β Libraries and kernel modules for essential programs
βββ media β Mount points for removable media (USB drives, CDs, etc)
βββ opt β Optional or third-party software packages
βββ root β Home directory of the root (administrator) user
βββ run β Runtime data (process IDs, sockets, temporary files)
βββ sbin β Essential system binaries (for administration)
βββ srv β Data for system services (e.g., web or FTP servers)
βββ sys β Virtual filesystem with information about devices/drivers
βββ tmp β Temporary files (often cleared on reboot)
βββ usr β User programs, libraries, documentation, and utilities
β βββ bin β Non-essential user binaries
β βββ lib β Libraries for user programs
β βββ share β Shared resources like docs, icons, etc.
βββ var β Variable data (logs, mail, caches, databases, spool)
Linux vs Windows File Systems
Unlike Linux, which uses a single root directory (/
) for everything, Windows organizes files into separate drives (such as C:\
,
D:\
, etc.). Each drive has its own root, and directories are separated with a backslash (\
) instead of a forward slash (/
).
For example, your documents might be stored under C:\Users\YourName\Documents
in Windows, whereas on Linux they would be under /home/yourname/Documents
.
Another difference is that in Linux, everything is treated as a file (even hardware devices like USBs or disks), while in Windows, devices are usually represented with drive letters. This unified design in Linux makes scripting, automation, and system management more consistent.
π The Linux Command Line Sandbox
Before diving into the projects, let's get you comfortable with the most fundamental commands. Think of your home directory as a safe place to play and experiment. You can't break anything important here! π
Step 1: Where are you?
First, let's find out your current location in the file system and who you are. This is a common first step for any task.
pwd
: "Print Working Directory." It shows your exact location. It should be something like/home/your_username
.whoami
: Shows your current username.
pwd
whoami
Run these commands. What do you see? This is your base camp!
Step 2: Looking around
The ls
command is your flashlight in the dark. It lists the contents of a directory.
ls
: Lists the files and folders in your current directory.ls -l
: Lists contents in a "long" format, showing more details like permissions, owner, size, and date.ls -a
: Shows all files, including hidden ones (which start with a dot, like.bashrc
).ls -R
: Lists contents recursively, meaning it shows all files and subdirectories inside folders.ls -lh
: Long format with sizes in "human-readable" form (e.g., KB, MB).ls -lt
: Long format sorted by modification time (newest files first).
ls
ls -l
ls -a
ls -R
ls -lh
ls -lt
Practice using these flags and notice the differences:
- The first character in ls -l
output shows d
for directories and -
for files.
- Try ls -R
in a folder with subdirectories. What happens?
- How does ls -lt
help you find recently modified files?
Step 3: Creating and moving things
Now, let's build something. You'll create a folder and then some files inside it, and practice moving them around.
mkdir
: "Make directory." Creates a new folder.cd
: "Change directory." Moves you into a different folder.touch
: Creates a new, empty file.mv
: "Move." Moves files or directories to another location. It can also be used to rename files or folders.
# Create a practice folder and move into it
mkdir my_practice
cd my_practice
# Create two files
touch file1.txt file2.txt
ls
# Move file1.txt into a new folder
mkdir subfolder
mv file1.txt subfolder/
ls
ls subfolder
# Rename file2.txt to renamed.txt
mv file2.txt renamed.txt
ls
Try it out:
- What happened to file1.txt
after using mv file1.txt subfolder/
?
- Notice that mv
is also used for renaming. How does it differ from moving?
- Can you create another file and move it into subfolder
as practice?
Step 4: Cleaning up
When you're done experimenting, you can remove files and directories.
rm
: "Remove." Deletes a file.rmdir
: "Remove directory." Deletes an empty folder.rm -r
: "Remove recursively." Deletes a directory and everything inside it (all files and subdirectories).
rm file1.txt
ls
cd ..
rmdir my_practice
# Example with rm -r
rm -r my_practice
After running these commands, can you explain what happened at each step?
What does cd ..
do?
What happens if you try to run rmdir my_practice
without first deleting file2.txt
?
Why is rm -r my_practice
able to remove the whole folder even if it still contains files?
Step 5: Putting it all together
Now, try a quick challenge. Without looking at the previous steps, try to:
- Create a new directory named
linux_fun
. - Go inside that directory.
- Create three empty files named
notes.md
,report.pdf
, andimage.png
. - List all the files to confirm they were created.
- Delete all the files and the directory.
If you can do this from memory, you're ready for the projects! You've mastered the basics. If not, don't worryβjust revisit the steps above until you feel confident.
π Project 1: Automated File Organizer
Learn the fundamentals of directory and file manipulation. This project involves writing a simple script to organize files into folders based on their type.
Concepts you'll learn: whoami
(check your current user), pwd
(print current directory), ls
(list files), mkdir
(make directories), touch
(create empty files), mv
(move files), chmod
(change permissions), and the basics of shell scripting.
-
Check your environment.
Before creating files and directories, itβs useful to confirm who you are and where you are in the system.
whoami
: shows your current user.pwd
: prints the βpresent working directoryβ (the folder you are currently in).ls
: lists the files and folders in your current location.
whoami pwd ls
This helps you verify your current user, the folder youβre working in, and what files are there before starting.
-
Create a project directory.
Directories (or βfoldersβ) help keep files organized. The command below shows one way to do it in a single line, and then an alternative step-by-step method.
Method 1: One-liner with
&&
mkdir file_sorter && cd file_sorter
Here,
mkdir
(βmake directoryβ) creates the folder, andcd
(βchange directoryβ) moves into it. The&&
means βonly run the second command if the first succeeds.βMethod 2: Step by step
mkdir file_sorter cd file_sorter
This does the same thing, but separates the steps so you can clearly see the directory being created first, then moving into it.
Tip: Run
pwd
again to confirm that you are now insidefile_sorter
. -
Create some dummy files.
The
touch
command creates new, empty files. These act as placeholders so we can test our script later.touch report.doc notes.txt image.jpg data.csv archive.zip presentation.ppt
Check your files with
ls
. You should see the six files you just created. -
Create the script file.
Scripts are just text files containing commands to be executed in order. Use a text editor like
nano
orvim
to create one.nano organize_files.sh
-
Add the script content.
This script creates folders and moves files into them based on their extension.
mkdir -p
: creates directories (the-p
ensures no error if they already exist).mv
: moves files into the correct folder.ls -R
: lists files recursively, showing the new structure.
Follow these steps carefully to use
nano
if you are new:- After running
nano organize_files.sh
, your terminal opens a blank editor. - Use the keyboard to type or paste the script content exactly as shown below.
- To save your work:
- Press
Ctrl + O
(the letter O, not zero) to write out the file. - Press
Enter
to confirm the file name (organize_files.sh
).
- Press
- To exit
nano
, pressCtrl + X
. This closes the editor and returns you to the terminal.
#!/bin/bash # A simple script to organize files echo "Creating directories..." mkdir -p Documents Pictures Spreadsheets Archives Presentations echo "Organizing files..." mv *.doc *.ppt Presentations/ mv *.txt Documents/ mv *.jpg Pictures/ mv *.csv Spreadsheets/ mv *.zip Archives/ echo "Done! Here is the new structure:" ls -R
After saving and exiting, your script is ready to be made executable and run.
-
Make the script executable.
By default, new files are just text. To run it as a program, you need to give it βexecuteβ permission using
chmod
.chmod +x organize_files.sh
-
Run your script!
Use
./
to run a script in the current folder../organize_files.sh
You should see messages as the script runs, ending with a list of your organized folders and files. Try running
ls
orpwd
afterwards to confirm your results.
π Project 2: Permissions Manager
Linux permissions determine who can read, write, or execute files and directories. By mastering this, youβll understand how collaboration and security are enforced in Linux systems.
Concepts you'll learn: useradd
, groupadd
, chown
, chmod
, user/group ownership, octal vs. symbolic permissions. (Note: most commands here require sudo
).
-
Create a new group. This group will contain your project members.
First use this command to display the current content of the /etc/group file on your Linux system. It will show all current groups:
cat /etc/group
Then, this command will create a new group called developers on your Linux system:
sudo groupadd developers
-
Create two new users. Alice (a developer) and Bob (a read-only user).
First, run this command to print the list of all the current user accounts on your Linux system:
getent passwd
Then, run these two commands to create the two required user accounts:
sudo useradd -m -g developers -s /bin/bash alice sudo useradd -m -s /bin/bash bob
Both alice and bob were created with their own home directories (-m), login shells set to Bash (-s /bin/bash), with aliceβs primary group explicitly set to developers (-g developers) while bob was assigned a private group named after himself by default
-
Create a shared project directory.
sudo mkdir /srv/project_alpha
-
Set ownership. Assign
root
as the owner anddevelopers
as the group.sudo chown root:developers /srv/project_alpha
-
Understand Linux file permissions (numbers & symbols).
Every file or directory in Linux has three sets of permissions: owner (user), group, and others. Each set can have three rights:
r
(read = 4) β view a file, or list directory contentsw
(write = 2) β modify, create, or delete filesx
(execute = 1) β run a file, or enter a directory
These numbers are added together to form a permission value for each category:
Value Calculation Permissions 7 4+2+1 rwx β full access 6 4+2 rw- β read & write 5 4+1 r-x β read & execute 4 4 r-- β read only 0 none --- β no access Example:
755
= 7 (owner: rwx), 5 (group: r-x), 5 (others: r-x). -
Set permissions for a shared project folder.
By default, a new directory like
/srv/project_alpha
is owned by root and not writable by normal users. To allow both thedevelopers
group and the owner to fully manage it, while giving others read-only access, run:sudo chmod 775 /srv/project_alpha
β
775
= owner (rwx), group (rwx), others (r-x)
β755
= owner full, group & others read-only (developers couldnβt write)
β770
= owner & group full, others blocked completely
β700
= private folder, only the owner can access -
Alternative syntax (symbolic mode).
Instead of numbers, you can describe permissions with letters:
sudo chmod u=rwx,g=rwx,o=rx /srv/project_alpha
u
= user/owner,g
= group,o
= others. Same as775
, but more descriptive. -
Test the permissions in practice.
To confirm that our permissions work, weβll switch users and try creating/reading files inside
/srv/project_alpha
. Thesu
command (substitute user) lets you temporarily become another user without logging out. Adding-
ensures you start a full login shell (with that userβs environment).# Switch to Alice (member of developers group) su - alice cd /srv/project_alpha touch dev_file.txt # β should work: Alice can write here # Switch to Bob (not in developers group by default) su - bob cd /srv/project_alpha touch readonly.txt # β should fail: Bob has only read/execute rights cat dev_file.txt # β should work: Bob can still read existing files
β Alice succeeds because she belongs to the
developers
group, which has full (rwx) access.
β Bob cannot create files since "others" only have read/execute (r-x) permission, but he can still open and view files.
β This test confirms that775
is correctly allowing collaboration for developers while limiting everyone else to read-only access.
β±οΈ Project 3: Process Control
Every program running on Linux is a process. Being able to start, find, monitor, and stop processes is a fundamental skill for troubleshooting and system administration.
Concepts you'll learn:
ps
(list processes),
grep
(filter output),
kill
(terminate processes),
backgrounding with &
.
-
Start a simple background process.
The command below runs
sleep 1000
, which tells the system to "do nothing" for 1000 seconds. Adding&
runs it in the background, so your terminal is free for other commands. Youβll see a job number in[1]
and the process ID (PID).sleep 1000 &
-
Find the process.
Use
ps aux
to list all processes. To avoid scrolling through hundreds of lines, pipe the output togrep sleep
, which filters only lines containing βsleepβ. In the output, the second column is the PIDβthe unique identifier of the process. Write it down.ps aux | grep sleep
β Expect to see a line like:
user 12345 ... sleep 1000
. Here,12345
is the PID. -
Terminate the process.
To stop the process, use
kill
followed by the PID you noted earlier. This sends a TERM signal, politely asking the process to exit. Replace[PID]
with the actual number.kill [PID]
β No output means the signal was sent successfully. If the process refuses to exit, you can use
kill -9 [PID]
to force it (use cautiously). -
Verify the process is gone.
Run the search command again. If the process terminated, you will no longer see your
sleep
entry. You may still see thegrep sleep
command itself, which is normalβit appears because it matches the word βsleepβ.ps aux | grep sleep
β Expect: your original
sleep 1000
process is gone. If it still shows up, double-check the PID and trykill
again.
π Project 4: The Log Investigator
Troubleshooting is a key skill. In this project, you'll run a script designed to fail, investigate the error logs, and then fix the bug.
Concepts you'll learn: Reading logs, standard error/output, I/O redirection (`>`), basic debugging.
-
Create the broken script. Create a file named
broken_script.sh
usingnano
.nano broken_script.sh
-
Add the script content. This script tries to list the contents of a directory that doesn't exist, which will cause an error.
#!/bin/bash # This script has a bug! echo "Starting backup process..." # Attempt to list files in a non-existent directory ls /non_existent_directory echo "Backup process finished."
-
Make the script executable.
chmod +x broken_script.sh
-
Run the script and redirect its output to a log file. This is the crucial part.
> script.log
sends the normal output (stdout) to the file, and2>&1
sends the error output (stderr) to the same place../broken_script.sh > script.log 2>&1
-
Investigate the log file. Use
cat
orless
to view the log file's contents.cat script.log
You will see the normal "Starting..." message, followed by an error like "ls: cannot access '/non_existent_directory': No such file or directory".
-
Fix the bug. The error message tells you the problem. Edit the script (
nano broken_script.sh
) and change/non_existent_directory
to a real directory, like/home
or.
(the current directory). -
Re-run and verify. Run the script again with redirection. This time, when you
cat script.log
, you should see no error message, only the success messages and the file listing. You've successfully debugged the script!
βοΈ Project 5: Service Management & Automation
In this project, youβll practice managing background services and automating tasks.
Services are essential for keeping applications running reliably, while automation ensures
repetitive jobs happen without manual input. By the end, youβll understand how to use
systemctl
for service management, journalctl
for logs,
and cron
for automation.
Concepts you'll learn: Managing services with systemctl
,
viewing logs with journalctl
, scheduling tasks with cron
,
and verifying service activity.
-
Create a logging script.
Youβll start by writing a simple script that generates log entries.
Open a file named
my_service.sh
usingnano
:nano my_service.sh
This script will simulate a background service by writing timestamps into a log file.
-
Add script content.
Paste the following into the file:
#!/bin/bash echo "This is a log entry from my_service.sh at $(date)" | sudo tee -a /var/log/my_service.log
Every time this script runs, it appends a new line with the current date and time into
/var/log/my_service.log
. -
Make the script executable.
Without this step, you wonβt be able to run the script directly.
chmod +x my_service.sh
-
Schedule the script with cron.
Cron is a time-based job scheduler. Youβll use it to run the script automatically every minute.
Open your crontab configuration:
crontab -e
Then add this line at the bottom (replace
your_username
with your actual username):* * * * * /home/your_username/my_service.sh
This means: run the script every minute, indefinitely.
-
Monitor the service activity.
Wait 2β3 minutes, then check if logs are being written:
cat /var/log/my_service.log
You should see multiple log entries with timestamps. To monitor system logs live, use:
journalctl -f
-f
makesjournalctl
behave liketail -f
, showing new log lines as they appear. -
Clean up.
Once youβve confirmed the automation works, remove the cron job to stop the script from running every minute:
crontab -r
This deletes your crontab entirely. If you want finer control, instead run
crontab -e
and just remove the specific line.
β
Expected Outcome:
After 2β3 minutes, your /var/log/my_service.log
file will contain multiple log entries created automatically by cron.
Youβll also have practiced service-like automation and learned how to monitor logs in real time.
π Project 6: Basic System Monitoring
Monitoring your system's resources is essential to troubleshoot performance issues and understand how your Linux system behaves. This project introduces tools for checking CPU, memory, and disk usage in real-time and via summary commands.
Concepts you'll learn: top
, htop
, df
, du
, and identifying high-resource processes.
-
Monitor running processes with
top
orhtop
.top
provides a real-time overview of running processes and resource usage. Focus on these key columns:- PID β Process ID, useful for managing processes.
- %CPU β CPU usage of each process.
- %MEM β Memory usage of each process.
Press
q
to exit. Alternatively,htop
offers a more interactive interface (use arrow keys to navigate,F10
to quit). If not installed, runsudo apt-get install htop
.top
β Expect: a live-updating list of processes, showing which programs are using the most CPU and memory.
-
Check disk usage.
Use
df
to see free space on disks anddu
to check how much space specific directories use.df -h
β "human-readable" output, showing sizes in MB/GB instead of bytes.du -sh /home/your_username
β total disk usage of your home directory.
df -h du -sh /home/your_username
β Expect:
df
shows disk partitions and free space;du
shows directory sizes, helping identify large folders. -
Put it all together: identify high-resource processes.
Open two terminal windows. In the first, run a CPU-intensive command like:
yes > /dev/null
This command continuously outputs "y" to
/dev/null
, consuming CPU. In the second terminal, runtop
orhtop
and observe which process uses the most CPU.β Expect: the
yes
process will appear at the top oftop
orhtop
sorted by CPU usage. PressCtrl+C
in the first terminal to stop it.
β Key Takeaways: You now know how to:
- Monitor real-time CPU and memory usage with
top
andhtop
. - Check available disk space and directory sizes with
df
anddu
. - Identify resource-hogging processes and respond accordingly.