Cyber Security /Linux Fundamentals / Lesson
Cyber Security

Terminal Fundamentals

Learn how to work confidently and safely with the Linux terminal, including commands, arguments, options, paths, pipes, redirection, command history, help systems and essential terminal security practices.

🎯

Learning Objectives

["Understand what a terminal is and how it relates to a shell.","Understand the basic structure of Linux commands.","Use command names, options and arguments correctly.","Distinguish between absolute and relative paths.","Navigate the filesystem from the terminal.","Use built-in help and manual pages.","Understand standard input, output and error.","Use pipes and basic redirection.","Understand command history and tab completion.","Recognize basic terminal security risks.","Work safely with commands in an authorized Linux environment."]

📖

Lesson Content

Terminal Fundamentals

The Linux terminal is one of the most important tools for anyone learning
Linux administration, system administration, networking or cyber security.
It provides a text-based interface through which users can communicate with
the operating system and run commands.

A graphical interface is useful for many everyday tasks, but the terminal
provides precise control, repeatability and access to a large collection of
administrative and diagnostic tools.


1. What Is a Terminal?

A terminal is an interface that allows a user to interact
with a computer through text commands.

Historically, terminals were physical devices connected to larger computers.
Modern Linux systems normally provide software-based terminal applications
such as GNOME Terminal, Konsole, XTerm and many terminal emulators.

The terminal itself is not the same thing as the shell.

  • Terminal: Provides the interface where commands are entered.
  • Shell: Interprets commands and communicates with the operating system.
  • Kernel: Manages hardware and core operating-system resources.

Common Linux shells include Bash, Zsh, Dash and Fish.


2. Terminal vs Shell

Consider the following simplified flow:

User
  ↓
Terminal
  ↓
Shell
  ↓
Operating System / Kernel
  ↓
Hardware and System Resources

For example, when a user types:

pwd

the shell interprets the command and asks the operating system for the
current working directory.


3. Understanding the Command Prompt

A Linux prompt may look similar to:

student@linuxlab:~$

The exact format depends on the system configuration.

A prompt can contain information such as:

  • Current username.
  • Computer hostname.
  • Current directory.
  • User privilege level.

A $ commonly represents a normal user shell, while a
# is often used for a root shell.

Do not assume that a command is safe simply because it is entered at a
terminal prompt. Commands should be understood before execution.


4. Basic Command Structure

Many Linux commands follow a structure similar to:

command [options] [arguments]

For example:

ls -l /home

Here:

  • ls is the command.
  • -l is an option.
  • /home is an argument.

Not every command requires options or arguments.


5. Command Names

A command name tells the shell which program or built-in operation should
be executed.

Examples include:

pwd
ls
cd
whoami
hostname
date

These commands are useful for learning basic system navigation and
identification.


6. The pwd Command

pwd means print working directory.
It displays the directory in which the current shell is operating.

pwd

Example output:

/home/student

This is especially useful when working with relative paths.


7. The ls Command

The ls command lists files and directories.

ls

A detailed listing can be requested with:

ls -l

Hidden files can be included with:

ls -la

Options vary between commands, so students should use the command’s
documentation rather than memorizing every possible option.


8. Navigating with cd

The cd command changes the current working directory.

cd /home

To move to the parent directory:

cd ..

To return to the current user’s home directory:

cd ~

To return to the previous working directory:

cd -

9. Absolute and Relative Paths

A path identifies the location of a file or directory.

Absolute Path

An absolute path begins from the root of the filesystem.

/home/student/Documents

Relative Path

A relative path is interpreted from the current working directory.

Documents/project

Understanding paths is essential when working with Linux files, logs,
configuration files and applications.


10. Clearing the Terminal

The terminal can become crowded with previous output.

clear

This clears the visible terminal screen without deleting files.


11. Command History

Linux shells normally maintain a history of commands entered by the user.

history

The up and down arrow keys can also be used to navigate through previous
commands in many terminal environments.

Command history is useful for productivity and troubleshooting, but it can
also create a security concern if sensitive information is entered directly
into a command.

For example, passwords, API keys and access tokens should not normally be
placed directly in command-line arguments because they may appear in shell
history or process information.


12. Tab Completion

Most modern Linux shells support tab completion.

Typing part of a command, filename or directory and pressing
Tab can complete the item or show available matches.

Tab completion reduces typing mistakes and improves terminal productivity.


13. Getting Help

Linux provides several mechanisms for learning how commands work.

Manual Pages

man ls

The man command opens the manual page for a command.

Help Options

ls --help

Many commands provide a help option.

Command Information

which ls

This can help identify the executable being used for a command.


14. Reading Files from the Terminal

Several commands can display text files.

cat

cat notes.txt

less

less notes.txt

head

head notes.txt

tail

tail notes.txt

These commands are particularly useful when examining configuration files,
logs and documentation in an authorized environment.


15. Creating Files and Directories

The touch command can create an empty file or update a file’s
timestamp.

touch notes.txt

The mkdir command creates a directory.

mkdir cybersecurity-lab

A safe training environment can therefore be created without modifying
important system files.


16. Copying and Moving Files

The cp command copies files.

cp notes.txt backup.txt

The mv command can move or rename files.

mv notes.txt lesson-notes.txt

Students should verify paths carefully before moving or replacing files.


17. Removing Files

The rm command removes files.

rm test.txt

Because removal can be destructive, students should be especially careful
when using recursive or forced removal options.

For training exercises, work inside a dedicated lab directory containing
only disposable files.


18. Standard Input, Output and Error

Linux programs commonly work with three standard streams:

  • stdin: Standard input.
  • stdout: Standard output.
  • stderr: Standard error output.

Understanding these streams is important for shell scripting,
troubleshooting and security monitoring.


19. Output Redirection

The > operator redirects output into a file.

echo "Linux Lab" > lab.txt

The >> operator appends output to an existing file.

echo "Second line" >> lab.txt

Students should understand the difference because > can
replace the contents of an existing file.


20. Input Redirection

The < operator can provide a file as standard input.

The concept is important when learning shell scripting and command
automation.


21. Pipes

A pipe, represented by |, sends the output of one command
to another command.

For example:

ls -la | less

The output from ls -la is passed to less.

Pipes are extremely useful when working with large amounts of terminal
output.


22. Searching Output with grep

The grep command can search text for matching patterns.

grep "error" application.log

A simple pipeline can also be used:

cat application.log | grep "error"

In practice, the first form is often simpler:

grep "error" application.log

Security professionals frequently use text-search tools when reviewing
authorized logs and configuration data.


23. Command Chaining

The && operator can run the second command only if the
first command succeeds.

mkdir lab && cd lab

The semicolon can separate commands:

pwd; whoami

Students should understand that command chaining can make scripts and
terminal sessions more efficient, but careless chaining can also produce
unexpected results.


24. Environment Variables

Environment variables store information used by processes and shells.

For example:

echo $HOME

Another important variable is:

echo $PATH

The PATH variable contains directories in which the shell
looks for executable commands.

Incorrect PATH configuration can create security and administration
problems, so students should understand it before modifying it.


25. Terminal Security

The terminal is powerful because it can interact directly with the
operating system. That power also introduces security responsibilities.

Important practices include:

  • Do not execute commands you do not understand.
  • Use the least privilege necessary.
  • Prefer a normal user account for routine work.
  • Use sudo only when administrative privileges are required.
  • Do not expose passwords or secrets in commands.
  • Be careful when copying commands from untrusted websites.
  • Verify filenames and paths before destructive operations.
  • Work inside an authorized lab when learning security commands.
  • Keep software updated.
  • Protect shell history and sensitive configuration files.

26. Why Terminal Skills Matter in Cyber Security

Cybersecurity professionals frequently work with Linux systems because Linux
is widely used in servers, cloud environments, networking appliances,
containers, development environments and security infrastructure.

Terminal skills help analysts perform tasks such as:

  • Inspecting system information.
  • Reviewing logs.
  • Checking network configuration.
  • Examining running processes.
  • Managing files and permissions.
  • Checking installed software.
  • Investigating system behavior.
  • Automating repetitive administrative tasks.

27. Terminal Security Example

Suppose a student receives a command from an unknown source that contains
many shell operators, downloads files and attempts to execute them.
The correct approach is not to run the command immediately.

Instead, the student should:

  1. Read the command carefully.
  2. Identify every command being executed.
  3. Understand pipes and redirections.
  4. Identify whether files are being downloaded or modified.
  5. Check whether administrative privileges are requested.
  6. Use documentation to understand unfamiliar commands.
  7. Test only inside an authorized isolated lab when appropriate.

This habit is especially important in cybersecurity because attackers can
use social engineering to persuade users to execute dangerous commands.


28. Safe Terminal Laboratory

Create a dedicated training directory on your own Linux virtual machine:

mkdir -p ~/dwallnet-terminal-lab
cd ~/dwallnet-terminal-lab

Create sample files:

touch notes.txt
touch security.txt
mkdir logs

Add simple training content:

echo "Terminal fundamentals" > notes.txt
echo "Cyber security training" > security.txt

List the files:

ls -la

Read a file:

cat notes.txt

Search for a word:

grep "security" security.txt

This exercise should be performed only in a personal or explicitly
authorized Linux laboratory.


29. PHP Example — Safe Command Representation

PHP applications sometimes need to display or record system-command
information. The following example demonstrates safe representation of a
predefined command without executing it.

<?php

$command = 'pwd';

echo 'Training command: ';
echo htmlspecialchars(
    $command,
    ENT_QUOTES,
    'UTF-8'
);

echo '<br>';
echo 'This example displays the command only.';

The example intentionally does not use functions such as
shell_exec(), exec() or system().
Applications should not execute user-supplied commands without a strong,
well-designed security model and a clearly defined administrative purpose.


30. Terminal Fundamentals and Command Injection

One important cybersecurity concept connected to terminal usage is
command injection.

Command injection can occur when an application incorrectly combines
untrusted user input with operating-system commands.

For example, an application that accepts arbitrary user input and places it
directly into a shell command can unintentionally allow additional commands
to be interpreted.

The safest general approach is to avoid shell execution when it is not
necessary. Where operating-system interaction is genuinely required,
developers should use tightly controlled inputs, allowlists, safe APIs and
appropriate privilege separation.


31. Terminal Productivity Skills

Students should become comfortable with:

  • Tab completion.
  • Command history.
  • Keyboard navigation.
  • Manual pages.
  • Help options.
  • Absolute and relative paths.
  • Pipes.
  • Input and output redirection.
  • Text searching.
  • Environment variables.

These skills form the foundation for later lessons involving files,
permissions, users, processes, networking and shell scripting.


32. Practical Exercise

Using an authorized Linux virtual machine:

  1. Open a terminal.
  2. Display your username with whoami.
  3. Display the current directory with pwd.
  4. List the current directory with ls -la.
  5. Navigate to your home directory.
  6. Create a directory called dwallnet-lab.
  7. Enter the directory.
  8. Create two text files.
  9. Add sample text to the files.
  10. Display their contents.
  11. Use grep to search for a word.
  12. Use a pipe to send command output to less.
  13. Use history to inspect recent commands.
  14. Use man or --help to investigate one unfamiliar command.

Document what each command does and explain how it could be useful to a
cybersecurity analyst.


33. Review Questions

  1. What is a terminal?
  2. What is the difference between a terminal and a shell?
  3. What does pwd display?
  4. What does ls -la show?
  5. What is the difference between an absolute and relative path?
  6. What is the purpose of the man command?
  7. What does the pipe symbol | do?
  8. What is the difference between > and >>?
  9. Why should sensitive credentials not normally be placed in command-line arguments?
  10. What is the purpose of the PATH environment variable?
  11. Why should unfamiliar commands be examined before execution?
  12. What is command injection?

34. Key Takeaways

  • The terminal provides a powerful text-based interface to Linux.
  • A shell interprets commands entered through the terminal.
  • Linux commands commonly use commands, options and arguments.
  • pwd, ls and cd are fundamental navigation commands.
  • Absolute and relative paths identify filesystem locations.
  • Manual pages and help options are essential learning tools.
  • Pipes and redirection allow commands to work together.
  • Command history improves productivity but can expose sensitive information.
  • Terminal commands should be executed carefully and with appropriate privileges.
  • Terminal knowledge is an important foundation for cybersecurity work.

35. Conclusion

Terminal fundamentals provide the practical foundation for working with
Linux systems. Before learning advanced security administration, students
must become comfortable navigating the filesystem, understanding commands,
reading output and using the shell safely.

The next lesson will build on these skills by examining how Linux organizes
and manages Files and Directories.

💻

Code Example

<?php

$command = 'pwd';

echo 'Training command: ';
echo htmlspecialchars(
	$command,
	ENT_QUOTES,
	'UTF-8'
);

echo '<br>';
echo 'This example displays the command only.';
⭐

Key Takeaways

["The terminal provides a text-based interface for interacting with Linux.","A shell interprets commands entered through the terminal.","Linux commands commonly consist of a command, options and arguments.","pwd, ls and cd are fundamental terminal commands.","Absolute and relative paths are important for filesystem navigation.","Manual pages and help options help users understand unfamiliar commands.","Pipes and redirection allow commands to work together.","Command history can be useful but may expose sensitive information.","Users should avoid executing commands they do not understand.","Least privilege and authorized laboratory environments are important security practices.","Terminal skills form an important foundation for cybersecurity work."]

Enjoying this lesson?

Sign in to your Dwallnet Academy student account to track your learning progress and mark lessons as complete.

Sign In to Track Progress