High School Cybersecurity / Computer Science
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.
Example prompt:
joe@linux:~$
This tells you:
| Part | Meaning |
|---|---|
| joe | Current user |
| linux | Computer name |
| ~ | Home directory |
| $ | Normal user prompt |
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.
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
ls -a
Example hidden file:
.bashrc
Files that begin with a period . are hidden files. The .bashrc file stores terminal configuration settings.
cd Documents
The cd command moves you into another folder. This example moves you into the Documents folder.
cd ..
This command moves you back one level in the directory structure.
Example:
/home/joe/Documents
After typing cd ..:
/home/joe
touch report.txt
The touch command creates an empty file named report.txt.
mkdir Projects
The mkdir command creates a new folder named Projects.
rm notes.txt
The rm command deletes the file named notes.txt.
rm -r oldfiles
This deletes the folder oldfiles and everything inside it.
cp file1.txt backup.txt
The cp command copies file1.txt into a new file called backup.txt.
mv report.txt final.txt
The mv command renames report.txt to final.txt.
It can also move files to a different folder.
cat notes.txt
The cat command shows the full contents of a file in the terminal.
less logfile.txt
The less command lets you scroll through a file one screen at a time.
Press q to quit.
head data.txt
The head command shows the first 10 lines 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.
whoami
Example output:
joe
This means the current logged-in user is joe.
uname -a
This command shows system and kernel information, such as the operating system, kernel version, and architecture.
top
The top command shows running processes and system resource usage.
Press q to quit.
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.
-rwxr-xr--
This permission string shows file permissions for the owner, group, and others.
| Letter | Meaning |
|---|---|
| r | read |
| w | write |
| x | execute |
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 |
sudo apt update
The sudo command allows a user to run commands with administrator privileges.
sudo apt install nmap
This command installs the nmap software package.
Nmap is a common cybersecurity and network scanning tool.
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.
ip a
This command shows IP addresses and network interfaces on the system.
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.
grep "error" logfile.txt
The grep command searches a file for matching text.
This example searches logfile.txt for the word error.
find /home -name report.txt
The find command searches for a file named report.txt inside the /home directory.
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 |