Exercise 01 — Introduction to Linux¶
Navigation: Exercises Index | Next → Exercise 02 Note: 01 — Introduction to Linux
Before You Start¶
Read Note 01 first, then come back here.
These exercises are about exploration, not memorization. The goal is to get comfortable typing commands and reading output. Every command here is safe — nothing you do in this exercise can break anything.
Open a terminal and let's begin.
Exercise 1.1 — Find Out Who and Where You Are¶
These are the first commands any Linux user runs on a new machine.
Step 1: Type this and press Enter:
You should see your username printed. Something like:
Step 2: Now find out the machine's name:
Expected output (yours will differ):
Step 3: Find out which Linux distro you're running:
This prints the contents of a file. Look for the NAME and VERSION lines. Expected output (example):
What is
cat?catreads a file and prints it to the screen. You'll use it constantly./etc/os-releaseis a plain text file that your distro fills in with its own details.
Step 4: Check the kernel version:
Example output:
Step 5: See everything at once:
Example output:
This shows: OS name, hostname, kernel version, build date, architecture, and OS type — all in one line.
Reflect: Write down your answers: - Distro name and version: __ - Kernel version: __ - Hostname: _____
Exercise 1.2 — Check System Time and Uptime¶
Step 1: Check the current date and time:
Example output:
Step 2: Format the date as YYYY-MM-DD:
The +%Y-%m-%d part is a format string. %Y = 4-digit year, %m = month, %d = day.
Expected output:
Step 3: See how long the system has been running:
Example output:
Questions to answer: - How long has your system been running? - What is the load average for the last 1 minute? - How many users are currently logged in?
Exercise 1.3 — Getting Help Without Google¶
One of the most important skills in Linux is knowing how to get help from the terminal itself.
Step 1: Open the manual for ls:
The manual page opens. Use the arrow keys to scroll. Press q to quit.
While you're in the man page, find the answer to: What does the -a flag do?
Step 2: Get a quick one-line summary of a command:
Expected output:
ls (1) - list directory contents
cp (1) - copy files and directories
rm (1) - remove files or directories
Step 3: Search for commands by keyword:
This searches all man page descriptions. It lists every command related to "disk usage".
Example output:
Step 4: Use the quick --help flag:
This prints a short summary without opening the full man page. Look for the -p flag description.
Questions:
- What does mkdir -p do? (hint: you just found it)
- What is the difference between man and --help?
Exercise 1.4 — Explore Your Environment¶
Linux stores settings in environment variables — named values that programs can read.
Step 1: See what shell you're using:
$SHELL is an environment variable. The $ prefix tells bash "give me the value of this variable". Expected output:
Step 2: See your home directory:
Expected output:
Step 3: See the PATH:
Example output:
PATH is a list of directories (separated by :) where Linux looks for programs when you type a command. When you type ls, Linux searches each directory in PATH until it finds a program called ls.
Step 4: List all environment variables:
This prints a long list. Don't worry about understanding all of them — just notice that they're all in the format NAME=value.
Exercise 1.5 — Basic Terminal Skills¶
Step 1: Print a message:
Step 2: Use command substitution — run a command inside another command:
The $(...) part runs date +%A first (which prints the day of the week), then echo prints the result. Expected output:
Step 3: Run two commands on one line with &&:
&& means "run the second command only if the first one succeeded". Expected output:
Step 4: View your command history:
Linux remembers every command you've typed. This is very useful for recalling a long command you ran earlier. To re-run a command from history, type ! followed by the line number. For example, !42 runs command number 42 again.
Step 5: Clear the terminal:
Or press Ctrl + L. Your previous commands are not deleted — scroll up to see them.
Challenge — Test Yourself¶
Try to answer these without looking at the notes. Then check your answers.
- What is the difference between the Linux kernel and a distribution?
- What does
uname -rprint? - You want to find commands related to the word "network". What command would you run?
- What does the
$at the end of your prompt mean? What does#mean? - What does
exit code 0mean?
Answers: 1. The kernel is the core OS that talks to hardware. A distribution bundles the kernel with software, a package manager, and tools into a usable system. 2. The current Linux kernel version number. 3.
apropos network4.$= regular user,#= root (administrator) 5. The command succeeded (zero means success in Linux).
Navigation: Exercises Index | Next → Exercise 02 Note: 01 — Introduction to Linux