About the
Lab.

Welcome to the Linux Commands Lab. In this session, we'll build a real project entirely from the terminal — learning the essential Linux commands that every developer uses daily.

Recommended Learning

Master the Linux Shell

Explore the Linux ecosystem — from the kernel and file system hierarchy to shell scripting and process management.

Start Learning
bash — ~/myproject
user@linux:~/myproject$ ls -la
total 24
drwxr-xr-x 4 user user 4096 Jun 1 10:00 .
drwxr-xr-x 18 user user 4096 Jun 1 09:55 ..
-rw-r--r-- 1 user user 220 Jun 1 10:00 README.md
drwxr-xr-x 2 user user 4096 Jun 1 10:00 src
drwxr-xr-x 2 user user 4096 Jun 1 10:00 logs
user@linux:~/myproject$
What we are building

We'll construct a project workspace entirely from the terminal — creating directories, writing files, managing permissions, searching content, and monitoring processes. By the end, you'll navigate Linux like a pro.

Lab Objectives

  • 1
    Navigate the filesystem with confidence.
  • 2
    Create, move, copy, and delete files and directories.
  • 3
    Manage permissions, processes, and search content.

The Shell.

The terminal is your direct line to the operating system. Every command you type is interpreted by the shell — most commonly bash or zsh on Linux.

Why the Terminal?

GUIs are great for casual use, but the terminal gives you speed, precision, and automation. Every professional developer, sysadmin, and DevOps engineer lives in the terminal.

Requirements

  • 1
    A Linux/macOS terminal, or WSL on Windows.
  • 2
    Basic familiarity with typing commands.
  • 3
    Curiosity — the terminal rewards exploration.

Navigation

Before you can build anything, you need to know where you are. These three commands are the foundation of every terminal session.

bash
# Print Working Directory — where am I?
$ pwd
/home/user

# List files in current directory
$ ls
Documents  Downloads  myproject  README.md

$ ls -la          # long format, show hidden files
total 32
drwxr-xr-x  5 user user 4096 Jun  1 10:00 .
drwxr-xr-x 18 user user 4096 Jun  1 09:55 ..
-rw-------  1 user user  220 Jun  1 09:00 .bash_history
drwxr-xr-x  2 user user 4096 Jun  1 10:00 Documents
drwxr-xr-x  4 user user 4096 Jun  1 10:00 myproject
-rw-r--r--  1 user user   42 Jun  1 10:00 README.md

# Change Directory
$ cd Documents
$ pwd
/home/user/Documents

$ cd ..          # go up one level
$ cd ~           # go to home directory
$ pwd
/home/user
The Prompt

Your prompt shows user@hostname:path$. The ~ symbol always means your home directory (/home/username). The / is the root of the entire filesystem.

Project
Scaffold.

Let's build our project workspace. We'll create a directory tree using mkdir and verify it with ls.

bash
# Create the project root
$ mkdir myproject
$ cd myproject
$ pwd
/home/user/myproject

# Create nested directories in one command
$ mkdir -p src/components src/utils logs docs

# Verify the structure
$ ls -R
.:
docs  logs  src

./docs:

./logs:

./src:
components  utils

./src/components:

./src/utils:

# Or use tree (if installed)
$ tree
.
├── docs
├── logs
└── src
    ├── components
    └── utils

5 directories, 0 files
The -p Flag

The -p flag tells mkdir to create parent directories as needed. Without it, mkdir src/components would fail if src doesn't exist yet.

Writing Files.

Now let's populate our project. Linux gives you several ways to create and write files directly from the terminal.

bash
# Create an empty file
$ touch README.md
$ touch src/index.js src/utils/helpers.js
$ ls src/
components  index.js  utils

# Write content to a file (overwrites)
$ echo "# My Linux Project" > README.md

# Append content to a file
$ echo "Built entirely from the terminal." >> README.md

# View file contents
$ cat README.md
# My Linux Project
Built entirely from the terminal.

# Count lines
$ wc -l README.md
2 README.md
> vs >>

> overwrites the file completely. >> appends to the end. Using > on an existing file will erase all previous content — be careful.

File Operations.

Managing files is a core skill. cp, mv, and rm are the workhorses of file management in Linux.

bash
# Copy a file
$ cp README.md docs/README_backup.md
$ ls docs/
README_backup.md

# Copy a directory recursively
$ cp -r src/ src_backup/
$ ls
docs  logs  src  src_backup  README.md

# Move / Rename a file
$ mv src/index.js src/main.js
$ ls src/
components  main.js  utils

# Move a file to another directory
$ mv docs/README_backup.md logs/
$ ls logs/
README_backup.md

# Delete a file
$ rm logs/README_backup.md
$ ls logs/
(empty)

# Delete a directory and its contents
$ rm -rf src_backup/
$ ls
docs  logs  src  README.md
rm -rf Warning

rm -rf is permanent — there is no Recycle Bin in Linux. Always double-check your path before running it. A misplaced / can wipe critical system files.

Search &
Inspect.

Real projects have lots of files. grep and find let you locate exactly what you need without opening every file manually.

bash
# Search for text inside a file
$ grep "Linux" README.md
# My Linux Project

# Search recursively in all files
$ grep -r "function" src/
src/utils/helpers.js:function formatDate(d) {
src/main.js:function init() {

# Find files by name
$ find . -name "*.js"
./src/main.js
./src/utils/helpers.js

# Find files modified in the last 24 hours
$ find . -mtime -1
.
./README.md
./src/main.js
./src/utils/helpers.js

# Count lines in a file
$ wc -l README.md
2 README.md
grep is Everywhere

grep stands for Global Regular Expression Print. It's one of the most powerful tools in Linux — you can pipe almost any command's output into grep to filter results.

Permissions.

Linux is a multi-user system. Every file has an owner and a set of permissions that control who can read, write, or execute it.

bash
# View permissions
$ ls -l src/main.js
-rw-r--r-- 1 user user 0 Jun 1 10:00 src/main.js
#  └┬┘└┬┘└┬┘
#   │  │  └── others : r-- (read only)
#   │  └───── group  : r-- (read only)
#   └──────── owner  : rw- (read + write)

# Make a script executable
$ chmod +x src/main.js
$ ls -l src/main.js
-rwxr-xr-x 1 user user 0 Jun 1 10:00 src/main.js

# Set exact permissions (rwxr-xr-x = 755)
$ chmod 755 src/main.js
$ ls -l src/main.js
-rwxr-xr-x 1 user user 0 Jun 1 10:00 src/main.js

# Change file owner
$ chown user:group README.md
$ ls -l README.md
-rw-r--r-- 1 user group 42 Jun 1 10:00 README.md
The 755 Pattern

Permissions are represented as three octal digits: owner / group / others. 7 = rwx, 5 = r-x, 4 = r--. 755 is the standard for executable scripts and directories.

Pipes & Power.

The real power of Linux comes from chaining commands together. The pipe | sends the output of one command as input to the next.

bash
# List files and filter with grep
$ ls -la | grep ".js"
-rwxr-xr-x 1 user user  512 Jun 1 10:00 main.js
-rw-r--r-- 1 user user  128 Jun 1 10:00 helpers.js

# Count how many .js files exist
$ find . -name "*.js" | wc -l
2

# Show the 3 largest files in src/
$ ls -lS src/ | head -3
total 8
-rwxr-xr-x 1 user user 512 Jun 1 10:00 main.js
-rw-r--r-- 1 user user 128 Jun 1 10:00 helpers.js

# Append a timestamp + message to a log
$ date >> logs/activity.log
$ echo "Build complete" >> logs/activity.log
$ cat logs/activity.log
Mon Jun  1 10:05:42 UTC 2026
Build complete
Composability

Linux commands are designed to do one thing well and work together. By combining find, grep, sort, head, and wc with pipes, you can answer almost any question about your system instantly.

Processes.

Every running program is a process. Linux gives you full visibility and control over what's running on your system.

bash
# List all running processes
$ ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY  STAT START   TIME COMMAND
user      1021  0.0  0.1  14232  2048 pts/0 Ss  10:00   0:00 bash
user      1234  0.3  1.2 512340 24576 pts/0 Sl  10:01   0:02 node server.js
user      1301  0.0  0.0  10860  1024 pts/0 R+  10:05   0:00 ps aux

# Find a process by name
$ ps aux | grep "node"
user      1234  0.3  1.2 512340 24576 pts/0 Sl  10:01   0:02 node server.js

# Kill a process gracefully
$ kill 1234
[1]+  Terminated              node server.js

# Run a command in the background
$ node server.js &
[1] 1456
Server listening on port 3000

# Force kill if it won't stop
$ kill -9 1456
[1]+  Killed                  node server.js
PIDs

Every process has a unique Process ID (PID). Use ps aux | grep processname to find the PID, then kill PID to stop it gracefully, or kill -9 PID to force-terminate it.

Environment.

Environment variables store configuration that programs can read. They're how you pass secrets, paths, and settings to your applications without hardcoding them.

bash
# Read specific variables
$ echo $HOME
/home/user

$ echo $USER
user

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

# Set a temporary variable (current session only)
$ export PROJECT_NAME="myproject"
$ echo $PROJECT_NAME
myproject

# Make it permanent — add to ~/.bashrc
$ echo 'export PROJECT_NAME="myproject"' >> ~/.bashrc
$ source ~/.bashrc
$ echo $PROJECT_NAME
myproject

# Create a .env file for the project
$ echo "PORT=3000" > .env
$ echo "DEBUG=true" >> .env
$ cat .env
PORT=3000
DEBUG=true
Never Commit .env

Your .env file often contains API keys and passwords. Always add it to .gitignore before committing. Use .env.example to document which variables are needed without exposing real values.

Terminal
Mastery.

You've built a full project workspace from scratch using only the terminal. Here's a quick reference of everything you've learned in this lab.

cheatsheet.sh
# Navigation
pwd | ls | ls -la | cd | cd .. | cd ~

# File & Directory Management
mkdir -p | touch | echo > | echo >> | cat
cp | cp -r | mv | rm | rm -rf

# Search & Inspect
grep -r | find . -name | wc -l | less

# Permissions
chmod +x | chmod 755 | chown user:group

# Pipes & Redirection
cmd1 | cmd2 | head | tail | sort | wc

# Processes
ps aux | top | kill | kill -9 | & | fg

# Environment
env | export VAR=value | source ~/.bashrc

Final Checklist

  • 1
    Did you create the full project directory structure?
  • 2
    Can you navigate, search, and manage files without a GUI?
  • 3
    Do you understand permissions and environment variables?