Getting Started with Linux

LinuxBeginner
Practice Now

Introduction

The terminal is a text-based way to communicate with Linux. You type a command at the prompt, press Enter, and Linux prints output or changes something in the system. At first, the prompt may look unfamiliar, but every interaction follows this same simple pattern.

In this first lab, you will run safe commands that print text, show the date, display a calendar, calculate numbers, and create text art. You will also save a few results under /home/labex/project/first-commands so you can distinguish temporary terminal output from information stored in a file.

Run Your First Command

Tip: If you are new to LabEx, we recommend starting with the Linux Learning Path.

In this step, you will learn how to recognize the terminal prompt, run a command, and read its output.

The blinking cursor appears after a prompt. The prompt tells you that the shell is ready for a command; you do not type the prompt itself. Start by moving into the workspace prepared for this lab:

cd /home/labex/project/first-commands

Type the command at the blinking cursor in the Terminal tab

cd means “change directory.” A directory is Linux's name for a folder. Later labs explore directories in detail; for now, this command gives all your saved results one predictable home.

Run pwd, which means “print working directory”:

pwd

The output should be the directory you just entered:

/home/labex/project/first-commands

Now use echo to ask the shell to print text:

echo "Hello, Linux"

You should see:

Hello, Linux

The quotation marks keep the words together as one text value. Now save the greeting in a file. The > symbol is called output redirection: the shell creates the file named on its right and sends the command's normal output there instead of displaying it. If the file already exists, > replaces its previous contents, so check the destination before using it with important data:

echo "Hello, Linux" > greeting.txt

This command prints nothing on screen because the output went to greeting.txt.

Read the saved file with cat:

cat greeting.txt

Seeing Hello, Linux again proves that the text now exists in greeting.txt, not only on the terminal screen.

Read Dates and Calendars

In this step, you will ask Linux for time information and learn that command output can change with the environment.

Run date with no options:

date

Linux prints the current weekday, date, time, time zone, and year. The exact value changes every second, so your output will differ from examples you may see elsewhere.

Commands often accept options that change their output. A date format beginning with + lets you choose stable fields. %F means the ISO date format YYYY-MM-DD:

date +%F

Save today's ISO date. As in the previous step, > redirects the output into a file and replaces that file if it already exists:

date +%F > today.txt

The cal command displays the current month as a calendar:

cal

The month and weekday layout depend on the current date and locale. Save that output too:

cal > calendar.txt

The > symbol sends output to a file instead of the screen. Display the saved calendar to confirm it was written:

cat calendar.txt

You will learn redirection thoroughly later. For now, remember that terminal output can either be viewed immediately or saved for later use.

Calculate with Expr

In this step, you will use expr for integer arithmetic and observe why spaces matter in shell commands.

The shell separates a command line into words at spaces. expr expects the first number, operator, and second number as separate arguments. Add two numbers:

expr 5 + 3

The result is:

8

Try subtraction and division:

expr 20 - 7
expr 24 / 6

Multiplication needs one extra detail. The shell treats * as a filename wildcard, so escape it with a backslash to pass a literal multiplication operator to expr:

expr 6 \* 7

Save the multiplication result in a file. This uses the same output redirection you practiced earlier, so the terminal stays quiet while calculation.txt receives 42:

expr 6 \* 7 > calculation.txt

Display the file:

cat calculation.txt

You should see 42. Keeping this first exercise simple lets you focus on the command structure: command name, space-separated arguments, and optional output destination.

Turn Text into ASCII Art

In this step, you will use a command option to change how figlet formats text.

figlet builds large letters from ordinary terminal characters. Run it with a short word:

figlet "LabEx"

The output spans several lines. This is called ASCII art because it uses text characters rather than image pixels.

Many Linux options begin with -. For figlet, -f selects a font, and slant is the font name. Try it:

figlet -f slant "Linux"

Save the first design to a file:

figlet "LabEx" > labex-art.txt

Inspect the beginning of the saved art:

head labex-art.txt

head displays the first ten lines by default. You should see the same multi-line design that appeared in the terminal.

Reset a Busy Terminal

In this step, you will clear old output and distinguish screen cleanup from deleting files.

After several commands, the terminal can become visually crowded. Run:

clear

clear moves the old terminal output out of view. It does not remove commands, files, or directories. Most terminals also support Ctrl+L as a keyboard shortcut for the same visual cleanup.

Prove that your earlier files still exist by listing the workspace:

ls

You should still see greeting.txt, today.txt, calendar.txt, calculations.txt, and labex-art.txt.

Create a final marker after cleaning the screen:

echo "Terminal ready" > terminal-ready.txt

Display the marker to check it:

cat terminal-ready.txt

This final command reinforces an important idea: clearing the display changes only what you currently see, while files remain stored on disk.

Summary

You learned the terminal's basic interaction pattern: type a command, press Enter, and interpret the result. You practiced pwd, echo, date, cal, expr, figlet, and clear; used simple options; and saved output in files. You are now ready to apply these basics in a small terminal challenge before learning broader file operations.