Your First Linux Lab

LinuxLinuxBeginner
Practice Now

Introduction

Welcome to LabEx! This is your first lab, where you'll take your initial steps into the world of Linux. Don't worry if you're completely new to this - we'll guide you through every step.

In this lab, you'll learn how to:

  1. Use the classic "Hello, World!" program in Linux
  2. Understand and use basic Linux commands like whoami, id, and env
  3. Navigate the Linux terminal
  4. Install and use a simple system monitoring tool

These skills will form the foundation of your Linux journey. Let's get started!

Click the Continue button below to begin the lab.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/BasicSystemCommandsGroup(["`Basic System Commands`"]) linux(("`Linux`")) -.-> linux/PackagesandSoftwaresGroup(["`Packages and Softwares`"]) linux(("`Linux`")) -.-> linux/UserandGroupManagementGroup(["`User and Group Management`"]) shell(("`Shell`")) -.-> shell/BasicSyntaxandStructureGroup(["`Basic Syntax and Structure`"]) linux/BasicSystemCommandsGroup -.-> linux/echo("`Text Display`") linux/BasicSystemCommandsGroup -.-> linux/clear("`Screen Clearing`") linux/PackagesandSoftwaresGroup -.-> linux/apt("`Package Handling`") linux/UserandGroupManagementGroup -.-> linux/whoami("`User Identifying`") linux/UserandGroupManagementGroup -.-> linux/id("`User/Group ID Displaying`") linux/UserandGroupManagementGroup -.-> linux/sudo("`Privilege Granting`") shell/BasicSyntaxandStructureGroup -.-> shell/comments("`Comments`") shell/BasicSyntaxandStructureGroup -.-> shell/quoting("`Quoting Mechanisms`") linux/PackagesandSoftwaresGroup -.-> linux/software("`Linux Software`") subgraph Lab Skills linux/echo -.-> lab-270253{{"`Your First Linux Lab`"}} linux/clear -.-> lab-270253{{"`Your First Linux Lab`"}} linux/apt -.-> lab-270253{{"`Your First Linux Lab`"}} linux/whoami -.-> lab-270253{{"`Your First Linux Lab`"}} linux/id -.-> lab-270253{{"`Your First Linux Lab`"}} linux/sudo -.-> lab-270253{{"`Your First Linux Lab`"}} shell/comments -.-> lab-270253{{"`Your First Linux Lab`"}} shell/quoting -.-> lab-270253{{"`Your First Linux Lab`"}} linux/software -.-> lab-270253{{"`Your First Linux Lab`"}} end

Hello LabEx

Welcome to Linux! Let's start with something simple and fun - making your computer say hello. ๐Ÿ˜„

First, we need to open the terminal. The terminal is like a text-based control center for your computer. It might look intimidating at first, but it's actually a powerful tool that lets you talk directly to your computer.

To open the terminal:

  1. Look at the left side of your desktop.
  2. Find the icon labeled Xfce Terminal.
  3. Click on this icon.

A window will open - this is your terminal. It's waiting for you to type in commands. The terminal is a text-based interface for interacting with your computer. It might seem old-fashioned, but it's actually very powerful. Many tasks in Linux are quicker and easier to do using the terminal than with a graphical interface.

Now, let's make your computer say hello! We'll use a command called echo. In Linux, echo is like a parrot - it repeats whatever you tell it to say.

Type the following command into your terminal, exactly as you see it here:

echo "Hello LabEx"

After you've typed this, press the Enter key on your keyboard.

lab-hello-world-1-1

You should see "Hello LabEx" appear on the next line. Congratulations! You've just run your first Linux command.

A few important things to remember:

  • Linux is case-sensitive. This means echo, Echo, and ECHO are all different to Linux. Always type commands exactly as you see them.
  • Spaces are important in Linux commands. Make sure you have a space between echo and the opening quotation mark.
  • The quotation marks tell echo exactly what to repeat. Without them, echo might get confused.

Don't worry if you make a mistake - everyone does when they're learning. Just try the command again!

Displaying the Current User

Now that you've said hello and gotten familiar with the terminal, let's try another command. This one will tell us who the computer thinks we are.

In your terminal, type the following command and press Enter:

whoami

This command asks the computer "Who am I?", and the computer responds with your username.

You should see output similar to this:

labex
whoami

The whoami command is useful when you're working on different computers or with different user accounts. It's a quick way to check which user account you're currently using.

Displaying User and Group Information

Now let's dive a little deeper into user information with the id command.

In Linux, every user belongs to one or more groups. These groups help manage permissions - what each user is allowed to do on the system.

Type the following command in your terminal and press Enter:

id

You'll see output similar to this:

uid=5000(labex) gid=5000(labex) groups=5000(labex),27(sudo),121(ssl-cert),5002(public)

Let's break this down:

  • uid stands for User ID. Every user has a unique number.
  • gid is the Group ID of your primary group.
  • groups lists all the groups you belong to.

You can also use id to look up information about other users. For example, let's check the root user:

id root

You'll see something like:

uid=0(root) gid=0(root) groups=0(root)

The root user is a special user in Linux with full system access. It's like the boss of the computer!

Don't worry if all this seems complex - as you continue learning Linux, you'll understand more about users and groups.

htop System Monitor

Now that we've explored some basic commands, let's install a useful tool called htop. This is a program that shows you what's happening inside your computer - like a dashboard for your system.

To install htop, we'll use a special command called sudo apt install. Here's what each part means:

  • sudo: This stands for "SuperUser DO". It's like asking the computer "Please let me act as a super-powerful user for a moment."
  • apt: This is a tool that helps install, update, and manage software on your Linux system. It's like an app store for your computer.
  • install: This tells apt that we want to install a new program.
  • htop: This is the name of the program we want to install.

Type the following command in your terminal and press Enter:

sudo apt install htop

The system might ask for your password. Type it in (you won't see the characters as you type - this is normal for security reasons) and press Enter.

Once the installation is complete, you can run htop by simply typing:

htop

In LabEx, you can open the terminal using the Xfce terminal on your desktop or the terminal icon in the menu bar. Both options generally have the same functionality.

You'll see a screen full of information about your computer's performance.

The htop screen shows:

  1. At the top: CPU usage, memory usage, and how long your computer has been running.
  2. In the middle: A list of all the programs (processes) currently running.
  3. At the bottom: Options for interacting with htop.

You can use the arrow keys on your keyboard to move around.

When you're done exploring, press the q key to quit htop.

Clear the Screen

Finally, let's learn how to tidy up our terminal. If your terminal gets cluttered with text, you can clear it with a simple command.

Type the following and press Enter:

clear

Voila! Your terminal screen is now clean and ready for more commands.

Summary

Congratulations! You've completed your first LabEx Lab and taken your first steps into the world of Linux. Let's recap what you've learned:

  1. How to open and use the terminal
  2. How to use the echo command to make your computer "speak"
  3. How to find out your username with whoami
  4. How to get detailed user information with id
  5. How to install software using sudo apt install
  6. How to monitor your system with htop
  7. How to clear your terminal screen

These might seem like small steps, but they're the foundation of working with Linux. Every expert started exactly where you are now!

If you want to learn more about LabEx and how to use it, you can visit our Support Center. Or you can watch this video to learn more about LabEx.

Remember, learning to program is a journey, and you've just taken your first steps. Keep practicing, stay curious, and don't be afraid to experiment. Your next lab is just a click away. Let's keep going!

Other Linux Tutorials you may like