Linux Basics

Author
Affiliations

Md Rasheduzzaman

Last updated

September 20, 2025

Content summary
Linux, WSL2, Navigation, simple commands

Linux and WSL2

If you have Linux already, stay calm. Scrol down to learn things instead of installing WSL2.

Try to use Linux to do better in life. The black screen of Linux is way more powerful than you (probably) know till now. Follow this step-by-step guide to install Ubuntu (a Linux distribution).

Follow this pages to install Windows Subsystem for Linux if you are using Windows. Then you can use the WSL just like a native Linux using your system. You can’t do anything except using Linux to analyse Genomic (sequencing) data. So, better start now.

Follow link1 & link2 to get step-by-step guideline to do it.

A pro tip will be update your kernel first and then try. But here goes something.

Basic Linux Commands

Now that you have Linux/WSL2 set up, let’s learn the essential commands. These are the building blocks of working with Linux.

File and Directory Operations

mkdir - Make Directory

Create new directories.

# Create a single directory
mkdir my_folder

# Create multiple directories
mkdir folder1 folder2 folder3

# Create nested directories
mkdir -p project/data/raw

# Create directory with specific permissions
mkdir -m 755 public_folder

touch - Create Empty Files

Create empty files or update file timestamps.

# Create an empty file
touch my_file.txt

# Create multiple files
touch file1.txt file2.txt file3.txt

# Update file timestamp (useful for makefiles)
touch existing_file.txt

cp - Copy Files and Directories

Copy files and directories.

# Copy a file
cp source.txt destination.txt
# Copy file to a directory
cp file.txt /path/to/directory/

# Copy directory recursively
cp -r source_directory/ destination_directory/

# Copy with preservation of attributes
cp -p file.txt backup/

# Copy multiple files
cp file1.txt file2.txt destination_folder/

mv - Move/Rename Files and Directories

Move or rename files and directories.

# Rename a file
mv old_name.txt new_name.txt
# Move file to directory
mv file.txt /path/to/directory/

# Move directory
mv source_directory/ destination_directory/

# Move and rename in one step
mv file.txt /new/location/renamed_file.txt

rm - Remove Files and Directories

Delete files and directories.

# Remove a file
rm file.txt

# Remove multiple files
rm file1.txt file2.txt file3.txt

# Remove directory and all contents (BE CAREFUL!)
rm -r directory_name/

# Remove directory with confirmation
rm -ri directory_name/

# Remove empty directory only
rmdir empty_directory/

# Remove files with confirmation
rm -i *.txt

File Permissions

Understanding file permissions is crucial for Linux security.

Viewing Permissions

# List files with permissions
ls -l

# Example output:
# -rw-r--r-- 1 username group 1234 Dec 15 10:30 file.txt
# drwxr-xr-x 2 username group 4096 Dec 15 10:30 folder/

The permission string has 10 characters: - Position 1: File type (- for file, d for directory) - Positions 2-4: Owner permissions (read, write, execute) - Positions 5-7: Group permissions (read, write, execute) - Positions 8-10: Other permissions (read, write, execute)

chmod - Change File Permissions

# Give owner read, write, execute; group and others read, execute
chmod 755 script.sh

# Give owner read, write; group and others read only
chmod 644 file.txt

# Add execute permission for owner
chmod +x script.sh

# Remove write permission for group and others
chmod go-w file.txt

# Make file readable by everyone
chmod a+r file.txt

chown - Change File Ownership

# Change owner
chown newowner file.txt

# Change owner and group
chown newowner:newgroup file.txt

# Change ownership recursively
chown -R newowner:newgroup directory/

Text Editing

nano - Simple Text Editor

Great for beginners.

# Open file in nano
nano filename.txt

# Create new file
nano new_file.txt

Nano shortcuts: - Ctrl + X: Exit - Ctrl + O: Save - Ctrl + W: Search - Ctrl + K: Cut line - Ctrl + U: Paste

vim - Advanced Text Editor

More powerful but steeper learning curve.

# Open file in vim
vim filename.txt

# Create new file
vim new_file.txt

So, creating and opening command is basically the same. Just write the file name. After opening the file, you have toenter into editing/inserting mode. Press i on your keyboard to be able to insert/write (or copy-paste) contents. After finishing editing, press Esc key to come out of the editing mode. Then write :wq to save.

Basic vim commands: - i: Enter insert mode - Esc: Exit insert mode - :w: Save - :q: Quit - :wq: Save and quit - :q!: Quit without saving

Viewing File Contents

cat - Display File Contents

# Display entire file
cat file.txt

# Display multiple files
cat file1.txt file2.txt

# Display with line numbers
cat -n file.txt

less - View File Page by Page

# View file with pagination
less file.txt

# Search in less: type `/search_term` and press Enter
# Navigate: Space (next page), b (previous page), q (quit)

head and tail - View Beginning/End of Files

# Show first 10 lines
head file.txt

# Show first 20 lines
head -n 20 file.txt

# Show last 10 lines
tail file.txt

# Show last 20 lines
tail -n 20 file.txt

# Follow file changes in real-time
tail -f log_file.txt

Basic Text Processing

grep - Search Text

# Search for text in file
grep "search_term" file.txt

# Search case-insensitive
grep -i "search_term" file.txt

# Search in multiple files
grep "search_term" *.txt

# Search recursively in directories
grep -r "search_term" directory/

# Show line numbers
grep -n "search_term" file.txt

wc - Word Count

# Count lines, words, characters
wc file.txt

# Count only lines
wc -l file.txt

# Count only words
wc -w file.txt

# Count only characters
wc -c file.txt

Environment and System Information

whoami - Current User

# Show current username
whoami

uname - System Information

# Show system information
uname -a

# Show operating system
uname -s

# Show machine architecture
uname -m

df - Disk Space Usage

# Show disk space usage
df -h

free - Memory Usage

# Show memory usage
free -h

Process Management

ps - List Processes

# List running processes
ps

# List all processes
ps aux

# List processes for current user
ps u

top - Monitor Processes

# Show running processes interactively
top

# Press 'q' to quit

Getting Help

man - Manual Pages

# Get help for a command
man ls

# Get help for a command (alternative)
ls --help

which - Find Command Location

# Find where a command is located
which python3

# Find all locations
which -a python3

Example Workflow

Let’s practice with a complete example:

# Create a project directory
mkdir -p my_project/data
cd my_project

# Create some files
touch data/sample1.txt data/sample2.txt
echo "Hello World" > data/sample1.txt
echo "Linux is awesome" > data/sample2.txt

# List files
ls -la data/

# View file contents
cat data/sample1.txt

# Search for text
grep "Hello" data/*.txt

# Copy files
cp data/sample1.txt backup_sample1.txt

# Check permissions
ls -l data/

# Change permissions
chmod 644 data/sample1.txt

# View file with line numbers
cat -n data/sample1.txt

Example shell command

# Your Linux/Bash code here 
echo "Hello from Bash!" 
ls -l

WSL2 Installation Guide for Windows Users

This guide will help you install Windows Subsystem for Linux 2 (WSL2) and set up a Python development environment for running the IELTS AI Coach application.

Prerequisites

  • Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11
  • Administrator access to your computer
  • Stable internet connection

Step 1: Check Your Windows Version

First, verify you have a compatible Windows version:

# Open Command Prompt and run:
winver

You should see Windows 10 Build 19041+ or Windows 11.

Step 2: Enable WSL Feature

Open Command Prompt as Administrator (Right-click → “Run as administrator”):

# Enable WSL feature
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

# Enable Virtual Machine Platform
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Important: Restart your computer after running these commands.

Step 3: Install WSL2 (Modern Method)

After restarting, open Command Prompt as Administrator again:

# Install WSL2 with Ubuntu (this is the easiest method)
wsl --install

Do “OK” or “Yes” to agree if pop-ups appear. If this command doesn’t work, use the manual method below.

Step 4: Manual Installation (If Step 3 Failed)

Download and Install WSL2 Kernel Update

  1. Download the WSL2 Linux kernel update package from Microsoft:
  2. Run the downloaded .msi file and follow the installation wizard.

Set WSL2 as Default Version

# Set WSL2 as the default version
wsl --set-default-version 2

Install Ubuntu Distribution

# List available distributions
wsl --list --online
#it will show all the availabe Linux distributions. Choose one of Ubuntus.

# Install Ubuntu
wsl --install -d Ubuntu

Step 5: Alternative - Install via Microsoft Store

If command line installation fails:

  1. Open Microsoft Store
  2. Search for “Ubuntu 22.04.3 LTS” or just “Ubuntu
  3. Click “Get” or “Install
  4. Wait for download and installation
  5. Click “Launch” when ready

Step 6: First-Time Ubuntu Setup

When you launch Ubuntu for the first time:

  1. Wait for installation to complete (this may take several minutes)
  2. Create a username when prompted (can be different from your Windows username)
  3. Create a password (you won’t see characters as you type - this is normal)
  4. Confirm your password
# Example setup (replace 'yourusername' with your preferred username)
Enter new UNIX username: yourusername
New password: [type your password]
Retype new password: [type your password again]

Step 7: Verify Installation

# Check WSL version and status
wsl --list --verbose

You should see output like:

  NAME      STATE           VERSION
* Ubuntu    Running         2

Step 8: Update Ubuntu System

In your Ubuntu terminal, run these commands one by one:

# Update package list
sudo apt update

# Upgrade installed packages (this may take a while)
sudo apt upgrade

Note: When prompted, type Y and press Enter to confirm upgrades.

Step 9: Install Python Development Environment

This is required for latter use, not exactly now. You might choose not to do it right now. We will see things together.

Option B: Using Miniconda (Alternative)

# Download Miniconda installer
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

# Install Miniconda
bash Miniconda3-latest-Linux-x86_64.sh

# Follow the installation prompts:
# - Press ENTER to review the license
# - Type 'yes' to accept the license
# - Press ENTER to confirm the installation location
# - Type 'yes' to initialize conda

# Reload your shell configuration
source ~/.bashrc

# Verify conda installation
conda --version

Step 10: Access Your Windows Files

Your Windows files are accessible from Ubuntu at these locations:

# Your Windows C: drive
cd /mnt/c/

cd /mnt/c/Users/YourWindowsUsername/

# Your Downloads folder
cd /mnt/c/Users/YourWindowsUsername/Downloads/

mnt is to denote mounting. Your linux/ubuntu functionalities are actually mounted on Windows. Makes sense?

Your Windows user folder

Step 11: Copy Project Files

To copy your project from Windows to Ubuntu:

# Navigate to your home directory in Ubuntu
cd ~

# Copy project from Windows Downloads (adjust path as needed)
cp -r /mnt/c/Users/YourWindowsUsername/Downloads/folderName ./

# Navigate to the project
cd folderName

# List files to verify
ls -la

Common Troubleshooting

Issue: “WSL has no installed distributions”

Solution: You need to install a Linux distribution first.

# List available distributions
wsl --list --online

# Install Ubuntu
wsl --install Ubuntu

Issue: Command not found errors

Solution: Make sure you’re running commands in the correct environment: - WSL commands (wsl --install) should be run in Windows Command Prompt as Administrator - Linux commands (sudo apt update) should be run in Ubuntu terminal

Issue: Network/download problems

Solutions:

  1. Try different download mirrors:
# For Miniconda, try this mirror:
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-latest-Linux-x86_64.sh
  1. Download via Windows browser and copy:
    • Download files using your Windows browser
    • Copy to Ubuntu using /mnt/c/ path

Issue: Permission denied

Solution: Use sudo for system commands:

# Wrong:
apt update

# Correct:
sudo apt update

Issue: Ubuntu terminal closes immediately

Solutions: 1. Make sure WSL2 is properly installed 2. Restart your computer 3. Try reinstalling Ubuntu from Microsoft Store

Useful WSL Commands

# List all installed distributions
wsl --list --verbose

# Stop a distribution
wsl --terminate Ubuntu

# Start a specific distribution
wsl -d Ubuntu

# Uninstall a distribution
wsl --unregister Ubuntu

# Check WSL version
wsl --version

Opening Multiple Terminals

Method 2: Direct Launch

  • Search “Ubuntu” in Start Menu
  • Click to open new instances

Next Steps

Once WSL2 and Ubuntu are properly installed:

  1. Set up your development environment (Python virtual environment or Conda)
  2. Copy your project files from Windows to Ubuntu
  3. Install project dependencies
  4. Run your IELTS AI Coach application

Additional Resources

Need Help? If you encounter issues not covered in this guide, please: 1. Take a screenshot of the error message 2. Note which step you were on 3. Contact me

Citation

BibTeX citation:
@online{rasheduzzaman2025,
  author = {Md Rasheduzzaman},
  title = {Linux {Basics}},
  date = {2025-09-20},
  langid = {en},
  abstract = {Linux, WSL2, Navigation, simple commands}
}
For attribution, please cite this work as:
Md Rasheduzzaman. 2025. “Linux Basics.” September 20, 2025.

💬 Have thoughts or questions? Join the discussion below using your GitHub account!

You can edit or delete your own comments. Reactions like 👍 ❤️ 🚀 are also supported.