Welcome to Linux Basics with Git Bash Command Line by HitaVir Tech!
This hands-on codelab teaches you Linux command line skills using Git Bash on Windows. You do not need a Linux computer. You do not need any prior experience. By the end, you will navigate the terminal like a professional developer.
Throughout this codelab, you will build and manage a real developer workspace called hitavir-workspace entirely from the command line. You will:
Skill | Level |
Terminal navigation (pwd, ls, cd) | Beginner |
File management (mkdir, touch, cp, mv, rm) | Beginner |
Viewing files (cat, head, tail, less) | Beginner |
File permissions (ls -l, chmod) | Intermediate |
Searching (grep, find) | Intermediate |
Pipes and redirection | Intermediate |
Environment variables and productivity | Intermediate |
3-4 hours (go at your own pace — every section is self-contained)
HitaVir Tech says: "The terminal is your superpower. Once you learn it, you will wonder how you ever worked without it."
Before starting, make sure you have:
This codelab assumes zero experience with Linux, terminals, or command lines. We start from the very beginning.
HitaVir Tech says: "If you can type on a keyboard, you can learn the command line. It is that simple."
Git Bash gives you a Linux-like terminal on Windows. It understands the same commands used on Linux and Mac.
Go to https://git-scm.com/download/win
Download the 64-bit Windows installer.
Or open PowerShell and run:
winget install Git.Git
Press Win + S, type Git Bash, and open it.
You should see a window with a prompt like this:
user@COMPUTER MINGW64 ~
$
This is your terminal. The $ sign means it is ready for your commands.
Type this command and press Enter:
bash --version
Expected output:
GNU bash, version 5.2.26(1)-release (x86_64-pc-msys)
The version number may differ — any version 4+ is fine.
user@COMPUTER MINGW64 ~/projects
$ ls -la
│ │ │ │ └── The command you type
│ │ │ └── Dollar sign = ready for input
│ │ └── Current directory
│ └── System name
└── Your username
Problem | Solution |
"Git Bash not found" | Restart your computer after installation |
Blank or frozen screen | Press Enter — the terminal may be waiting |
Cannot paste text | Right-click to paste (Ctrl+V may not work) |
HitaVir Tech says: "Git Bash is your gateway to Linux on Windows. Treat it like your new best friend — you will be spending a lot of time together."
Before typing commands, let us understand what we are working with.
Linux is an operating system — like Windows or macOS — but it is free and open source. It powers:
You do not need to install Linux to learn its commands. Git Bash gives you the same tools on Windows.
A shell is a program that takes your typed commands and sends them to the operating system.
Think of it this way:
Concept | Real-World Analogy |
Operating System | The kitchen |
Shell | The waiter who takes your order |
Commands | Your food order |
Output | The food delivered to your table |
You tell the waiter (shell) what you want, and the waiter tells the kitchen (OS) to prepare it.
Git Bash is a shell for Windows that understands Linux commands. It combines:
Shell | Full Name | Used In |
bash | Bourne Again Shell | Linux, Mac, Git Bash |
zsh | Z Shell | Mac (default), Linux |
sh | Bourne Shell | Older Unix systems |
PowerShell | PowerShell | Windows |
cmd | Command Prompt | Windows (legacy) |
We will use Bash throughout this codelab because it is the industry standard.
HitaVir Tech says: "Learning Bash is like learning to drive a manual car. Once you know it, you can drive anything. The same commands work on Linux, Mac, servers, Docker containers, and cloud instances."
Time to type your first commands! Open Git Bash and follow along.
This command tells you where you are in the file system.
pwd
Expected output:
/c/Users/YourName
This is your home directory. Think of it as your desk — the default location where you start.
Real-world analogy: Imagine you are in a building. pwd is like asking "What room am I in right now?"
This command shows the files and folders in your current location.
ls
Expected output (example):
Desktop Documents Downloads Music Pictures Videos
These are the folders inside your home directory.
Add options to see more details:
ls -l
Expected output:
drwxr-xr-x 1 user group 0 Apr 5 10:00 Desktop
drwxr-xr-x 1 user group 0 Apr 5 10:00 Documents
drwxr-xr-x 1 user group 0 Apr 5 10:00 Downloads
The -l flag means "long format" — it shows permissions, owner, size, and date.
ls -la
The -a flag means "all" — it shows hidden files (files starting with .).
Expected output includes:
. .. .bashrc .gitconfig Desktop Documents ...
Files starting with . are hidden configuration files.
When your terminal gets cluttered:
clear
This clears all the text. Your previous commands are not deleted — just scrolled off screen.
Keyboard shortcut: Press Ctrl + L for the same effect.
Command | What It Does | Analogy |
| Show current location | "Where am I?" |
| List files and folders | "What is in this room?" |
| List with details | "Show me everything about this room" |
| List all including hidden | "Show me everything, even hidden items" |
| Clear the screen | "Clean the whiteboard" |
HitaVir Tech says: "pwd, ls, and clear are your three best friends. You will use them hundreds of times a day. Type them until they become muscle memory."
Mistake | Fix |
Typing | Linux commands are case-sensitive — use lowercase |
Adding spaces in wrong places |
|
Forgetting to press Enter | Commands only run when you press Enter |
The cd command lets you move between directories (folders).
The file system is like a tree:
/ ← Root (top of everything)
├── c/ ← Your C: drive
│ └── Users/
│ └── YourName/ ← Your home directory (~)
│ ├── Desktop/
│ ├── Documents/
│ └── Downloads/
├── tmp/ ← Temporary files
└── etc/ ← System configuration
Move into a folder:
cd Documents
Verify you moved:
pwd
Expected output:
/c/Users/YourName/Documents
cd ..
The .. means "parent directory" (one level up).
pwd
Expected output:
/c/Users/YourName
From anywhere, go straight home:
cd ~
Or simply:
cd
Both take you to your home directory.
Jump directly to any location:
cd /c/Users
cd -
This takes you back to wherever you were before. Like pressing the "Back" button.
Type | Example | Description |
Absolute path |
| Full path from root |
Relative path |
| Path relative to current location |
Real-world analogy:
cd ~
pwd
cd Documents
pwd
cd ..
pwd
cd /tmp
pwd
cd ~
pwd
Expected output pattern:
/c/Users/YourName
/c/Users/YourName/Documents
/c/Users/YourName
/tmp
/c/Users/YourName
Start typing a folder name and press Tab — Git Bash will auto-complete it:
cd Doc
Press Tab and it becomes:
cd Documents/
This saves time and prevents typos!
HitaVir Tech says: "Tab completion is your secret weapon. Press Tab early, press Tab often. It saves you from typos and speeds up your workflow by 10x."
Mistake | Fix |
| Case matters! Use |
| Use quotes: |
"No such file or directory" | Check spelling with |
You have completed the foundations! Here is what you learned:
pwdls and its optionscd (relative and absolute paths)clearNow let us start building things! We will create our project workspace.
Create a single folder:
cd ~
mkdir hitavir-workspace
Verify it was created:
ls
You should see hitavir-workspace in the list.
Create multiple levels at once with -p:
mkdir -p hitavir-workspace/projects/web-app
mkdir -p hitavir-workspace/projects/api
mkdir -p hitavir-workspace/logs
mkdir -p hitavir-workspace/backups
mkdir -p hitavir-workspace/config
ls hitavir-workspace
Expected output:
backups config logs projects
ls hitavir-workspace/projects
Expected output:
api web-app
mkdir -p hitavir-workspace/docs hitavir-workspace/scripts hitavir-workspace/temp
cd ~/hitavir-workspace
pwd
Expected output:
/c/Users/YourName/hitavir-workspace
hitavir-workspace/
├── backups/
├── config/
├── docs/
├── logs/
├── projects/
│ ├── api/
│ └── web-app/
├── scripts/
└── temp/
Real-world analogy: Creating directories is like organizing a filing cabinet. You create drawers (folders) and sub-drawers to keep everything organized.
HitaVir Tech says: "A well-organized directory structure is the sign of a professional developer. Take 5 minutes to plan your folders and save hours of confusion later."
Mistake | Fix |
| Use |
Space in folder name | Use quotes |
Creating in wrong location | Always check |
Now let us add files to our workspace.
cd ~/hitavir-workspace
touch README.md
touch .gitignore
Verify:
ls -la
You should see both files. Notice .gitignore starts with a dot — it is a hidden file.
touch projects/web-app/index.html projects/web-app/style.css projects/web-app/app.js
touch projects/api/server.py projects/api/requirements.txt
touch config/settings.conf config/database.conf
echo "# HitaVir Workspace" > README.md
The > writes text to a file (creates it if it does not exist, overwrites if it does).
echo "Created by HitaVir Tech" >> README.md
echo "Linux Basics Codelab Project" >> README.md
The >> appends text to the end of the file without deleting existing content.
echo "node_modules/" > .gitignore
echo "*.log" >> .gitignore
echo "__pycache__/" >> .gitignore
echo "APP_NAME=HitaVir-Workspace" > config/settings.conf
echo "APP_ENV=development" >> config/settings.conf
echo "APP_PORT=3000" >> config/settings.conf
echo "DEBUG=true" >> config/settings.conf
echo "DB_HOST=localhost" > config/database.conf
echo "DB_PORT=5432" >> config/database.conf
echo "DB_NAME=hitavir_db" >> config/database.conf
echo "DB_USER=admin" >> config/database.conf
echo "[2026-04-05 10:00:01] INFO: Server started on port 3000" > logs/app.log
echo "[2026-04-05 10:00:02] INFO: Database connected successfully" >> logs/app.log
echo "[2026-04-05 10:01:15] WARNING: High memory usage detected" >> logs/app.log
echo "[2026-04-05 10:02:30] ERROR: Failed to connect to cache server" >> logs/app.log
echo "[2026-04-05 10:03:00] INFO: Cache reconnected" >> logs/app.log
echo "[2026-04-05 10:05:22] ERROR: Timeout on /api/users endpoint" >> logs/app.log
echo "[2026-04-05 10:06:00] INFO: Request completed in 250ms" >> logs/app.log
echo "[2026-04-05 10:07:45] WARNING: Disk space below 10%" >> logs/app.log
echo "[2026-04-05 10:08:00] ERROR: Permission denied on /var/data" >> logs/app.log
echo "[2026-04-05 10:10:00] INFO: Daily backup completed" >> logs/app.log
cat > scripts/setup.sh << 'EOF'
#!/bin/bash
# HitaVir Workspace Setup Script
echo "Setting up HitaVir Workspace..."
echo "Creating directories..."
mkdir -p data output
echo "Setup complete!"
echo "Welcome to HitaVir Tech workspace!"
EOF
ls -la
ls projects/web-app/
ls config/
ls logs/
ls scripts/
HitaVir Tech says: "touch creates empty files. echo puts content inside files. Think of touch as placing an empty envelope, and echo as writing a letter and putting it inside."
The cp command copies files and folders.
cd ~/hitavir-workspace
cp README.md backups/README.md.bak
This creates a copy of README.md in the backups folder with a .bak extension.
cat backups/README.md.bak
Expected output:
# HitaVir Workspace
Created by HitaVir Tech
Linux Basics Codelab Project
The content is identical to the original.
cp config/settings.conf config/settings.conf.backup
cp -r projects/web-app projects/web-app-backup
The -r flag means "recursive" — copy the folder and everything inside it.
cp config/settings.conf config/database.conf backups/
This copies both files into the backups folder.
ls backups/
Expected output:
README.md.bak database.conf settings.conf
Command | What It Does |
| Copy file1 to file2 |
| Copy file1 into folder |
| Copy directory recursively |
| Copy multiple files into folder |
Real-world analogy: cp is like photocopying a document. The original stays where it is, and you get a new copy.
HitaVir Tech says: "Always keep backups! The cp command is your safety net. Before making risky changes, copy the original file first."
Mistake | Fix |
Forgetting |
|
Overwriting without warning | Use |
Wrong destination path | Always check with |
The mv command moves files to a new location OR renames them.
cd ~/hitavir-workspace
mv temp/nothing.txt docs/ 2>/dev/null
touch temp/notes.txt
echo "Temporary notes from HitaVir Tech session" > temp/notes.txt
mv temp/notes.txt docs/
Check both locations:
ls temp/
ls docs/
The file is gone from temp/ and now in docs/.
mv docs/notes.txt docs/session-notes.txt
This renames notes.txt to session-notes.txt. Same command, different use.
mv projects/web-app-backup backups/web-app-backup
Directories move without needing -r (unlike cp).
mkdir temp/old-logs
mv temp/old-logs temp/archived
ls temp/
Expected output:
archived
touch temp/file1.txt temp/file2.txt temp/file3.txt
mv temp/file1.txt temp/file2.txt temp/file3.txt docs/
ls docs/
Feature |
|
|
Original file | Removed | Stays |
Analogy | Relocating furniture | Photocopying a document |
Directories | No | Needs |
Can rename | Yes | Yes (but makes a copy) |
Real-world analogy: mv is like picking up a book from one shelf and putting it on another. cp is like making a photocopy — the original stays.
HitaVir Tech says: "Remember: mv is a Swiss army knife. It both moves AND renames. If the destination is a new name in the same folder, it renames. If the destination is a different folder, it moves."
rm -f temp/archived 2>/dev/null
rmdir temp/archived 2>/dev/null
Deleting in the terminal is permanent. There is no Recycle Bin.
cd ~/hitavir-workspace
touch temp/delete-me.txt
ls temp/
rm temp/delete-me.txt
ls temp/
The file is gone. Permanently.
Add -i to get a confirmation prompt:
touch temp/careful.txt
rm -i temp/careful.txt
Expected output:
rm: remove regular empty file 'temp/careful.txt'?
Type y and press Enter to confirm.
mkdir -p temp/test-dir/sub-dir
touch temp/test-dir/file.txt
touch temp/test-dir/sub-dir/deep-file.txt
Remove the entire directory tree:
rm -r temp/test-dir
Everything inside is deleted.
mkdir temp/empty-dir
rmdir temp/empty-dir
If the directory is not empty, rmdir will refuse:
mkdir temp/not-empty
touch temp/not-empty/file.txt
rmdir temp/not-empty
Expected output:
rmdir: failed to remove 'temp/not-empty': Directory not empty
Clean up:
rm -r temp/not-empty
Command | Risk Level | What Happens |
| Low | Deletes one file |
| Medium | Deletes folder and everything inside |
| HIGH | Force-deletes without any warnings |
| CATASTROPHIC | Attempts to delete your entire system |
ls first to see what will be deletedrm -i when unsurerm -rf / or rm -rf * without absolute certaintyHitaVir Tech says: "The terminal trusts you completely. If you say delete, it deletes — no questions asked (unless you use -i). With great power comes great responsibility."
Excellent! You have mastered file management. Here is what you learned:
mkdir and mkdir -ptouch and echocp and cp -rmvrm, rm -r, and rmdir> (overwrite) and >> (append)Now let us read what is inside files without opening an editor.
cd ~/hitavir-workspace
cat README.md
Expected output:
# HitaVir Workspace
Created by HitaVir Tech
Linux Basics Codelab Project
cat -n logs/app.log
Expected output:
1 [2026-04-05 10:00:01] INFO: Server started on port 3000
2 [2026-04-05 10:00:02] INFO: Database connected successfully
3 [2026-04-05 10:01:15] WARNING: High memory usage detected
4 [2026-04-05 10:02:30] ERROR: Failed to connect to cache server
5 [2026-04-05 10:03:00] INFO: Cache reconnected
6 [2026-04-05 10:05:22] ERROR: Timeout on /api/users endpoint
7 [2026-04-05 10:06:00] INFO: Request completed in 250ms
8 [2026-04-05 10:07:45] WARNING: Disk space below 10%
9 [2026-04-05 10:08:00] ERROR: Permission denied on /var/data
10 [2026-04-05 10:10:00] INFO: Daily backup completed
head logs/app.log
By default, shows the first 10 lines. Specify a number:
head -3 logs/app.log
Expected output:
[2026-04-05 10:00:01] INFO: Server started on port 3000
[2026-04-05 10:00:02] INFO: Database connected successfully
[2026-04-05 10:01:15] WARNING: High memory usage detected
tail logs/app.log
Show last 3 lines:
tail -3 logs/app.log
Expected output:
[2026-04-05 10:07:45] WARNING: Disk space below 10%
[2026-04-05 10:08:00] ERROR: Permission denied on /var/data
[2026-04-05 10:10:00] INFO: Daily backup completed
For long files, use less:
less logs/app.log
Inside less:
Key | Action |
| Scroll down one page |
| Scroll up one page |
| Scroll one line down |
| Scroll one line up |
| Search for text |
| Next search match |
| Quit |
Press q to exit less.
Count lines, words, and characters:
wc logs/app.log
Expected output:
10 62 560 logs/app.log
This means: 10 lines, 62 words, 560 characters.
Count only lines:
wc -l logs/app.log
Expected output:
10 logs/app.log
Display multiple files:
cat config/settings.conf config/database.conf
Command | What It Does | When to Use |
| Show entire file | Small files |
| Show with line numbers | Debugging |
| Show first 10 lines | Quick preview |
| Show first N lines | Specific preview |
| Show last 10 lines | Recent log entries |
| Show last N lines | Specific recent entries |
| Interactive viewer | Large files |
| Count lines | File statistics |
Real-world analogy: cat is reading the entire letter. head is reading just the greeting. tail is jumping to the signature. less is reading page by page.
HitaVir Tech says: "In real-world DevOps, tail is your go-to for reading logs. Servers generate thousands of lines — you almost always want to see just the latest entries."
You have already used echo and >. Let us understand redirection deeply.
The > operator sends command output to a file:
cd ~/hitavir-workspace
echo "This is line one" > docs/output.txt
cat docs/output.txt
Expected output:
This is line one
Using > again replaces the file content:
echo "This is NEW content" > docs/output.txt
cat docs/output.txt
Expected output:
This is NEW content
The old "This is line one" is gone.
Use >> to add without deleting:
echo "Line one" > docs/output.txt
echo "Line two" >> docs/output.txt
echo "Line three" >> docs/output.txt
cat docs/output.txt
Expected output:
Line one
Line two
Line three
Save ls output to a file:
ls -la > docs/file-listing.txt
cat docs/file-listing.txt
Save date and system info:
echo "Report generated on: $(date)" > docs/report.txt
echo "Current directory: $(pwd)" >> docs/report.txt
echo "Files in workspace:" >> docs/report.txt
ls >> docs/report.txt
cat docs/report.txt
Operator | What It Does | Example |
| Write to file (overwrite) |
|
| Append to file |
|
| Redirect errors to file |
|
| Redirect all output to file |
|
HitaVir Tech says: "Think of > as a bulldozer — it flattens everything and starts fresh. Think of >> as a bricklayer — it adds on top of what is already there."
Every file in Linux has permissions that control who can read, write, and execute it.
cd ~/hitavir-workspace
ls -l scripts/setup.sh
Expected output:
-rw-r--r-- 1 user group 156 Apr 5 10:00 scripts/setup.sh
Let us break this down:
-rw-r--r-- 1 user group 156 Apr 5 10:00 scripts/setup.sh
│├──┤├──┤├──┤ │ │ │ │ │
│ │ │ │ │ │ │ │ └── File name
│ │ │ │ │ │ │ └── Date modified
│ │ │ │ │ │ └── Size in bytes
│ │ │ │ │ └── Group owner
│ │ │ │ └── File owner
│ │ │ └── Others permissions (r--)
│ │ └── Group permissions (r--)
│ └── Owner permissions (rw-)
└── File type (- = file, d = directory)
Character | Meaning | Number |
| Read (view content) | 4 |
| Write (modify content) | 2 |
| Execute (run as program) | 1 |
| No permission | 0 |
Position | Who |
First 3 chars (rw-) | Owner — the user who created the file |
Middle 3 chars (r–) | Group — users in the same group |
Last 3 chars (r–) | Others — everyone else |
Make a file executable:
chmod +x scripts/setup.sh
ls -l scripts/setup.sh
Expected output:
-rwxr-xr-x 1 user group 156 Apr 5 10:00 scripts/setup.sh
Notice the x appeared in all three groups.
./scripts/setup.sh
Expected output:
Setting up HitaVir Workspace...
Creating directories...
Setup complete!
Welcome to HitaVir Tech workspace!
Each permission has a number value. Add them up for each group:
Permission | Calculation | Total |
rwx | 4+2+1 | 7 |
rw- | 4+2+0 | 6 |
r-x | 4+0+1 | 5 |
r– | 4+0+0 | 4 |
chmod 755 scripts/setup.sh
ls -l scripts/setup.sh
Expected output:
-rwxr-xr-x 1 user group 156 Apr 5 10:00 scripts/setup.sh
755 means: owner=rwx(7), group=r-x(5), others=r-x(5).
Number | Permissions | Common Use |
| rw-r–r– | Regular files |
| rwxr-xr-x | Executable scripts |
| rw——- | Private files (passwords, keys) |
| rwx—— | Private executable scripts |
| rwxrwxrwx | Everyone can do everything (avoid this!) |
Real-world analogy: Permissions are like access cards in an office building. The owner has the master key, the group has department access, and others can only enter the lobby.
HitaVir Tech says: "Never use chmod 777 in production. It is like leaving your front door wide open with a sign that says ‘Come in and take whatever you want.' Use the minimum permissions needed."
Great work! Here is what you learned:
cat, head, tail, and lesswc -l> (overwrite) and >> (append)chmodgrep is one of the most powerful Linux commands. It searches for text patterns inside files.
Search for the word "ERROR" in our log file:
cd ~/hitavir-workspace
grep "ERROR" logs/app.log
Expected output:
[2026-04-05 10:02:30] ERROR: Failed to connect to cache server
[2026-04-05 10:05:22] ERROR: Timeout on /api/users endpoint
[2026-04-05 10:08:00] ERROR: Permission denied on /var/data
Only lines containing "ERROR" are shown.
grep -i "error" logs/app.log
The -i flag ignores case — matches ERROR, error, Error, etc.
grep -n "ERROR" logs/app.log
Expected output:
4:[2026-04-05 10:02:30] ERROR: Failed to connect to cache server
6:[2026-04-05 10:05:22] ERROR: Timeout on /api/users endpoint
9:[2026-04-05 10:08:00] ERROR: Permission denied on /var/data
grep -c "ERROR" logs/app.log
Expected output:
3
Three lines contain "ERROR".
grep -v "INFO" logs/app.log
Expected output:
[2026-04-05 10:01:15] WARNING: High memory usage detected
[2026-04-05 10:02:30] ERROR: Failed to connect to cache server
[2026-04-05 10:05:22] ERROR: Timeout on /api/users endpoint
[2026-04-05 10:07:45] WARNING: Disk space below 10%
[2026-04-05 10:08:00] ERROR: Permission denied on /var/data
All lines except INFO lines.
grep "localhost" config/*.conf
Expected output:
config/database.conf:DB_HOST=localhost
grep -r "HitaVir" .
This searches every file in every subdirectory for "HitaVir".
Show lines around the match:
grep -B 1 -A 1 "ERROR" logs/app.log
-B 1 shows 1 line Before the match-A 1 shows 1 line After the matchOption | What It Does | Example |
| Case insensitive |
|
| Show line numbers |
|
| Count matches |
|
| Invert (lines NOT matching) |
|
| Recursive (search subdirectories) |
|
| Show only filenames |
|
| Show N lines before match |
|
| Show N lines after match |
|
Real-world analogy: grep is like Ctrl+F in your browser, but supercharged. It can search across thousands of files in seconds.
HitaVir Tech says: "grep is the command you will use most in real-world DevOps. Server crashes at 3 AM? You grep the logs. Customer reports a bug? You grep for their user ID. Master grep and you will solve problems 10x faster."
find searches for files and directories by name, type, size, or age.
cd ~/hitavir-workspace
find . -name "*.txt"
Expected output:
./docs/session-notes.txt
./docs/output.txt
./docs/file-listing.txt
./docs/report.txt
./docs/file1.txt
./docs/file2.txt
./docs/file3.txt
./projects/api/requirements.txt
The . means "search from current directory". *.txt matches any file ending in .txt.
Find only directories:
find . -type d
Find only files:
find . -type f
find . -iname "*.conf"
Expected output:
./config/settings.conf
./config/settings.conf.backup
./config/database.conf
find . -type f | wc -l
This counts how many files exist in the workspace.
find . -name "*.js"
find . -name "*.py"
find . -name "*.html"
Command | What It Finds |
| Files ending in .txt |
| Directories only |
| Files only |
| Case-insensitive name search |
| Log files |
Real-world analogy: find is like a search dog that you send into a building. You tell it what to look for (name, type, size), and it searches every room and reports back.
HitaVir Tech says: "find + grep is the ultimate combo. Use find to locate files, then grep to search inside them. Together, they can answer any question about your codebase."
Pipes (|) connect commands together. The output of one command becomes the input of the next.
Command1 | Command2 | Command3
↓ ↓ ↓
Output → becomes Input → becomes Input → Final Output
cd ~/hitavir-workspace
grep "ERROR" logs/app.log | wc -l
Expected output:
3
How it works: grep finds ERROR lines → sends them to wc -l → counts them.
ls -lS | head -5
ls -lS lists files sorted by Size → head -5 shows only the top 5.
find . -name "*.conf" | xargs grep "localhost"
find locates .conf files → xargs grep searches inside each one.
grep -o "INFO\|WARNING\|ERROR" logs/app.log | sort | uniq -c | sort -rn
Expected output:
5 INFO
3 ERROR
2 WARNING
How it works:
grep -o extracts just the matched wordssort puts them in orderuniq -c counts duplicatessort -rn sorts by count (highest first)history | grep "mkdir"
Shows all previous mkdir commands you typed.
ls -l | grep "^d"
Lines starting with d are directories.
echo "=== Log Analysis Report ===" > docs/log-report.txt
echo "Generated: $(date)" >> docs/log-report.txt
echo "" >> docs/log-report.txt
echo "Total log entries:" >> docs/log-report.txt
wc -l < logs/app.log >> docs/log-report.txt
echo "" >> docs/log-report.txt
echo "Errors:" >> docs/log-report.txt
grep -c "ERROR" logs/app.log >> docs/log-report.txt
echo "" >> docs/log-report.txt
echo "Warnings:" >> docs/log-report.txt
grep -c "WARNING" logs/app.log >> docs/log-report.txt
echo "" >> docs/log-report.txt
echo "Error details:" >> docs/log-report.txt
grep "ERROR" logs/app.log >> docs/log-report.txt
cat docs/log-report.txt
Expected output:
=== Log Analysis Report ===
Generated: Sat Apr 5 10:30:00 2026
Total log entries:
10
Errors:
3
Warnings:
2
Error details:
[2026-04-05 10:02:30] ERROR: Failed to connect to cache server
[2026-04-05 10:05:22] ERROR: Timeout on /api/users endpoint
[2026-04-05 10:08:00] ERROR: Permission denied on /var/data
You just built a log analysis tool using only pipes and redirection!
Pattern | What It Does |
| Show first few results |
| Show last few results |
| Count results |
| Sort results |
| Filter results |
| Remove duplicates |
HitaVir Tech says: "Pipes are the magic of Linux. Each command does one small thing well. Pipes let you chain them together to do powerful things. This is the Unix philosophy — small tools, big results."
Environment variables store system-wide settings. Productivity tools save you time every day.
echo $HOME
Expected output:
/c/Users/YourName
echo $PATH
This shows all directories where the system looks for commands.
echo $USER
Shows your username.
Variable | What It Stores |
| Your home directory |
| Where to find programs |
| Your username |
| Your current shell |
| Current directory |
MY_PROJECT="hitavir-workspace"
echo $MY_PROJECT
Expected output:
hitavir-workspace
export MY_NAME="HitaVir Tech"
echo "Welcome, $MY_NAME!"
history
Shows all commands you have typed. Each has a number.
history | tail -10
Shows the last 10 commands.
!!
Runs the last command again.
!50
Runs command number 50 from history.
alias ll='ls -la'
alias cls='clear'
alias workspace='cd ~/hitavir-workspace'
Now try them:
workspace
ll
Shortcut | Action |
| Cancel current command |
| Clear screen (same as |
| Search command history (reverse search) |
| Move cursor to beginning of line |
| Move cursor to end of line |
| Delete from cursor to beginning |
| Delete from cursor to end |
| Auto-complete file/directory names |
| Show all possible completions |
| Previous command |
| Next command |
This is the most useful shortcut. Press Ctrl + R and start typing. It searches your history:
(reverse-i-search)`gre': grep "ERROR" logs/app.log
Press Enter to run the matched command, or Ctrl + R again for the next match.
Add aliases to your ~/.bashrc file:
echo "" >> ~/.bashrc
echo "# HitaVir Tech Custom Aliases" >> ~/.bashrc
echo "alias ll='ls -la'" >> ~/.bashrc
echo "alias cls='clear'" >> ~/.bashrc
echo "alias workspace='cd ~/hitavir-workspace'" >> ~/.bashrc
Reload the configuration:
source ~/.bashrc
Now your aliases will work every time you open Git Bash.
HitaVir Tech says: "Productivity in the terminal is all about saving keystrokes. Aliases, tab completion, and Ctrl+R will save you hours every week. The fastest developers are not the fastest typists — they are the ones who type the least."
Outstanding! You have completed the Intermediate Level. Here is what you learned:
grep and all its optionsfind|)>, >>) to save output$HOME, $PATH, custom)Let us bring everything together with a realistic developer workflow simulation.
You are a junior DevOps engineer at HitaVir Tech. Your manager asks you to:
cd ~/hitavir-workspace
mkdir -p deployment/{staging,production,scripts,logs,configs}
Verify:
ls deployment/
Expected output:
configs logs production scripts staging
cat > deployment/configs/staging.env << 'EOF'
APP_ENV=staging
APP_URL=https://staging.hitavir.tech
DB_HOST=staging-db.hitavir.tech
DB_PORT=5432
DB_NAME=hitavir_staging
REDIS_HOST=staging-cache.hitavir.tech
LOG_LEVEL=debug
MAX_WORKERS=2
EOF
cat > deployment/configs/production.env << 'EOF'
APP_ENV=production
APP_URL=https://hitavir.tech
DB_HOST=prod-db.hitavir.tech
DB_PORT=5432
DB_NAME=hitavir_prod
REDIS_HOST=prod-cache.hitavir.tech
LOG_LEVEL=warning
MAX_WORKERS=8
EOF
cat > deployment/scripts/deploy.sh << 'SCRIPT'
#!/bin/bash
# HitaVir Tech Deployment Script
# Usage: ./deploy.sh [staging|production]
ENV=${1:-staging}
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
echo "================================================"
echo " HitaVir Tech Deployment Tool"
echo " Environment: $ENV"
echo " Timestamp: $TIMESTAMP"
echo "================================================"
echo ""
echo "[1/4] Loading configuration..."
echo "[2/4] Running pre-deployment checks..."
echo "[3/4] Deploying application..."
echo "[4/4] Running health checks..."
echo ""
echo "Deployment to $ENV completed successfully!"
echo "Log saved to: deployment/logs/deploy_${ENV}_${TIMESTAMP}.log"
SCRIPT
chmod +x deployment/scripts/deploy.sh
cat > deployment/logs/staging-app.log << 'EOF'
[2026-04-05 08:00:01] INFO: Application starting in staging mode
[2026-04-05 08:00:02] INFO: Loading configuration from staging.env
[2026-04-05 08:00:03] INFO: Connected to database staging-db.hitavir.tech
[2026-04-05 08:00:04] INFO: Redis cache connected
[2026-04-05 08:01:00] INFO: Health check passed
[2026-04-05 08:15:30] WARNING: Slow query detected (2.3s) on /api/reports
[2026-04-05 08:20:00] INFO: Request from 192.168.1.100 - GET /api/users - 200
[2026-04-05 08:20:05] INFO: Request from 192.168.1.101 - POST /api/orders - 201
[2026-04-05 08:25:10] ERROR: Connection refused to payment gateway
[2026-04-05 08:25:15] ERROR: Retry 1/3 - payment gateway connection
[2026-04-05 08:25:20] INFO: Payment gateway reconnected
[2026-04-05 08:30:00] INFO: Scheduled job: cleanup temp files
[2026-04-05 08:45:00] WARNING: Memory usage at 78%
[2026-04-05 09:00:00] INFO: Hourly metrics report generated
[2026-04-05 09:15:30] ERROR: Disk write failed on /tmp/upload_cache
[2026-04-05 09:15:35] WARNING: Fallback to memory cache activated
[2026-04-05 09:30:00] INFO: SSL certificate valid for 45 days
[2026-04-05 09:45:00] INFO: Auto-scaling triggered: 2 -> 3 instances
[2026-04-05 10:00:00] ERROR: Unhandled exception in worker thread 2
[2026-04-05 10:00:05] INFO: Worker thread 2 restarted
[2026-04-05 10:30:00] INFO: Daily backup initiated
EOF
Task 1: How many errors?
grep -c "ERROR" deployment/logs/staging-app.log
Expected output: 4
Task 2: Show all errors with line numbers
grep -n "ERROR" deployment/logs/staging-app.log
Task 3: Count each log level
grep -o "INFO\|WARNING\|ERROR" deployment/logs/staging-app.log | sort | uniq -c | sort -rn
Expected output:
13 INFO
4 ERROR
3 WARNING
Task 4: Find all IP addresses in the logs
grep -o "[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}" deployment/logs/staging-app.log
Expected output:
192.168.1.100
192.168.1.101
Task 5: Show errors with surrounding context
grep -B 1 -A 1 "ERROR" deployment/logs/staging-app.log
cat > deployment/scripts/report.sh << 'REPORT'
#!/bin/bash
# HitaVir Tech Log Analysis Report Generator
LOG_FILE="deployment/logs/staging-app.log"
REPORT_FILE="deployment/logs/status-report.txt"
echo "============================================" > $REPORT_FILE
echo " HitaVir Tech - System Status Report" >> $REPORT_FILE
echo " Generated: $(date)" >> $REPORT_FILE
echo "============================================" >> $REPORT_FILE
echo "" >> $REPORT_FILE
echo "--- Log Summary ---" >> $REPORT_FILE
echo "Total entries: $(wc -l < $LOG_FILE)" >> $REPORT_FILE
echo "INFO count: $(grep -c 'INFO' $LOG_FILE)" >> $REPORT_FILE
echo "WARNING count: $(grep -c 'WARNING' $LOG_FILE)" >> $REPORT_FILE
echo "ERROR count: $(grep -c 'ERROR' $LOG_FILE)" >> $REPORT_FILE
echo "" >> $REPORT_FILE
echo "--- Error Details ---" >> $REPORT_FILE
grep "ERROR" $LOG_FILE >> $REPORT_FILE
echo "" >> $REPORT_FILE
echo "--- Warning Details ---" >> $REPORT_FILE
grep "WARNING" $LOG_FILE >> $REPORT_FILE
echo "" >> $REPORT_FILE
echo "--- System Health ---" >> $REPORT_FILE
echo "Config files: $(find deployment/configs -type f | wc -l)" >> $REPORT_FILE
echo "Log files: $(find deployment/logs -type f | wc -l)" >> $REPORT_FILE
echo "Scripts: $(find deployment/scripts -type f | wc -l)" >> $REPORT_FILE
echo "" >> $REPORT_FILE
echo "Report complete." >> $REPORT_FILE
REPORT
chmod +x deployment/scripts/report.sh
Run the report:
cd ~/hitavir-workspace
bash deployment/scripts/report.sh
cat deployment/logs/status-report.txt
cd ~/hitavir-workspace
mkdir -p backups/archive-$(date +%Y%m%d)
cp deployment/logs/staging-app.log backups/archive-$(date +%Y%m%d)/
cp deployment/logs/status-report.txt backups/archive-$(date +%Y%m%d)/
cp -r deployment/configs backups/archive-$(date +%Y%m%d)/
ls backups/archive-$(date +%Y%m%d)/
cd ~/hitavir-workspace
./deployment/scripts/deploy.sh staging
Expected output:
================================================
HitaVir Tech Deployment Tool
Environment: staging
Timestamp: 20260405_103000
================================================
[1/4] Loading configuration...
[2/4] Running pre-deployment checks...
[3/4] Deploying application...
[4/4] Running health checks...
Deployment to staging completed successfully!
Log saved to: deployment/logs/deploy_staging_20260405_103000.log
hitavir-workspace/
├── README.md
├── .gitignore
├── backups/
│ ├── archive-20260405/
│ ├── README.md.bak
│ └── web-app-backup/
├── config/
│ ├── settings.conf
│ ├── settings.conf.backup
│ └── database.conf
├── deployment/
│ ├── configs/
│ │ ├── staging.env
│ │ └── production.env
│ ├── logs/
│ │ ├── staging-app.log
│ │ └── status-report.txt
│ ├── scripts/
│ │ ├── deploy.sh
│ │ └── report.sh
│ ├── staging/
│ └── production/
├── docs/
├── logs/
│ └── app.log
├── projects/
│ ├── api/
│ └── web-app/
├── scripts/
│ └── setup.sh
└── temp/
HitaVir Tech says: "You just did what junior DevOps engineers do every day — set up deployments, analyze logs, generate reports, and manage files. These are not toy exercises. This is real-world work."
When things go wrong, here is how to fix them.
bash: somecmd: command not found
Causes and fixes:
Cause | Fix |
Typo in command | Check spelling |
Command not installed | Install the package |
Wrong case | Use lowercase ( |
PATH not set | Check |
bash: ./script.sh: Permission denied
Fix:
chmod +x script.sh
ls: cannot access 'myfile': No such file or directory
Fix:
pwd
ls
Check you are in the right directory and the file name is correct.
Situation | Fix |
Command running too long | Press |
Screen looks stuck | Press |
Stuck in a program (less, vim) | Press |
Accidentally opened vim | Type |
When using * with too many files:
# Instead of: rm *.log
find . -name "*.log" -exec rm {} \;
Unfortunately, there is no undo. Prevention is the best cure:
rm -i for interactive confirmationpwd before running destructive commandsHitaVir Tech says: "Every developer has accidentally deleted something important at least once. That is how we learn to make backups. The terminal is powerful — and power demands respect."
Congratulations! You have completed Linux Basics with Git Bash Command Line by HitaVir Tech!
Level | Skills Mastered |
Beginner | Terminal basics, navigation, pwd, ls, cd, clear |
File Management | mkdir, touch, cp, mv, rm, rmdir |
File Viewing | cat, head, tail, less, wc, echo |
Permissions | ls -l, chmod, file ownership |
Intermediate | grep, find, pipes, redirection |
Productivity | history, alias, env variables, shortcuts |
Real-World | Log analysis, scripting, deployment workflows |
ls works, LS does notHitaVir Tech says: "You have gone from zero to confident in the Linux command line. This is a skill that will serve you for your entire career. Keep practicing, keep exploring, and keep building."
Topic | Why It Matters |
Shell Scripting (Bash) | Automate complex workflows |
Docker | Container management is all CLI |
SSH | Remote server access |
vim or nano | Terminal-based text editors |
awk and sed | Advanced text processing |
cron jobs | Scheduled tasks |
systemd | Service management |
Networking (curl, wget, ping) | API testing and monitoring |
HitaVir Tech says: "The best way to learn Linux is to use it every day. Make the terminal your default tool — not a last resort. Every command you type makes you better."
Save this reference for daily use!
pwd # Where am I?
ls # List files
ls -la # List all with details
cd folder # Enter folder
cd .. # Go up one level
cd ~ # Go home
cd - # Go to previous directory
clear # Clear screen (or Ctrl+L)
mkdir folder # Create directory
mkdir -p a/b/c # Create nested directories
touch file.txt # Create empty file
cp file1 file2 # Copy file
cp -r dir1 dir2 # Copy directory
mv file1 file2 # Move or rename
rm file # Delete file
rm -r folder # Delete directory
rm -i file # Delete with confirmation
rmdir folder # Delete empty directory
cat file # View entire file
cat -n file # View with line numbers
head file # First 10 lines
head -N file # First N lines
tail file # Last 10 lines
tail -N file # Last N lines
less file # Interactive viewer (q to quit)
wc -l file # Count lines
echo "text" > file # Write (overwrite)
echo "text" >> file # Append
command > file # Save command output
command >> file # Append command output
grep "text" file # Search in file
grep -i "text" file # Case insensitive
grep -n "text" file # With line numbers
grep -c "text" file # Count matches
grep -r "text" . # Search recursively
grep -v "text" file # Lines NOT matching
find . -name "*.txt" # Find files by name
find . -type d # Find directories
find . -type f # Find files
ls -l file # View permissions
chmod +x script.sh # Make executable
chmod 755 script.sh # Set specific permissions
chmod 644 file.txt # Standard file permissions
cmd1 | cmd2 # Pipe output to next command
cmd | grep "text" # Filter output
cmd | wc -l # Count output lines
cmd | sort # Sort output
cmd | head -N # First N lines of output
cmd | sort | uniq -c # Count unique values
history # View command history
!! # Repeat last command
alias name='command' # Create shortcut
echo $HOME # Show environment variable
export VAR="value" # Set variable
Ctrl+C # Cancel command
Ctrl+R # Search history
Tab # Auto-complete
Here are 15 real-world interview questions with concise answers.
Answer: An absolute path starts from the root (/) and specifies the full location, like /home/user/docs. A relative path starts from the current directory, like ../docs. Absolute paths work from anywhere; relative paths depend on where you are.
chmod 755 mean?Answer: It sets permissions to rwxr-xr-x. Owner gets read+write+execute (7), group gets read+execute (5), others get read+execute (5). This is the standard permission for executable scripts.
> and >>?Answer: > overwrites the file with new content (creates it if it does not exist). >> appends to the end of the file without deleting existing content.
Answer: Use grep "word" filename. Add -i for case-insensitive search, -r for recursive search across directories, and -n for line numbers.
| (pipe) do?Answer: The pipe takes the output of one command and sends it as input to the next command. For example, ls | grep ".txt" lists files and then filters for .txt files only.
rm and rmdir?Answer: rmdir only removes empty directories. rm -r removes directories and all their contents recursively. rm without -r removes only files.
Answer: Use find /path -name "*.log". Add -type f to ensure only files (not directories) are returned.
ls -la show?Answer: It shows all files including hidden ones (-a) in long format (-l). Long format displays permissions, owner, group, size, modification date, and filename.
Answer: Run chmod +x script.sh to add execute permission. Then run it with ./script.sh. Without the execute permission, the shell refuses to run it.
$PATH variable?Answer: $PATH is a colon-separated list of directories where the shell looks for executable programs. When you type a command, the shell searches these directories in order.
cp and mv?Answer: cp creates a copy of the file — the original remains. mv moves the file — the original is removed from its old location. mv can also rename files.
Answer: Use tail -20 filename. tail shows the end of a file. Combine with -f (tail -f filename) to watch a file in real-time as new lines are added.
Answer: Files whose names start with a dot (.) are hidden. They do not appear in regular ls output. Use ls -a to see them. Configuration files like .bashrc and .gitconfig are typically hidden.
Answer: Use wc -l filename. The -l flag counts lines only. Without flags, wc shows lines, words, and characters.
~ in paths?Answer: ~ is a shortcut for the current user's home directory. cd ~ and cd $HOME both take you to your home directory. ~/Documents means the Documents folder inside your home.
rm -i, checking pwd)> and >> — interviewers love this questionHitaVir Tech says: "In Linux interviews, they are not testing your memory. They are testing your understanding. If you have worked through this entire codelab hands-on, you understand these concepts deeply. That is what matters."
You have successfully completed Linux Basics with Git Bash Command Line - Beginner to Intermediate!
Tell the world you completed this codelab. Every command you typed made you a better developer.
Happy command-lining!