Learn / Linux / Getting Started
Lesson 2 of 74

Your First Commands

Open a terminal, read the prompt, run your first commands and understand their output. Learn how every command is built, where commands come from, how to get help without Googling, and the shortcuts that make you fast.

25 min read Report a problem Hands-on lab included 6-question quiz

Getting a terminal

To use Linux you need a terminal: a window where you type commands and see their results. Where you get one depends on your computer:

Your computerHow to get a Linux terminal
This courseevery lesson's lab opens a terminal on a real Ubuntu machine, right in your browser. Nothing to install.
Windowsinstall WSL (Windows Subsystem for Linux): open PowerShell as administrator and run wsl --install. You get a real Ubuntu terminal inside Windows.
macOSopen the Terminal app. macOS is Unix-like, so most commands work, with small differences.
Linux desktopopen the Terminal app (often Ctrl + Alt + T).
A cloud serverconnect from any of the above with ssh user@server-address

Inside the terminal runs the shell, the program that reads your commands. On almost every server it's bash (Bourne Again SHell), and that's the shell this course uses.

Reading the prompt

When the shell is waiting for you, it shows a prompt. On our lab machines it looks like this:

Anatomy of the prompt

rootthe user you are logged in as
@"at"
devopsshackthe machine's name (hostname)
:separator
~the current folder (~ means your home folder)
## means root, $ means a normal user

root@devopsshack:~# means: user root, on the machine devopsshack, in the home folder, with administrator rights.

A normal user's prompt looks like aditya@web-01:/var/log$: user aditya, machine web-01, folder /var/log, and $ because it's not root.

Why care? Because in real jobs you often have several terminals open on different servers. Read the hostname before you press Enter on anything destructive. "I thought I was on the test server" is how production outages start.

root is the administrator account. It can read, change and delete anything, including the files that keep the system running. On real servers you usually log in as a normal user and use sudo for the few commands that need admin rights (covered in the Users & Permissions module). In our labs you're root, because the machine is yours and disposable.

Your first commands

Type a command, press Enter, read the output. Here are the ones you'll use from day one.

bash
whoami

What it does: prints the user you are logged in as.

text
root

One word, nothing else. Many Linux commands do one small job and print only the answer, which makes them easy to use in scripts.

bash
hostname

What it does: prints the machine's name, the same one shown in the prompt.

text
devopsshack
bash
pwd

What it does: print working directory: the full path of the folder you're in right now.

text
/root

/root is the home folder of the root user. The prompt shows it as ~. Folders and paths get a whole lesson next.

bash
date

What it does: prints the current date, time and time zone.

text
Tue Nov 24 15:14:27 IST 2026

Day, date, time, time zone (IST here) and year. Most servers run in UTC, so when you compare log times with your own clock, check the time zone first.

bash
uptime

What it does: shows how long the machine has been running and how busy it is.

text
 15:14:27 up 29 min,  0 user,  load average: 0.29, 0.22, 0.13
PartMeaning
15:14:27the current time
up 29 minthe machine started 29 minutes ago. After a crash or a reboot this number is small, a useful clue.
0 userhow many people are logged in through a normal login
load average: 0.29, 0.22, 0.13how busy the CPU has been over the last 1, 5 and 15 minutes. Roughly: below the number of CPU cores means fine. You'll learn to read it properly in the monitoring lesson.
bash
uname -a
PartMeaning
uname"Unix name": information about the system and kernel
-aall the information. uname alone prints just Linux, and uname -r just the kernel version.
text
Linux devopsshack 6.18.44-fc-v819 #1 SMP PREEMPT_DYNAMIC @0 x86_64 x86_64 x86_64 GNU/Linux
PartMeaning
Linuxthe kernel's name
devopsshackthe hostname
6.18.44-fc-v819the kernel version (asked for in bug reports and security checks)
x86_64the CPU architecture: 64-bit Intel/AMD. ARM servers (like AWS Graviton) show aarch64.
GNU/Linuxthe operating system

To find out which distribution and version you're on, read this file:

bash
cat /etc/os-release

What it does: cat prints a file. /etc/os-release exists on every modern distribution and describes it.

text
PRETTY_NAME="Ubuntu 24.04 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04 LTS (Noble Numbat)"
VERSION_CODENAME=noble
...

Ubuntu 24.04, a Long Term Support release, code name "Noble Numbat". On a Red Hat machine you'd see NAME="Red Hat Enterprise Linux". This is the first thing to check on a server you've never seen before.

bash
id

What it does: shows your user, its numeric ID, and the groups you belong to.

text
uid=0(root) gid=0(root) groups=0(root)
  • uid=0(root): your user ID is 0. The kernel only cares about numbers, and UID 0 is always the all-powerful root.
  • gid=0(root): your main group.
  • groups=: every group you're in. Groups decide what you're allowed to access, as you'll see in the permissions lessons.
bash
echo "Hello from Linux"
clear
CommandWhat it does
echoprints the text you give it. Mostly used in scripts to show messages, or to print variables like echo $HOME.
clearclears the screen (same as Ctrl + L). Your history is untouched.
Try it · Task 1 of 4

The prompt and your first commands

Find out who you are and which machine you are on, and save both answers to a file.

1 · See how it's done Read this, then run the commands in your terminal (or press ▶ Run)

When the terminal is ready for a command, it shows a prompt: a short piece of text that ends in $ or #, followed by a blinking cursor. The prompt is not decoration. It tells you who you are, which machine you're on, and where you are, three things you should always check before running anything on a real server.

1. Read the prompt

Look at the last line of your terminal:

text
root@devopsshack:~#
PartMeaning
rootthe user you are logged in as. root is the administrator account, which can do anything (including breaking the machine).
@devopsshackthe name of the machine (its hostname)
:separator
~the folder you are in. ~ is short for your home folder, here /root.
#you are root. A normal user sees $ instead.

On a real job you might have five terminals open on five different servers. Reading the hostname in the prompt is how you avoid restarting the database on production when you meant the test server.

2. Who am I?

bash
whoami

What it does: prints the name of the user you are logged in as. Useful when you've switched users and lost track.

text
root

Just one word. Many Linux commands are like this: they do one small job and print only the answer.

3. Which machine am I on?

bash
hostname

What it does: prints the machine's name, the same name shown in the prompt.

text
devopsshack

4. More first commands

bash
date
pwd
echo "Hello from Linux"
CommandWhat it does
dateprints the current date, time and time zone
pwdprint working directory: the full path of the folder you're in
echoprints back whatever text you give it. Very useful in scripts.

Click Run once and all three run, one after the other.

text
Tue Nov 24 14:55:37 IST 2026
/root
Hello from Linux
  • date shows the day, date, time and time zone (IST here; most servers use UTC).
  • pwd shows /root: the full path behind the ~ in your prompt.
  • echo printed exactly the text between the quotes.

5. When things go wrong

Linux tells you clearly when it doesn't understand. Try a command that doesn't exist:

bash
whoamii
text
bash: whoamii: command not found
  • bash: tells you who is complaining: the shell itself.
  • whoamii: is what it couldn't find, here because of a typo.
  • command not found usually means a typo, or a program that isn't installed.

Read error messages slowly. They nearly always tell you exactly what's wrong.

2 · Your task

Save your user name and the machine's name into /root/about-me.txt, one per line:

bash
whoami > /root/about-me.txt
hostname >> /root/about-me.txt
cat /root/about-me.txt

> sends a command's output into a file (replacing what was there), >> adds to the end of the file, and cat shows a file. You'll learn all three properly in later labs.

Expected result: cat /root/about-me.txt prints root on the first line and devopsshack on the second.

First start the lab machine in the terminal panel on the right.

How every command is built

This is the most important idea in this lesson. Nearly every Linux command follows the same pattern:

The anatomy of a command

headcommand
which program to run
-n 5option (with a value)
HOW to run it
/etc/passwdargument
WHAT to work on

head -n 5 /etc/passwd → show the first 5 lines of the file /etc/passwd. The parts are separated by spaces.

bash
head -n 5 /etc/passwd
text
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync

The first 5 lines of /etc/passwd, the file that lists the user accounts (you'll take it apart in the users lesson).

Options

Options change how a command behaves. They come in two styles that usually do the same thing:

StyleLooks likeExampleNotes
Shortone dash, one letter-n 5, -a, -lfast to type; can be combined: ls -l -a -h = ls -lah
Longtwo dashes, a word--lines=5, --alleasy to read; best in scripts so others understand them

So these two commands are identical:

text
head -n 2 /etc/passwd
head --lines=2 /etc/passwd

Some options take a value (-n 5: show 5 lines). Others are simple on/off flags (-a: show all).

Arguments

Arguments are what the command works on: a file, a folder, a user name, a server address. Many commands accept several (ls /etc /var), and many have a sensible default when you give none (ls alone lists the current folder).

Rules that trip beginners up

  1. Spaces separate the parts. ls -la is a command and an option; ls - la is something else entirely.
  2. Everything is case-sensitive. ls -a and ls -A are different options, and Notes.txt and notes.txt are different files.
  3. Names with spaces need quotes. cat My File.txt looks for two files, My and File.txt. Write cat "My File.txt".
  4. Options usually come before arguments: ls -l /etc, not ls /etc -l (GNU tools forgive this, but other systems don't).
Try it · Task 2 of 4

How a command is built

List every file in the practice folder, hidden ones included, with full details.

1 · See how it's done Read this, then run the commands in your terminal (or press ▶ Run)

Almost every Linux command, however long it looks, is built from the same three parts, separated by spaces:

text
ls    -l     /root/practice
│     │      │
│     │      └── argument: WHAT to work on (a file, a folder, a name)
│     └───────── option:   HOW to do it (also called a flag or switch)
└─────────────── command:  WHICH program to run
  • Options change the behaviour. Short options are one letter after one dash (-l). Long options are a word after two dashes (--all).
  • Arguments are the things the command works on. Many commands have a sensible default when you give none.

Once you can see these three parts, any command you meet in a tutorial, a script or a job interview becomes readable.

There's a practice folder ready for you in /root/practice. You'll explore it with ls, which lists what's in a folder.

1. Just the command

bash
ls /root/practice
PartTypeMeaning
lscommandlist the contents of a folder
/root/practiceargumentwhich folder to list. Without it, ls lists the folder you're in.
text
logs  notes.txt  report.pdf  scripts

Four names. In the terminal, folders are usually shown in blue and files in white, but plain ls gives no other details. What are they? How big? Let's ask for more.

2. Add an option: -l for "long"

bash
ls -l /root/practice
PartTypeMeaning
lscommandlist
-loptionlong format: one line per item, with details
/root/practiceargumentthe folder
text
total 16
drwxr-xr-x 2 root root 4096 Nov 24 14:56 logs
-rw-r--r-- 1 root root   61 Nov 20 18:30 notes.txt
-rw-r--r-- 1 root root 2048 Nov  1 09:00 report.pdf
drwxr-xr-x 2 root root 4096 Nov 24 14:56 scripts

Each line has seven columns. Take notes.txt:

ColumnValueMeaning
1-rw-r--r--the first character is the type: - a file, d a directory (folder), l a link. The other nine are the permissions (who may read, write, run it), covered in the permissions lab.
21number of links to it. You can ignore this for now.
3rootthe owner (user)
4rootthe group
561the size in bytes
6Nov 20 18:30when it was last modified
7notes.txtthe name

And total 16 at the top is the disk space used by everything listed, in kilobyte blocks.

3. Hidden files: -a for "all"

bash
ls -a /root/practice

What -a does: shows all entries, including hidden ones. On Linux, any name that starts with a dot (.) is hidden from a normal ls. Configuration files are often hidden, so they don't clutter your view.

text
.  ..  .env  logs  notes.txt  report.pdf  scripts

Three new entries:

  • .env is a hidden file. Files like this often hold settings or even passwords, so you'll want to see them.
  • . means "this folder itself".
  • .. means "the folder above this one" (the parent). You'll use .. all the time in the next lab, as in cd ...

4. Combine options

bash
ls -lah /root/practice
PartMeaning
-llong format
-ainclude hidden files
-hhuman-readable sizes: 2.0K instead of 2048

Short options can be joined: -lah is the same as -l -a -h. The order doesn't matter, -hal works too.

text
total 28K
drwxr-xr-x 4 root root 4.0K Nov 24 14:56 .
drwx------ 1 root root 4.0K Nov 24 14:56 ..
-rw-r--r-- 1 root root   23 Nov 24 14:56 .env
drwxr-xr-x 2 root root 4.0K Nov 24 14:56 logs
-rw-r--r-- 1 root root   61 Nov 20 18:30 notes.txt
-rw-r--r-- 1 root root 2.0K Nov  1 09:00 report.pdf
drwxr-xr-x 2 root root 4.0K Nov 24 14:56 scripts

Everything at once: hidden files, details, and sizes like 2.0K that are easy to read. ls -lah is probably the most-typed command on any server.

Long options do the same as short ones but are easier to read in scripts: ls --all is ls -a, ls --human-readable is ls -h. And capital letters matter: ls -A is a different option from ls -a, and a file called Notes.txt is different from notes.txt. Linux is case-sensitive everywhere.

2 · Your task

Save a long listing of /root/practice that includes hidden files into /root/practice-listing.txt.

Expected result: the file contains a line for .env with all seven columns.

Hint: the commands, explained
text
ls -la /root/practice > /root/practice-listing.txt

What each part does

  • ls -la: long format (permissions, owner, size, date), and all files, including hidden ones whose names start with ..
  • > /root/practice-listing.txt saves the listing instead of printing it.
First start the lab machine in the terminal panel on the right.

Where commands come from

When you type ls, how does the shell find it? There are two kinds of commands:

  • Shell builtins: part of bash itself, like cd, echo and pwd.
  • Programs: separate files on disk, like /usr/bin/ls.

type tells you which one a command is:

bash
type echo pwd ls
text
echo is a shell builtin
pwd is a shell builtin
ls is /usr/bin/ls

echo and pwd are built into bash. ls is a program stored in /usr/bin.

For programs, the shell looks through a list of folders, in order, stored in a variable called PATH:

bash
echo $PATH
which ls python3
CommandWhat it does
echo $PATHprints the PATH variable: the folders the shell searches, separated by :
which ls python3shows the full path of the program that would run for each name
text
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
/usr/bin/ls
/usr/bin/python3

The shell checks /usr/local/sbin first, then /usr/local/bin, and so on, and runs the first match. When you get "command not found", either the program isn't installed, or it lives in a folder that isn't in PATH. You'll fix exactly that in the environment variables lesson.

When things go wrong

Linux error messages are short but precise. Learn to read them, because they almost always tell you what's wrong.

text
$ whoamii
bash: whoamii: command not found

$ ls /nope
ls: cannot access '/nope': No such file or directory

The pattern is who complains, what about, why: bash couldn't find a command called whoamii (a typo); ls couldn't access /nope because it doesn't exist.

Exit codes: did it work?

Every command ends with a number called its exit code (or exit status). 0 means success, anything else means failure. The shell keeps the last one in the special variable $?:

bash
ls /nope; echo "exit code: $?"
ls /root; echo "exit code: $?"

The ; lets you put two commands on one line: run the first, then the second.

text
ls: cannot access '/nope': No such file or directory
exit code: 2
exit code: 0

The failed ls returned 2, the successful one returned 0 (and printed nothing, because /root is empty). You'll rarely check $? by hand, but scripts, cron jobs and CI pipelines rely on it: a deployment step "fails" precisely because some command returned a non-zero exit code.

Getting help without leaving the terminal

Nobody remembers every option. What experienced engineers remember is how to look them up quickly. There are three levels of help:

HelpGives youUse it when
whatis CMDone line: what the command does"what is this command?"
CMD --helpa short list of options"what was that option called?"
man CMDthe full manualyou need details or examples
bash
whatis passwd
text
passwd (1)           - change user password
passwd (1ssl)        - OpenSSL application commands
passwd (5)           - the password file

The number in brackets is the manual section. The same name can appear in several:

SectionContains
1normal user commands (ls, passwd)
5file formats (/etc/passwd)
8administrator commands (useradd, mount)

man 5 passwd opens the page about the file, man passwd the one about the command.

Reading --help

text
$ ls --help
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).

  -a, --all                  do not ignore entries starting with .
  -l                         use a long listing format
  ...

How to read the usage line: things in [square brackets] are optional, and ... means you can give several. So ls works with no options and no files, or with many of each. Each option line shows the short form, the long form, and a description.

Help texts are long. Filter them with a pipe and grep, which keeps only matching lines:

text
ls --help | grep size

Using man

man ls opens the full manual in a viewer. The keys you need:

KeyAction
Space / bpage down / back
↓ ↑one line
/word + Entersearch for "word", then n for the next match
qquit

Every man page has the same sections: NAME, SYNOPSIS (how to call it), DESCRIPTION (all options), and often EXAMPLES and SEE ALSO.

Don't know the command's name at all? Search the manual descriptions with man -k:

bash
man -k "list directory"
text
dir (1)              - list directory contents
ls (1)               - list directory contents
vdir (1)             - list directory contents
Try it · Task 3 of 4

Finding help on your own

Use the built-in help to find the ls option that sorts by time.

1 · See how it's done Read this, then run the commands in your terminal (or press ▶ Run)

Nobody remembers every option of every command, not even senior engineers. What they do remember is how to look things up, right in the terminal, without leaving the server. Linux has three levels of built-in help:

HelpGives youUse it when
whatis COMMANDa one-line description"what does this command even do?"
COMMAND --helpa short list of options"what was that option called again?"
man COMMANDthe full manualyou need all the details and examples

1. One line: whatis

bash
whatis ls
text
ls (1)               - list directory contents
  • ls is the command.
  • (1) is the section of the manual it lives in. Section 1 is normal user commands, section 8 is administrator commands (like useradd), section 5 is file formats (like /etc/passwd).
  • After the dash comes the description.

2. The quick reference: --help

bash
ls --help

What it does: almost every command accepts --help and prints a summary of how to use it. It's long, so scroll up in the terminal to read it all.

text
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

  -a, --all                  do not ignore entries starting with .
  -A, --almost-all           do not list implied . and ..
      --author               with -l, print the author of each file
  ...

Two things to learn to read here:

  • The usage line ls [OPTION]... [FILE]...: square brackets mean optional, and ... means you can give several. So ls works with no options and no files, or with many of each.
  • Each option line shows the short form, the long form, then what it does. -a, --all means -a and --all are the same option.

3. Search the help instead of scrolling

The help is long. You can filter it with grep, which keeps only the lines that contain a word:

bash
ls --help | grep sort
PartMeaning
ls --helpproduce the help text
|the pipe: send that text into the next command instead of the screen
grep sortkeep only the lines containing the word sort
text
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
  ...
  -r, --reverse              reverse order while sorting
  -S                         sort by file size, largest first
      --sort=WORD            sort by WORD instead of name: none (-U), size (-S),
  ...
  -t                         sort by time, newest first; see --time
  ...
  -U                         do not sort; list entries in directory order
  -v                         natural sort of (version) numbers within text
  -X                         sort alphabetically by entry extension

Instead of about 100 lines, you get only the ones about sorting, with the word sort highlighted in red. (Some option descriptions continue on a second line, so you may see a few lines that start with spaces.) Pipes get their own lab later, but this trick alone will save you hours.

4. The full manual: man

bash
man ls

What it does: opens the complete manual page for ls in a viewer. Inside the viewer:

KeyAction
↓ ↑ or Spacescroll down / up, or one page down
/word then Entersearch for "word". Press n for the next match.
qquit and get your prompt back

Pressing q is the one you must remember. New users often think the terminal froze, when it's just waiting inside man.

text
LS(1)                            User Commands                           LS(1)

NAME
       ls - list directory contents

SYNOPSIS
       ls [OPTION]... [FILE]...

DESCRIPTION
       List  information  about  the FILEs (the current directory by default).

Every man page follows the same layout: NAME (one line), SYNOPSIS (how to call it), DESCRIPTION (all the options), and often EXAMPLES and SEE ALSO (related commands) at the end.

2 · Your task

Use the help to find which ls option sorts by modification time, newest first. Write just that option (for example -x) into /root/answer.txt, then try it: ls -lt /root/practice.

Expected result: /root/answer.txt contains the option, and in your listing the newest items come first.

Hint: the commands, explained

Look through the output of ls --help | grep sort for the line that says "sort by time". Then for example:

text
echo "-t" > /root/answer.txt

What each part does

  • You found this in ls --help or man ls: -t sorts by modification time, newest first.
  • echo "-t" > FILE writes the answer. The quotes make sure the shell treats it as plain text.
First start the lab machine in the terminal panel on the right.

Working faster

Tab completion

Press Tab while typing a command, file or folder name, and the shell completes it. If several names match, press Tab twice to see them all. Completion saves typing and, more importantly, prevents typos in long paths.

History

The shell remembers what you've typed:

Keys / commandWhat it does
↑ / ↓previous / next command, ready to edit or run again
historynumbered list of your recent commands
!42run command number 42 from the history
!!run the last command again, famously sudo !! when you forgot sudo
Ctrl + Rsearch the history: type part of an old command, Ctrl + R again for older matches

Shortcuts every engineer uses

KeysAction
Ctrl + Cstop the running command, or cancel the line you're typing
Ctrl + Lclear the screen
Ctrl + A / Ctrl + Ejump to the start / end of the line
Ctrl + Udelete everything before the cursor
Ctrl + Wdelete the word before the cursor
Ctrl + Dend of input. On an empty line it logs you out.
Ctrl + Zpause the running command and send it to the background (resume with fg)

Pressing Ctrl + Z to "get out" of a program. It doesn't stop it, only pauses it in the background, where it keeps holding files and ports. Use Ctrl + C to stop a command, and q to leave viewers like less and man.

"How do you check which OS version and kernel a server is running?" cat /etc/os-release for the distribution and version, uname -r for the kernel version.

"What is an exit code?" The number a command returns when it finishes: 0 means success, non-zero means failure. echo $? shows the last one, and scripts and CI pipelines use it to decide whether a step passed.

"What's the difference between a shell builtin and a command?" A builtin like cd is part of the shell itself; a command like ls is a separate program found through PATH. type tells you which is which.

Try it · Task 4 of 4

Work faster

Use history and shortcuts, then save your command history to a file.

1 · See how it's done Read this, then run the commands in your terminal (or press ▶ Run)

Experienced engineers aren't faster because they type faster. They type less. The shell can finish names for you, remember every command you've run and repeat them in a keystroke. These habits also prevent typos in long paths, which on a real server can mean deleting the wrong thing.

1. Tab completion

Type the following, but don't press Enter. Press the Tab key where you see [Tab]:

text
ls /root/pra[Tab]

The shell completes it to /root/practice/, because that's the only name starting with pra. Now press Tab twice quickly:

text
ls /root/practice/[Tab][Tab]
text
.env       logs/      notes.txt  report.pdf scripts/

When more than one name matches, one Tab does nothing and a second Tab lists all the choices. Type one or two more letters and press Tab again. Completion works for commands too: type whoa and press Tab.

2. Command history

Press the ↑ (up arrow) key a few times. Your earlier commands come back one by one, ready to run again or edit. ↓ goes forward again.

To see the whole list:

bash
history

What it does: prints every command you've typed in this shell, numbered.

text
    1  whoami
    2  hostname
    3  whoami > /root/about-me.txt
    4  hostname >> /root/about-me.txt
    5  ls -la /root/practice
    6  history

The number on the left lets you re-run a command: !5 runs number 5 again. And !! repeats the last command, most famously as sudo !! when you forgot sudo.

3. Search your history

Press Ctrl + R and start typing part of an old command, for example prac. The shell finds the most recent command containing it. Press Ctrl + R again for older matches, Enter to run it, or Ctrl + C to cancel.

4. Shortcuts worth learning now

KeysWhat it does
Tabcomplete a name
↑ / ↓previous / next command
Ctrl + Rsearch history
Ctrl + Cstop the running command, or cancel what you're typing
Ctrl + Lclear the screen (same as the clear command)
Ctrl + A / Ctrl + Ejump to the start / end of the line
Ctrl + Dlog out of the shell. Careful on a remote server!

Ctrl + C is the most important one. If a command takes over your terminal and you don't know how to stop it, try Ctrl + C first, then q.

2 · Your task

Use Tab completion and ↑ to run a few commands, then save your command history into /root/history.txt.

Expected result: /root/history.txt contains your numbered commands, including some ls commands from this lab.

Hint: the commands, explained
text
history > /root/history.txt

What each part does

  • history: print the numbered list of commands you've typed in this shell. > saves it. Try !5 to re-run command number 5, or Ctrl+R to search it.
First start the lab machine in the terminal panel on the right.

Summary

  • The prompt shows user@host:folder, with # for root and $ for normal users. Check the hostname before risky commands.
  • First commands: whoami, hostname, pwd, date, uptime, uname -a, cat /etc/os-release, id, echo, clear.
  • Commands are command + options + arguments, separated by spaces. Short options can be combined; long options are clearer. Everything is case-sensitive.
  • type and which show where a command comes from; programs are found through PATH.
  • Exit code 0 = success; $? holds the last one.
  • Help: whatis, --help, man (q to quit), man -k to search.
  • Tab, ↑, Ctrl + R and Ctrl + C make you fast and safe.

Now open the lab and try it all on your own Linux machine.

Check your understanding

Quick quiz

Feedback