By leveraging a post-installation Bash script, you can automate your entire Kali Linux (2026.1+) setup procedure. Today, I'll walk you through a custom script I built to configure a clean workspace directory, define virtual environment spaces, and install the kali-linux-everything tool suite—all in one go.
Why Automate Your Setup?
Building a script like this serves three main purposes:
- An All-in-One Solution: It guarantees you have every tool, hypervisor, and package you need right out of the gate.
- Repeatability: By generating a synchronous workspace and home folder directory structure, your environment looks exactly the same, whether you are on a laptop, a desktop, or a fresh VM.
- Version Independence: The script is designed to be independent of your current Kali Linux version, meaning it doubles as a highly effective version upgrading tool.
1. Installing Base Dependencies
A fresh Kali install is great, but we need to lay down some foundational infrastructure — specifically for virtualization, development, and package management.
Our script first updates the system and then pulls down essentials like python3-full, code-oss for offensive development, and hypervisors like VirtualBox, QEMU, and Docker for exploiting labs. It also pulls the incredibly fast uv Python package manager
install_base_dependencies() {
log "[...] Updating package lists..."
sudo apt update
log "[...] Upgrading packages..."
sudo apt-get full-upgrade -y
log "[...] Installing base and virtualization dependencies..."
sudo apt install -y \
python3-full \
python3-pip \
git \
curl \
wget \
npm \
code-oss \
jq \
ca-certificates \
docker.io \
docker-compose \
virtualbox \
virtualbox-ext-pack \
virtualbox-dkms \
virtualbox-qt \
qemu-system-x86 \
qemu-utils \
qemu-kvm \
libvirt-daemon-system \
libvirt-clients \
bridge-utils \
ovmf
log "[...] Installing uv package manager..."
if ! command -v uv >/dev/null 2>&1; then
python3 -m pip install --user uv --break-system-packages
fi
}
2. Configuring System Services
Installing Docker and KVM isn't enough; you need the correct permissions to run them without throwing sudo in front of every command. This function enables the necessary daemons and adds your user to the appropriate groups.
configure_system_services() {
log "[...] Configuring virtualization services and groups..."
sudo systemctl enable --now docker || true
sudo systemctl enable --now libvirtd || true
sudo usermod -aG docker "$USER" || true
sudo usermod -aG kvm "$USER" || true
sudo usermod -aG libvirt "$USER" || true
sudo usermod -aG vboxusers "$USER" || true
}3. Creating the Organized Workspace
A disorganized file system is an ethical hacker's worst nightmare. You don't want to be hunting for your HackTheBox VPN file or your reverse shell payloads during an engagement.
This function builds a highly organized, standardized directory tree:
- Assistant: For AI tools and local models.
- CTF: Dedicated folders for HackTheBox and TryHackMe, including subdirectories for Rooms, Challenges, and OpenVPN configs.
- Development: A clean space for your GitHub clones and custom scripts.
- Virtual: Categorized storage for ISOs, snapshots, and images for VirtualBox, QEMU, and Docker.
create_directories() {
log "[...] Creating workspace directory structure..."
mkdir -p ~/Assistant/Tools
mkdir -p ~/Assistant/Models
log "[...] Created Assistant directories."
mkdir -p ~/CTF/HackTheBox/{Rooms,Challenges,ProLabs,OpenVPN}
mkdir -p ~/CTF/TryHackMe/{Rooms,Challenges,OpenVPN}
log "[...] Created CTF directories."
mkdir -p ~/Development/Projects
mkdir -p ~/Github/Tools
mkdir -p ~/Scripts ~/Tools
log "[...] Created development and tools directories."
mkdir -p ~/Virtual/virtualbox/{isos,images,snapshots}
mkdir -p ~/Virtual/qemu/{isos,images,snapshots,scripts}
mkdir -p ~/Virtual/docker/{images,containers,compose}
mkdir -p ~/Virtual/labs/windows
mkdir -p ~/Virtual/labs/linux
log "[...] Created virtualization directories."
}
4. Local AI Integration with Ollama
In modern cybersecurity, having an AI assistant can significantly speed up tasks like reverse-engineering scripts or crafting payloads. However, submitting sensitive client data to cloud-based LLMs is a massive OPSEC failure.
The script installs Ollama, allowing you to host and run powerful open-source AI models entirely locally and offline.
install_ollama() {
log "[...] Installing Ollama for local AI model hosting..."
if ! command -v ollama >/dev/null 2>&1; then
curl -fsSL https://ollama.com/install.sh | sh
sudo systemctl enable --now ollama
fi
}More about Kali & Ollama LLM:
5. The Arsenal: kali-linux-everything
Finally, rather than fetching tools individually, we pull the trigger on the kali-linux-everything metapackage. This ensures every tool maintained by Offensive Security is locally available on your machine.
install_kali_toolsuite() {
log "[...] Installing Kali Linux tool suite..."
sudo apt-get install kali-linux-everything -y
}6. Put everything together
The main function orchestrates the entire process cleanly, tying all of our custom modules together in logical order.
main() {
install_base_dependencies
configure_system_services
create_directories
configure_shell
install_ollama
install_kali_toolsuite
log "[...] Setup complete."
}
main "$@"How to Use the Script
Want to skip the manual configuration and get straight to the action? You can clone my official repository and run the setup script yourself.
git clone https://github.com/fsocietygit/kali-linux-scripts.git
cd kali-linux-scripts
chmod +x setup.sh
./setup.sh
Final Thoughts: The Professional Edge
Automation isn't just about saving time; it's about professionalism. When you can spin up a new, perfectly configured environment in minutes, you eliminate "environment friction." You stop fighting your OS and start fighting the target.
Sit back, grab a coffee, and let the script do the heavy lifting. When it finishes, you'll have a fully weaponized, neatly organized, and container-ready OS.
Follow me here on Medium at @fsocietyhub for more write-ups on automation, Linux internals, and offensive security.
If you found this helpful, give it a clap and share it with your fellow researchers. Stay secure.