How to use a Linux terminal! [full tutorial]

Started by Error2 replies20 views

🐧 COMPLETE LINUX TERMINAL MINI-COURSE (ZERO TO HERO)
Everything you need: Navigation, Permissions, Git, Python, Networking, Nmap, Scripting & Ready-to-Use Kits.


[/HR]

1. Navigation & File Management (The Absolute Basics)
Before hacking or coding, you need to know how to move around without a mouse.
  • pwd β€” Shows your exact current folder path.
  • ls -la β€” Lists ALL files (including hidden ones starting with .) with permissions and sizes.
  • cd folder_name β€” Enters a directory. Use cd .. to go back one folder, or cd ~ to jump straight to your Home folder.
  • mkdir -p project/src β€” Creates a folder (and parent folders if they don't exist).
  • touch script.py β€” Creates a blank file immediately.
  • cp -r folder1 folder2 β€” Copies files or entire folders (-r = recursive).
  • mv old.txt new.txt β€” Moves or renames a file/folder.
  • rm -rf folder_name β€” Force-deletes a folder and everything inside. WARNING: Permanent deletion. No Trash bin!


[/HR]

2. Reading, Editing & Searching Files
Stop opening heavy text editors just to read or tweak a config file.
  • cat file.txt β€” Dumps the entire file content into the terminal.
  • head -n 20 file.txt / tail -n 20 file.txt β€” Shows only the first or last 20 lines (great for massive logs).
  • nano file.txt β€” Opens a simple terminal text editor. (Save: CTRL + O -> Enter | Exit: CTRL + X).
  • grep -i "password" file.txt β€” Searches for a word inside a file (-i ignores uppercase/lowercase).
  • find / -name "secret.txt" 2>/dev/null β€” Searches the entire system for a file by name while hiding permission errors.


[/HR]

3. Permissions & Root (Admin Power)
Linux security is strict. If a script won't run, it's usually a permission issue.
bash
# Run a command as Administrator (Root):
sudo apt update

# Switch to full Root shell (be careful!):
sudo su

# Make a downloaded script or binary executable:
chmod +x tool.sh

# Give full read/write/execute permissions (777):
chmod 777 file.txt

# Change file owner to your user:
sudo chown $USER:$USER file.txt


[/HR]

4. Installing "The Master Kit" (All-in-One Setup)
Fresh Linux installs lack basic tools. Copy and paste the command for your distro to install Git, Python3, Pip, Nmap, Curl, Wget, Net-Tools, Htop, Tmux & Unzip all at once:

β–Ά Ubuntu / Debian / Kali / Parrot / Mint:
bash
sudo apt update && sudo apt upgrade -y && sudo apt install -y git python3 python3-pip python3-venv nmap curl wget net-tools htop tmux unzip build-essential

β–Ά Arch Linux / Manjaro / EndeavourOS:
bash
sudo pacman -Syu --noconfirm && sudo pacman -S --noconfirm git python python-pip nmap curl wget net-tools htop tmux unzip base-devel

β–Ά Fedora / RHEL / CentOS:
bash
sudo dnf update -y && sudo dnf install -y git python3 python3-pip nmap curl wget net-tools htop tmux unzip @development-tools


[/HR]

5. How to Clone & Use GitHub Repositories
90% of open-source tools live on GitHub. Here is the exact workflow to download and run them:
bash
# 1. Copy (clone) a repository to your machine:
git clone [hidden link]

# 2. Enter the downloaded folder:
cd repository-name

# 3. Check what files are inside (look for README.md, requirements.txt, or .sh/.py files):
ls -la

# 4. Update a repo later when the creator releases new code:
git pull


[/HR]

6. How to Run Python Tools & Virtual Environments (venv)
Modern Linux systems block global pip install to protect the OS. Always use a Virtual Environment (venv) when running Python tools from GitHub:
bash
# 1. Create an isolated environment inside the tool's folder:
python3 -m venv venv

# 2. Activate the environment (your terminal prompt will change to show "(venv)"):
source venv/bin/activate

# 3. Install the tool's dependencies:
pip install -r requirements.txt

# 4. Run the Python script:
python3 main.py

# 5. Exit the virtual environment when finished:
deactivate


[/HR]

7. Networking, SSH & Nmap Essentials
Check connections, download files, connect to remote servers, and scan networks.
bash
# Check your local IP address:
ip a

# Check your public IP address:
curl ifconfig.me

# Download a file directly from a URL:
wget [hidden link]

# Connect to a remote Linux server (VPS) via SSH:
ssh [email protected]

# Start a quick local HTTP server to share files from your current folder:
python3 -m http.server 8000

πŸ” Nmap Cheat Sheet (Network Scanning):
bash
# Fast scan of top 100 ports on a target:
nmap -F 192.168.1.1

# Detailed scan (Service versions + Default scripts + OS detection):
sudo nmap -sC -sV -O 192.168.1.1

# Scan all 65,535 ports quickly:
nmap -p- -T4 192.168.1.1


[/HR]

8. Process Control, Piping & Terminal God-Mode
Combine commands and manage background tasks like a pro:
  • ps aux | grep python β€” Finds all running Python processes and their PID (Process ID).
  • kill -9 1234 β€” Force-kills a frozen program using its PID (1234).
  • command1 && command2 β€” Runs command 2 only if command 1 succeeds.
  • command > output.txt β€” Saves command output to a file (overwrites). Use >> to append without erasing.
  • TAB β€” Auto-completes commands and file paths.
  • CTRL + R β€” Searches your command history as you type.
  • sudo !! β€” Repeats your last command with sudo in front.

⚑ Bonus: Create Your Own Shortcuts (Aliases)
Run this once to create a custom command called update that updates your whole Ubuntu/Debian system:
echo 'alias update="sudo apt update && sudo apt upgrade -y"' >> ~/.bashrc && source ~/.bashrc

Bookmark this thread for quick reference. Drop your favorite commands below! πŸ‘‡

Last edited by Error

Like1
🐧 LINUX TERMINAL: BONUS POWER PACK
5 PRACTICAL KITS | MORE SKILLS, LESS THEORY
A companion to the original Linux Terminal Mini-Course. Five additional workflows for troubleshooting, backups, automation, project setup and security checks.
Copy. Understand. Customize.



πŸ–₯ KIT 01 | System Health Dashboard
Goal: Check CPU load, RAM, disk space and the processes consuming the most resources.
bash
echo '=== SYSTEM ==='
uname -sr
uptime

echo '=== MEMORY ==='
free -h

echo '=== STORAGE ==='
df -h

echo '=== TOP CPU PROCESSES ==='
ps -eo pid,comm,%cpu,%mem --sort=-%cpu | head -n 8
What you learn:
β€’ uptime displays how long Linux has been running and its load averages.
β€’ free -h reports memory and swap usage in readable units.
β€’ df -h reports available space on mounted filesystems.
β€’ ps --sort=-%cpu places high-CPU processes at the top.



πŸ“¦ KIT 02 | Backup and Verify a Project
Goal: Create a timestamped compressed backup and check that the archive can be read.
bash
mkdir -p "$HOME/demo-project"
printf 'Backup test\n' > "$HOME/demo-project/notes.txt"

STAMP=$(date +%Y%m%d_%H%M%S)
ARCHIVE="$HOME/demo-project-$STAMP.tar.gz"

tar -czf "$ARCHIVE" -C "$HOME" demo-project

echo '=== ARCHIVE CONTENTS ==='
tar -tzf "$ARCHIVE"

echo '=== SHA-256 ==='
sha256sum "$ARCHIVE"
What you learn:
β€’ tar -czf creates a gzip-compressed archive.
β€’ tar -tzf lists files inside an archive without extracting them.
β€’ sha256sum generates a fingerprint useful for later integrity checks.



🐍 KIT 03 | Python Project in 30 Seconds
Goal: Set up a clean project without modifying system-wide Python packages.
bash
mkdir -p "$HOME/python-lab"
cd "$HOME/python-lab"

python3 -m venv .venv
source .venv/bin/activate

cat > main.py <<'PY'
from pathlib import Path
print('Python is ready!')
print('Project:', Path.cwd())
PY

python main.py
python -m pip --version
deactivate
What you learn:
β€’ venv isolates project dependencies.
β€’ source activates the environment in Bash.
β€’ cat > file writes text into a file; an existing file will be replaced.
β€’ deactivate returns to your normal shell environment.



🌐 KIT 04 | Network Troubleshooting
Goal: Find out whether a connectivity issue involves your computer, routing or DNS.
bash
echo '=== INTERFACES ==='
ip -brief address

echo '=== ROUTES ==='
ip route

echo '=== LOCAL TEST ==='
ping -c 3 127.0.0.1

echo '=== DNS LOOKUP ==='
getent hosts example.com

echo '=== HTTPS HEADERS ==='
curl -I --max-time 10 [hidden link]

echo '=== LISTENING SERVICES ==='
ss -tuln
How to interpret results:
β€’ Loopback works: your local IP stack is responding.
β€’ No default route: check your network connection and router settings.
β€’ DNS lookup fails: investigate DNS configuration or connectivity.
β€’ HTTPS fails: check connectivity, certificates, proxy settings or the remote service.
SAFETY: Only test services and networks you own or are authorized to assess.



⚑ KIT 05 | Your First Bash Automation
Goal: Create a reusable script that records a small system report in your home directory.
bash
mkdir -p "$HOME/linux-reports"

cat > "$HOME/linux-reports/report.sh" <<'BASH'
#!/usr/bin/env bash
set -e
OUT="$HOME/linux-reports/report-$(date +%Y%m%d_%H%M%S).txt"
{
  echo 'LINUX SYSTEM REPORT'
  date
  uname -a
  uptime
  free -h
  df -h
} > "$OUT"
echo "Report saved: $OUT"
BASH

chmod +x "$HOME/linux-reports/report.sh"
"$HOME/linux-reports/report.sh"
What you learn:
β€’ #!/usr/bin/env bash selects Bash to run the script.
β€’ { ... } > file saves multiple commands' output to one file.
β€’ chmod +x makes the script executable.
β€’ $HOME points to your home directory.



πŸ† BONUS PACK COMPLETE
5 KITS β€’ REAL COMMANDS β€’ REUSABLE WORKFLOWS
The original mini-course teaches the commands. This companion puts them to work.
Created by Error
Like1
🎨 LINUX TERMINAL VISUAL UPGRADE PACK
MAKE YOUR TERMINAL LOOK AMAZING
A practical visual customization guide: system logos, beautiful prompts, colorful file listings, syntax highlighting, live dashboards and terminal effects.
Customize the look. Keep the power.


🐧 1. Fastfetch | Your System, Beautifully Displayed
What it does: Shows a colorful Linux logo alongside OS, kernel, CPU, GPU, RAM and uptime information.
bash
# Ubuntu/Debian (where available):
sudo apt install fastfetch

# Arch Linux:
sudo pacman -S fastfetch

# Fedora:
sudo dnf install fastfetch

# Launch:
fastfetch
TIP: Run fastfetch whenever you want a quick system showcase. Package availability depends on your distribution.


πŸš€ 2. Starship | A Modern, Colorful Prompt
What it does: Adds a customizable prompt showing the current directory, Git branch, programming environment and more.
bash
# Install with a supported package manager,
# or follow the official installer instructions:
# [hidden link]

# Add this to the END of ~/.bashrc:
eval "$(starship init bash)"
Bonus: Starship supports Bash, Zsh, Fish and other shells. For extra icons, use a terminal font with Nerd Font glyphs.


πŸ“‚ 3. eza + bat | Better File Browsing
What they do: eza displays colorful directory listings; bat displays files with syntax highlighting and line numbers.
bash
# Arch Linux:
sudo pacman -S eza bat

# Fedora:
sudo dnf install eza bat

# Ubuntu/Debian: install available packages
# using your distro's repositories.

# Examples:
eza -lah
bat README.md
NOTE: On some Debian/Ubuntu installations, the bat executable is named batcat. Icons may require a compatible font.


πŸ“Š 4. btop | A Live System Dashboard
What it does: Displays CPU, memory, disks, network activity and processes using interactive graphs.
bash
# Debian/Ubuntu:
sudo apt install btop

# Arch:
sudo pacman -S btop

# Fedora:
sudo dnf install btop

# Open the dashboard:
btop
Try it: Open btop, explore its settings and switch between available themes.


✨ 5. Zsh Plugins | Smarter Command Line
What they do: Autosuggestions propose commands from your history, while syntax highlighting makes commands easier to read.
bash
# Ubuntu/Debian (package names may vary):
sudo apt install zsh zsh-autosuggestions zsh-syntax-highlighting

# Start Zsh for this session:
zsh

# Enable plugins by adding these lines to ~/.zshrc
# if the package files exist at these paths:
source /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
TIP: Check the installed plugin paths before adding them. Different distributions store Zsh plugins in different locations. Oh My Zsh is another optional framework for themes and plugins.


🌌 BONUS | Terminal Effects & Fonts
cmatrix β€” Animated Matrix-style character rain.
Nerd Fonts β€” Extra symbols and icons for prompts and file listings.
Terminal transparency β€” Usually configured in the terminal emulator, not through Bash.
Color themes β€” Try built-in themes in your terminal app or btop.
bash
# Debian/Ubuntu:
sudo apt install cmatrix

# Arch:
sudo pacman -S cmatrix

# Run the effect:
cmatrix

# Press q to exit.


πŸ† YOUR TERMINAL, YOUR STYLE
Fastfetch + Starship + eza + bat + btop = a clean, colorful and useful terminal setup.
Which terminal theme do you use?

Created by Error
Like1

You must log in or register to reply here.

Back to Tutorials