Kali Linux Commands: Basic Commands and Security Tools Guide

Sunucun 3 min read

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.

Illustration: Linux

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

CommandDescription
pwdShows the current directory
ls -laLists directory contents in detail, including hidden files
cd /etcChanges directory
mkdir labCreates a new directory
cp source targetCopies a file (-r for directories)
mv old newMoves or renames
rm fileDeletes (-r for directories; use with care)
cat fileShows file contents
less fileShows long files page by page
nano fileOpens the file in a terminal editor
find / -name "*.conf"Searches for files
grep -i "word" fileSearches for text in a file

User, Permission and System Commands

CommandDescription
whoamiShows the logged-in user
sudo commandRuns the command with administrator privileges
sudo suSwitches to the root user
passwdChanges the password
chmod 755 fileChanges file permissions
chown user:group fileChanges file ownership
uname -aKernel and system information
df -h / free -hDisk and memory usage
top or htopRunning processes and resource usage
ps aux / kill PIDLists / 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 packages

Since 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

CommandDescription
ip aNetwork interfaces and IP addresses
ip routeRouting table and default gateway
ping -c 4 example.comConnectivity test
traceroute example.comThe path packets take
dig example.comDNS lookup
ss -tulpnListening ports and services
curl -I https://example.comShows HTTP headers
sudo systemctl start sshStarts 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 ports

Wireshark and tcpdump: traffic analysis

sudo tcpdump -i eth0 port 80    # watches traffic on port 80
wireshark &                     # starts the graphical interface

Metasploit 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 used

The 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 command or command --help to see how any command works.
  • The Tab key completes command and file names; Ctrl + R searches your command history.
  • history lists the commands you’ve run.
  • Use command > result.txt to 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

Latest guides