Skip to main content

Lab 1.1 - Installation and First Use of Linux

Lab Objectives​

By the end of this lab, you will be able to:

  • Install Linux (Ubuntu/Debian or distribution of your choice)
  • Access the terminal
  • Use basic commands
  • Navigate the file system
  • Understand the basic structure of Linux

Estimated Duration​

30-45 minutes

Prerequisites​

  • Virtual machine (VirtualBox, VMware, Hyper-V) or physical machine
  • ISO image of a Linux distribution (Ubuntu recommended)
  • At least 20 GB of disk space
  • 2 GB of RAM minimum (4 GB recommended)

Option 1: Installation on Virtual Machine​

Step 1: Download Ubuntu​

# Download Ubuntu 24.04 Desktop from:
# https://ubuntu.com/download/desktop

# Or Ubuntu 24.04 Server (lighter):
# https://ubuntu.com/download/server

Step 2: Create the Virtual Machine​

  1. VirtualBox:

    • New virtual machine
    • Type: Linux, Version: Ubuntu (64-bit)
    • RAM: 2048 MB minimum
    • Hard disk: 20 GB minimum
  2. Configure the disk:

    • Select the downloaded Ubuntu ISO
    • Start the virtual machine

Step 3: Install Ubuntu​

  1. Choose the language: English
  2. Installation type: Normal installation
  3. Partitioning: Erase disk and install Ubuntu
  4. User: Create your user account
  5. Wait for the installation to complete

Step 4: Restart​

# After restarting, you should see the login screen
# Log in with your user account

Option 2: Use WSL (Windows)​

Step 1: Enable WSL​

# In PowerShell as administrator
wsl --install

# Or for a specific version
wsl --install -d Ubuntu

Step 2: Restart​

# Restart Windows after installation

Step 3: Configure Ubuntu​

# On first launch, create a user
# Enter a username and password

First Use of the Terminal​

Step 1: Open the Terminal​

Ubuntu Desktop:

  • Ctrl + Alt + T
  • Or search for "Terminal" in applications

WSL:

  • Open PowerShell or CMD
  • Type wsl or ubuntu

Step 2: Check the Environment​

# See the Linux version
uname -a

# See the distribution
lsb_release -a

# See the shell used
echo $SHELL

# See the current user
whoami

# See the current directory
pwd

Expected result:

Linux hostname 6.8.0-xx-generic #xx-Ubuntu SMP ...
Distributor ID: Ubuntu
Description: Ubuntu 24.04 LTS
Release: 24.04
Codename: noble

Practical Exercises​

Exercise 1: Basic Navigation​

# 1. View the contents of the current directory
ls

# 2. View hidden files too
ls -a

# 3. View details
ls -l

# 4. Go to the home directory
cd ~
# or
cd $HOME

# 5. View the full path
pwd

# 6. Return to the previous directory
cd -

# 7. Go to the root
cd /

# 8. View the structure
ls /

Exercise 2: Create Files and Directories​

# 1. Create a directory
mkdir my-first-lab

# 2. Go inside
cd my-first-lab

# 3. Create a text file
echo "Hello Linux!" > file1.txt

# 4. View the content
cat file1.txt

# 5. Create another file
touch file2.txt

# 6. View the files
ls -l

# 7. Create multiple directories
mkdir dir1 dir2 dir3

# 8. View the structure
tree
# If tree is not installed:
# sudo apt install tree

Exercise 3: Useful Commands​

# 1. View command help
man ls
# or
ls --help

# 2. View command history
history

# 3. Search in history
history | grep ls

# 4. Repeat the last command
!!

# 5. View running processes
ps aux

# 6. View disk usage
df -h

# 7. View memory usage
free -h

# 8. View system information
uname -a

Exercise 4: Text Editor​

# 1. Create a file with nano
nano my-file.txt

# 2. Write a few lines:
# - Line 1: Introduction to Linux
# - Line 2: First practical lab
# - Line 3: It's great!

# 3. Save: Ctrl+O, Enter
# 4. Exit: Ctrl+X

# 5. View the content
cat my-file.txt

# 6. Edit with vim (more advanced)
vim my-file.txt
# Press 'i' to insert
# Write text
# Press 'Esc' then ':wq' to save and exit

Verification​

Checklist​

Check that you can:

  • Open the terminal
  • Navigate directories (cd, ls, pwd)
  • Create files and directories (mkdir, touch, echo)
  • View file contents (cat, less)
  • Use help (man, --help)
  • Understand the basic structure (/, /home, /etc)

Final Test​

# Create this structure:
# ~/lab1/
# ├── file1.txt
# ├── file2.txt
# └── sub-dir/
# └── file3.txt

mkdir -p ~/lab1/sub-dir
cd ~/lab1
echo "File 1" > file1.txt
echo "File 2" > file2.txt
echo "File 3" > sub-dir/file3.txt

# Verify
tree ~/lab1
# or
ls -R ~/lab1

Troubleshooting​

Problem: Command not found​

# Check that the command exists
which command-name

# Install if necessary
sudo apt update
sudo apt install package-name

Problem: Permission denied​

# Check permissions
ls -l file

# If needed, use sudo (with caution!)
sudo command

Problem: WSL does not start​

# Check status
wsl --status

# Restart WSL
wsl --shutdown
wsl

Next Steps​

  • Chapter 1.2: Why Linux?
  • Chapter 1.3: History and Evolution
  • Next Lab: Advanced Terminal Practices

Resources​


Lab created on: December 2024