🐧 Linux Terminal Command Notes

High School Cybersecurity / Computer Science

Introduction

These notes explain common Linux terminal commands that programmers, system administrators, and cybersecurity professionals use every day. Each section is based on real Linux terminal examples.

1️⃣ Understanding the Terminal Prompt

Example prompt:

joe@linux:~$

This tells you:

Part Meaning
joe Current user
linux Computer name
~ Home directory
$ Normal user prompt

2️⃣ pwd — Print Working Directory

pwd

Example output:

/home/joe

The pwd command shows your current location in the Linux file system.

If the output is /home/joe, it means the current directory is the home folder for the user named Joe.

3️⃣ ls — List Files and Folders

ls

Example output:

notes.txt   project

The ls command lists files and folders in the current directory.

Common options:

ls -l
ls -a
ls -la

4️⃣ Hidden Files

ls -a

Example hidden file:

.bashrc

Files that begin with a period . are hidden files. The .bashrc file stores terminal configuration settings.

Hidden files are often used for configuration, system settings, and environment setup.

5️⃣ cd — Change Directory

cd Documents

The cd command moves you into another folder. This example moves you into the Documents folder.

6️⃣ cd .. — Move Up One Directory

cd ..

This command moves you back one level in the directory structure.

Example:

/home/joe/Documents

After typing cd ..:

/home/joe

7️⃣ touch — Create a File

touch report.txt

The touch command creates an empty file named report.txt.

8️⃣ mkdir — Create a Folder

mkdir Projects

The mkdir command creates a new folder named Projects.

9️⃣ rm — Delete Files

rm notes.txt

The rm command deletes the file named notes.txt.

Be careful: deleted files in Linux usually do not go to the trash.

🔟 rm -r — Delete Folders Recursively

rm -r oldfiles

This deletes the folder oldfiles and everything inside it.

This is a powerful command. Use it carefully because it can remove many files at once.

1️⃣1️⃣ cp — Copy Files

cp file1.txt backup.txt

The cp command copies file1.txt into a new file called backup.txt.

1️⃣2️⃣ mv — Move or Rename Files

mv report.txt final.txt

The mv command renames report.txt to final.txt.

It can also move files to a different folder.

1️⃣3️⃣ cat — Display File Contents

cat notes.txt

The cat command shows the full contents of a file in the terminal.

1️⃣4️⃣ less — Scroll Through a File

less logfile.txt

The less command lets you scroll through a file one screen at a time.

Press q to quit.

1️⃣5️⃣ head — View the Beginning of a File

head data.txt

The head command shows the first 10 lines of a file.

1️⃣6️⃣ tail — View the End of a File

tail data.txt

The tail command shows the last 10 lines of a file.

This is especially useful when reading logs and checking recent system activity.

1️⃣7️⃣ whoami — Current Logged-In User

whoami

Example output:

joe

This means the current logged-in user is joe.

1️⃣8️⃣ uname -a — System Information

uname -a

This command shows system and kernel information, such as the operating system, kernel version, and architecture.

1️⃣9️⃣ top — Running Processes

top

The top command shows running processes and system resource usage.

Press q to quit.

2️⃣0️⃣ df -h — Disk Space Usage

df -h

This command displays disk usage in a human-readable format.

The -h option makes sizes easier to read, such as MB and GB.

2️⃣1️⃣ Linux File Permissions

-rwxr-xr--

This permission string shows file permissions for the owner, group, and others.

Letter Meaning
r read
w write
x execute

2️⃣2️⃣ chmod — Change Permissions

chmod 755 script.sh

This command changes permissions so that the owner can read, write, and execute the file.

Number Permission
7 read + write + execute
5 read + execute

2️⃣3️⃣ sudo — Administrator Privileges

sudo apt update

The sudo command allows a user to run commands with administrator privileges.

Use sudo carefully. A mistake made with administrator privileges can break the system.

2️⃣4️⃣ Installing Software

sudo apt install nmap

This command installs the nmap software package.

Nmap is a common cybersecurity and network scanning tool.

2️⃣5️⃣ ping — Test Network Connectivity

ping google.com

The ping command tests network connectivity to another computer or website.

It is often used to check whether a system can reach the internet or another device.

2️⃣6️⃣ ip a — View IP Address and Interfaces

ip a

This command shows IP addresses and network interfaces on the system.

2️⃣7️⃣ netstat -tuln — Network Connections and Listening Ports

netstat -tuln

This command shows active network connections and listening ports.

This is useful in cybersecurity for checking which services are open on a system.

2️⃣8️⃣ grep — Search Inside Files

grep "error" logfile.txt

The grep command searches a file for matching text.

This example searches logfile.txt for the word error.

2️⃣9️⃣ find — Search for Files

find /home -name report.txt

The find command searches for a file named report.txt inside the /home directory.

3️⃣0️⃣ Command Structure

ls -l Documents

Most Linux commands follow this pattern:

command [options] [argument]
Part Meaning
ls Command
-l Option that changes how the command runs
Documents Argument or target folder

🔐 Why Linux Matters in Cybersecurity

Practicing Linux commands regularly helps students build real-world cybersecurity skills.