Kali Linux Foundations Scripts — Files, Networking & System Info
Start here. These Bash and Python scripts cover the Linux fundamentals every security learner needs first — creating and moving files, reading logs, checking disk space, discovering your local IP, listing open ports and printing system information. Each script is short enough to read in a minute and safe to run on your own machine.
Kali · Foundations — script list
| Script | Category | What it does |
|---|---|---|
create_system_directory.py | Foundations | Scaffolds an organised system directory tree for the toolkit. |
write_sample_logs.py | Foundations | Generates sample log files for testing monitoring and parsing scripts. |
run_basic_ping.py | Networking | Simple connectivity check against common targets such as Google DNS. |
list_directory_contents.py | File Ops | Walks and prints a directory structure for inspection. |
file_permissions.sh | File Ops | Demonstrates `chmod` and execution-right management. |
connectivity_check.sh | Networking | Basic connectivity and address discovery with `ping`. |
ip_recon.sh | Networking | Extracts the local IP address using `ip addr` and `grep`. |
file_ops.sh | File Ops | Automates `touch`, `cp`, `mv`, and `rm` operations. |
grep_search.sh | Text Processing | Pattern matching and search within log files using `grep`. |
system_updater.sh | Maintenance | Automated system update and package management. |
user_recon.sh | Recon | Reports on the current user's sessions and privileges. |
log_reader.sh | Log Analysis | Reads file segments with `cat`, `head`, and `tail`. |
hidden_files.sh | File Ops | Explores hidden-file creation and discovery (`ls -la`). |
process_hunter.sh | Process Management | Tracks and filters background processes with `ps aux`. |
project_directory_setup.sh | File Ops | Quickly scaffolds a standard project directory structure. |
disk_monitor.sh | Monitoring | Reports disk-space usage in a human-readable format. |
file_backup.sh | Backup | Creates a `.bak` backup copy of a chosen file. |
ip_fetcher.sh | Networking | Detects and prints the local IP address. |
local_net_analyzer.sh | Networking | Consolidated report of IP info, routing tables, and listening services. |
mass_file_creator.sh | File Ops | Demonstrates bulk file creation in a single pass. |
network_ping.sh | Networking | Checks connectivity to a host with a 3-packet ping. |
open_ports.sh | Networking | Lists all active listening network ports. |
sys_info.sh | System Info | Prints basic OS and kernel information. |
user_greet.sh | Utilities | Displays the current user and time as a friendly greeting. |
Code samples
sys_info.sh — print OS, kernel and hardware info
#!/bin/bash # sys_info.sh # This script fetches and prints basic system and kernel information. echo "--- System Information ---" # 'uname -s' prints the operating system name. # 'uname -r' prints the kernel release version. # 'uname -m' prints the machine hardware name. echo "Operating System: $(uname -s)" echo "Kernel Version: $(uname -r)" echo "Hardware Architecture: $(uname -m)" # 'hostname' displays the name of the machine. echo "Hostname: $(hostname)" echo "--------------------------"
open_ports.sh — list listening ports with ss/netstat
#!/bin/bash
# open_ports.sh
# This script lists currently listening network ports.
echo "--- Active Listening Ports ---"
# Check if 'ss' (Socket Statistics) is available.
if command -v ss >/dev/null 2>&1; then
# '-t' TCP, '-u' UDP, '-l' listening, '-n' numeric.
echo "Using 'ss' command:"
ss -tuln
else
# Fallback to 'netstat' if 'ss' is missing.
echo "Using 'netstat' command:"
netstat -tuln
fi
echo "------------------------------"
python_scripts/list_directory_contents.py
#!/usr/bin/env python3
import subprocess
import sys
def main():
if sys.platform == "win32":
command = ["cmd", "/c", "dir", "/a"]
else:
command = ["ls", "-la"]
print(f"Executing command: {' '.join(command)}")
try:
result = subprocess.run(command, capture_output=True, text=True, check=True)
print("Directory Contents:")
print(result.stdout)
except subprocess.CalledProcessError as e:
print(f"Error executing command: {e}")
if __name__ == "__main__":
main()