Kali Linux commands are largely the same as those in other Linux distributions, because Kali is Debian-based. The difference is that Kali also runs security testing tools from the command line. In this guide you’ll find basic file and system commands, package management, network commands and the basic usage of common security tools, with examples.
If you haven’t read what Kali Linux is yet, you can start with our article what is Kali Linux.
Important Note: Authorised Systems Only
Use the network and security tools below only on your own systems, in your own lab environment or on targets for which you have written permission. Unauthorised scanning and access attempts are crimes.
Basic File and Directory Commands
| Command | Description |
|---|---|
pwd | Shows the current directory |
ls -la | Lists directory contents in detail, including hidden files |
cd /etc | Changes directory |
mkdir lab | Creates a new directory |
cp source target | Copies a file (-r for directories) |
mv old new | Moves or renames |
rm file | Deletes (-r for directories; use with care) |
cat file | Shows file contents |
less file | Shows long files page by page |
nano file | Opens the file in a terminal editor |
find / -name "*.conf" | Searches for files |
grep -i "word" file | Searches for text in a file |
User, Permission and System Commands
| Command | Description |
|---|---|
whoami | Shows the logged-in user |
sudo command | Runs the command with administrator privileges |
sudo su | Switches to the root user |
passwd | Changes the password |
chmod 755 file | Changes file permissions |
chown user:group file | Changes file ownership |
uname -a | Kernel and system information |
df -h / free -h | Disk and memory usage |
top or htop | Running processes and resource usage |
ps aux / kill PID | Lists / terminates processes |
In current Kali releases the default user isn’t root; tasks that need administrator rights are done with sudo.
Package Management (APT)
sudo apt update # updates the package list
sudo apt full-upgrade -y # upgrades the system
sudo apt install package-name # installs a package
sudo apt remove package-name # removes a package
apt search keyword # searches for packages
sudo apt autoremove # removes unneeded packagesSince Kali is a rolling distribution, regular apt update and full-upgrade runs are recommended. Kali’s tool bundles can be installed together with metapackages such as kali-linux-default or kali-tools-web.
Network Commands
| Command | Description |
|---|---|
ip a | Network interfaces and IP addresses |
ip route | Routing table and default gateway |
ping -c 4 example.com | Connectivity test |
traceroute example.com | The path packets take |
dig example.com | DNS lookup |
ss -tulpn | Listening ports and services |
curl -I https://example.com | Shows HTTP headers |
sudo systemctl start ssh | Starts the SSH service |
For details on DNS lookup commands, see our guide how to do a DNS lookup.
Basic Commands for Common Security Tools
Nmap: network and port scanning
nmap 192.168.56.0/24 # finds live hosts on the lab network
nmap -sV 192.168.56.101 # open ports and service versions
nmap -p 22,80,443 192.168.56.101 # scans specific portsWireshark and tcpdump: traffic analysis
sudo tcpdump -i eth0 port 80 # watches traffic on port 80
wireshark & # starts the graphical interfaceMetasploit Framework
sudo msfdb init # prepares the database
msfconsole # opens the console
search ms17-010 # searches for modules (inside the console)Web tests
nikto -h http://192.168.56.101 # scans a web server for known issues
whatweb http://192.168.56.101 # identifies the technologies usedThe 192.168.56.x addresses in the examples represent VirtualBox’s host-only lab network, which only communicates with the host computer. Try these tools on test machines you set up yourself.
Useful Tips
- Use
man commandorcommand --helpto see how any command works. - The Tab key completes command and file names; Ctrl + R searches your command history.
historylists the commands you’ve run.- Use
command > result.txtto save output to a file.
Frequently Asked Questions
Do Kali Linux commands work on Ubuntu?
Almost all basic Linux commands are the same. Security tools need to be installed on Ubuntu separately.
I get a “command not found” error. What should I do?
The tool may not be installed. Install it with sudo apt install tool-name, or find the right package name with apt search.
What’s the best way to learn the commands?
Setting up a lab in a virtual machine and trying the commands on your own test systems is the most lasting way to learn.
Categories
-
CentOS 7 guides
-
cPanel 20 guides
-
CyberPanel 18 guides
-
Operating Systems 81 guides
-
Juniper Networks 18 guides
-
Control Panels 50 guides
-
Linux 17 guides
-
MySQL 29 guides
-
Network 93 guides
-
Plesk Panel 12 guides
-
Virtual Servers 273 guides
-
SEO 3 guides
-
Cyber Security 6 guides
-
Technology 162 guides
-
VMware 36 guides
-
WordPress 20 guides
-
Artificial Intelligence 22 guides