Courses3 levels
Level 1 · Foundations11 courses
Level 2 · Core5 courses
Level 3 · Advanced5 courses
Labs8 topics
Library Practice exams AI Range Pricing Start free

Practice library / Linux

Lab · Easy · 30 minutes

Kali Linux Environment Setup

Set up your Kali VM, configure tools, and prepare your hacking lab environment.

  • kali-setup
  • apt
  • ssh
  • tmux
  • aliases
On this page 6 sections
  1. 1Update Everything
  2. 2Install Core Tools
  3. 3Configure SSH
  4. 4Shell Aliases
  5. 5tmux Setup
  6. 6Engagement Directory Structure

Before you start

Kali Linux is a widely used operating system for offensive security work, but a fresh install is not an operator's workstation. An out-of-date toolchain and a flat home directory cost time in every engagement and lose findings when files get mixed up. Here you update the system, install SecLists and essential tools, harden SSH with a key, and lay down aliases and a case-folder tree you can reuse on the next job.

Lab Objectives

  • Keep Kali fully updated with the latest packages and tools
  • Install wordlists, SecLists and essential tooling
  • Configure SSH for remote access and key-based authentication
  • Set up productivity aliases and tmux configuration
  • Build a consistent directory structure for engagements

Before you start: you need Kali Linux running, either in a virtual machine such as VirtualBox or installed on a computer. If you do not have it yet, the Kali Linux Fundamentals workbook shows how to set it up. Then open a terminal in Kali and type or paste each command below. Lines that start with # are notes. You do not need to type them.

Step 1: Update Everything

# Full system update (run first on any fresh Kali)
sudo apt update && sudo apt full-upgrade -y
sudo apt autoremove -y && sudo apt autoclean

# Update all installed pip packages
pip3 list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U 2>/dev/null

Step 2: Install Core Tools

# Wordlists
sudo apt install seclists wordlists -y
sudo gunzip /usr/share/wordlists/rockyou.txt.gz 2>/dev/null || true

# Recon & enumeration
sudo apt install gobuster ffuf feroxbuster nikto whatweb -y

# Exploitation
sudo apt install metasploit-framework sqlmap -y

# Privilege escalation helpers
sudo apt install linenum linpeas -y 2>/dev/null || true
sudo wget https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh -O /opt/linpeas.sh
sudo chmod +x /opt/linpeas.sh

# Network tools
sudo apt install netcat-traditional ncat socat curl wget -y

# Password cracking
sudo apt install hashcat john hash-identifier hashid -y

Step 3: Configure SSH

# Enable and start SSH
sudo systemctl enable ssh
sudo systemctl start ssh

# Generate SSH key pair
ssh-keygen -t ed25519 -C "my-security-lab"

# Change default SSH port (optional — reduces scan noise)
sudo sed -i 's/#Port 22/Port 2222/' /etc/ssh/sshd_config
sudo systemctl restart ssh

Step 4: Shell Aliases

# Kali's default shell is zsh, so these go in ~/.zshrc
# (using bash? change ~/.zshrc to ~/.bashrc on both lines)
cat >> ~/.zshrc << 'EOF'

# KaliRange aliases
alias ll='ls -alh --color=auto'
alias nse='ls /usr/share/nmap/scripts | grep'
alias www='python3 -m http.server 8080'
alias msf='sudo msfconsole -q'
alias myip='ip addr show tun0 2>/dev/null | grep "inet " | awk "{print \$2}" | cut -d/ -f1'
alias rocks='/usr/share/wordlists/rockyou.txt'
alias update='sudo apt update && sudo apt full-upgrade -y'

# Quick nmap functions
nmapq() { sudo nmap -sC -sV -oA nmap_$1 $1; }
nmapf() { sudo nmap -sS -p- --min-rate 5000 -oA nmap_full_$1 $1; }
EOF

source ~/.zshrc

Step 5: tmux Setup

# Install tmux
sudo apt install tmux -y

# Basic ~/.tmux.conf
cat > ~/.tmux.conf << 'EOF'
set -g default-terminal "screen-256color"
set -g history-limit 50000
set -g mouse on
set -g base-index 1
bind | split-window -h
bind - split-window -v
bind r source-file ~/.tmux.conf \; display "Reloaded!"
set -g status-style 'bg=#161b22 fg=#dc2626'
EOF

# Start a named session for your lab
tmux new -s lab

Step 6: Engagement Directory Structure

# Add the newlab function to ~/.zshrc (Kali's default shell)
# (using bash? change ~/.zshrc to ~/.bashrc on both lines)
cat >> ~/.zshrc << 'EOF'

newlab() {
    TARGET=$1
    mkdir -p ~/labs/$TARGET/{nmap,web,exploits,loot,notes}
    echo "[*] Lab directory created: ~/labs/$TARGET"
    echo "[*] Target: $TARGET" > ~/labs/$TARGET/notes/README.md
    cd ~/labs/$TARGET
}
EOF

source ~/.zshrc

# Usage
newlab 10.10.10.1

Resulting structure:

~/labs/10.10.10.1/
├── nmap/       ← scan results
├── web/        ← gobuster, nikto output
├── exploits/   ← exploit code, modified payloads
├── loot/       ← files, hashes, credentials found
└── notes/      ← your notes and README

Environment ready. Your Kali system is configured for efficient penetration testing. Next, run your first Nmap scan.

Sign in to track progress and send feedback.

Related

This lab is extra practice for the course Linux. Do the lessons first.Open the course