GO KALI FREE

Linux Commands Reference

Complete Linux commands reference with syntax, examples, and FAQs. 164 commands across 13 categories.

Navigation Commands

pwd

Prints the current working directory (full path from root).

Syntax: pwd [options]

ls

Lists files and directories in the current directory.

Syntax: ls [options] [path]

cd

Changes the current working directory to the specified path.

Syntax: cd [directory]

cd ..

Moves up one directory level (to the parent directory).

Syntax: cd ..

cd ~

Changes to the current user's home directory.

Syntax: cd ~

cd -

Switches back to the previous working directory.

Syntax: cd -

pushd

Saves the current directory and then changes to the specified directory.

Syntax: pushd [directory]

popd

Returns to the directory saved by the last pushd command.

Syntax: popd

dirs

Displays the directory stack (list of directories saved with pushd).

Syntax: dirs [options]

File Management

mkdir

Creates a new directory (folder). Use -p to create nested directories.

Syntax: mkdir [options] directory_name

touch

Creates an empty file or updates the timestamp of an existing file.

Syntax: touch [options] filename

cp

Copies files or directories from one location to another.

Syntax: cp [options] source destination

mv

Moves or renames files and directories.

Syntax: mv [options] source destination

rm

Removes (deletes) files or directories. Use -rf for recursive force delete.

Syntax: rm [options] file

rmdir

Removes an empty directory. Safer than rm -r for removing directories.

Syntax: rmdir directory_name

cat

Displays the entire contents of a file on the terminal.

Syntax: cat [options] filename

less

Views file contents page by page with forward and backward navigation.

Syntax: less filename

more

Views file contents one screen at a time (forward-only navigation).

Syntax: more filename

head

Displays the first 10 lines of a file by default. Use -n to specify count.

Syntax: head [options] filename

tail

Displays the last 10 lines of a file. Use -f to follow file changes in real time.

Syntax: tail [options] filename

nano

Opens a simple, beginner-friendly terminal text editor.

Syntax: nano filename

vim

Opens the powerful Vim text editor for editing files.

Syntax: vim filename

wc

Counts lines, words, and characters in a file.

Syntax: wc [options] filename

ln

Creates links between files. Use -s for symbolic (soft) links.

Syntax: ln [options] source target

stat

Displays detailed file and filesystem information (size, permissions, timestamps).

Syntax: stat filename

file

Determines and displays the file type (text, binary, image, etc.).

Syntax: file filename

tee

Reads from stdin and writes to both stdout and one or more files simultaneously.

Syntax: command | tee filename

diff

Compares two files line by line and shows the differences.

Syntax: diff [options] file1 file2

User Management

whoami

Displays the username of the currently logged-in user.

Syntax: whoami

who

Shows all users currently logged into the system with login details.

Syntax: who [options]

w

Displays who is logged in and what they are currently doing.

Syntax: w [username]

id

Prints user and group IDs (UID, GID) for the specified or current user.

Syntax: id [username]

su

Switches to another user account or the root user.

Syntax: su [options] [username]

sudo

Executes a command with superuser (root) privileges.

Syntax: sudo command

passwd

Changes the password for a user account.

Syntax: passwd [username]

useradd

Creates a new user account on the system.

Syntax: useradd [options] username

usermod

Modifies an existing user account (groups, shell, home directory, etc.).

Syntax: usermod [options] username

userdel

Deletes a user account. Use -r to also remove the home directory.

Syntax: userdel [options] username

groupadd

Creates a new group on the system.

Syntax: groupadd groupname

groupdel

Deletes an existing group from the system.

Syntax: groupdel groupname

groups

Displays all groups the current user is a member of.

Syntax: groups [username]

last

Shows the last logged-in users from the system log file.

Syntax: last [options]

Permission Commands

chmod

Changes the read, write, and execute permissions of files and directories.

Syntax: chmod [options] mode file

chown

Changes the owner and/or group of a file or directory.

Syntax: chown [options] owner[:group] file

chgrp

Changes the group ownership of a file or directory.

Syntax: chgrp [options] group file

umask

Sets the default permission mask for newly created files and directories.

Syntax: umask [mode]

getfacl

Displays the Access Control List (ACL) of a file or directory.

Syntax: getfacl filename

setfacl

Sets or modifies the Access Control List (ACL) for a file or directory.

Syntax: setfacl [options] acl_spec file

sudo -l

Lists the allowed and forbidden sudo commands for the current user.

Syntax: sudo -l

visudo

Safely edits the /etc/sudoers file to configure sudo permissions.

Syntax: sudo visudo

Networking Commands

ping

Sends ICMP echo request packets to test network connectivity to a host.

Syntax: ping [options] host

ifconfig

Displays or configures network interface parameters (deprecated, use ip).

Syntax: ifconfig [interface]

ip

Modern replacement for ifconfig. Shows and manipulates routing, devices, and tunnels.

Syntax: ip [options] object command

netstat

Displays network connections, routing tables, interface statistics, and more.

Syntax: netstat [options]

ss

Modern replacement for netstat. Dumps socket statistics quickly.

Syntax: ss [options]

curl

Transfers data from or to a server using various protocols (HTTP, FTP, etc.).

Syntax: curl [options] URL

wget

Downloads files from the internet non-interactively via HTTP, HTTPS, or FTP.

Syntax: wget [options] URL

dig

Performs DNS lookups and displays detailed name server query information.

Syntax: dig [options] domain

nslookup

Queries DNS servers to resolve domain names to IP addresses and vice versa.

Syntax: nslookup [domain]

host

Simple utility for performing DNS lookups (forward and reverse).

Syntax: host [options] name

traceroute

Traces and displays the route packets take to reach a network host.

Syntax: traceroute host

arp

Displays and modifies the system's ARP cache (IP-to-MAC address mappings).

Syntax: arp [options]

route

Displays and modifies the IP routing table.

Syntax: route [options]

hostname

Shows or sets the system's hostname.

Syntax: hostname [new-name]

iwconfig

Displays and configures wireless network interface parameters.

Syntax: iwconfig [interface]

nmap

Network exploration tool and port scanner (basic usage).

Syntax: nmap [options] target

Process Commands

ps

Reports a snapshot of current running processes with their PIDs.

Syntax: ps [options]

top

Displays an interactive, real-time view of system processes and resource usage.

Syntax: top

htop

Enhanced, more user-friendly version of top with color and mouse support.

Syntax: htop

kill

Sends a signal to terminate a process by its PID.

Syntax: kill [options] PID

killall

Kills all processes matching a given name.

Syntax: killall [options] process_name

pkill

Sends a signal to processes based on name and other attributes.

Syntax: pkill [options] pattern

bg

Resumes a suspended job in the background.

Syntax: bg [job_id]

fg

Brings a background job to the foreground.

Syntax: fg [job_id]

jobs

Lists active jobs (background and suspended processes) in the current shell.

Syntax: jobs [options]

nice

Runs a command with a specified scheduling priority (niceness value).

Syntax: nice -n priority command

renice

Changes the priority (niceness) of an already running process.

Syntax: renice priority -p PID

nohup

Runs a command that keeps running even after the terminal session is closed.

Syntax: nohup command &

pgrep

Searches for processes by name and returns their PIDs.

Syntax: pgrep [options] pattern

System Information

uname

Prints system information such as kernel name, version, and architecture.

Syntax: uname [options]

uptime

Shows how long the system has been running along with load averages.

Syntax: uptime

hostnamectl

Displays and changes the system hostname and related settings.

Syntax: hostnamectl [options]

lscpu

Displays detailed CPU architecture information.

Syntax: lscpu

lsblk

Lists information about all available block devices (disks and partitions).

Syntax: lsblk [options]

lspci

Lists all PCI devices connected to the system (graphics cards, network adapters).

Syntax: lspci [options]

lsusb

Lists all USB devices connected to the system.

Syntax: lsusb [options]

free

Displays the amount of free and used system memory (RAM and swap).

Syntax: free [options]

vmstat

Reports virtual memory statistics including CPU, memory, and I/O.

Syntax: vmstat [options] [interval]

dmesg

Prints the kernel ring buffer messages (boot-time and hardware diagnostics).

Syntax: dmesg [options]

lsmod

Lists all currently loaded kernel modules.

Syntax: lsmod

modinfo

Displays detailed information about a specific kernel module.

Syntax: modinfo module_name

env

Displays all current environment variables.

Syntax: env

echo

Prints text or the value of variables to the terminal.

Syntax: echo [options] [string]

date

Displays or sets the system date and time.

Syntax: date [options] [format]

cal

Displays a calendar in the terminal.

Syntax: cal [month] [year]

history

Shows the list of previously executed commands in the current shell session.

Syntax: history [n]

clear

Clears the terminal screen.

Syntax: clear

alias

Creates or displays command aliases (shortcuts for longer commands).

Syntax: alias [name='command']

unalias

Removes a previously defined command alias.

Syntax: unalias name

Package Management

apt update

Updates the local package index with the latest information from repositories.

Syntax: apt update

apt upgrade

Upgrades all installed packages to their latest available versions.

Syntax: apt upgrade

apt install

Installs one or more packages from the repository.

Syntax: apt install package_name

apt remove

Removes a package but keeps its configuration files.

Syntax: apt remove package_name

apt purge

Removes a package along with all its configuration files.

Syntax: apt purge package_name

apt autoremove

Removes packages that were automatically installed as dependencies and are no longer needed.

Syntax: apt autoremove

apt search

Searches for packages in the repository by keyword.

Syntax: apt search keyword

apt show

Displays detailed information about a specific package.

Syntax: apt show package_name

apt list

Lists packages based on package names with options for installed/upgradeable.

Syntax: apt list [options]

dpkg -i

Installs a .deb package file directly (does not resolve dependencies).

Syntax: dpkg -i package.deb

dpkg -r

Removes an installed package (keeps config files).

Syntax: dpkg -r package_name

dpkg -l

Lists all installed packages with version and description.

Syntax: dpkg -l [pattern]

snap install

Installs a snap package from the Snap Store.

Syntax: snap install package_name

pip install

Installs Python packages from the Python Package Index (PyPI).

Syntax: pip install package_name

Compression Commands

tar

Archives multiple files into a single tarball. Use -czf to compress with gzip.

Syntax: tar [options] archive_name files

gzip

Compresses a single file using the gzip algorithm (replaces original with .gz).

Syntax: gzip [options] filename

gunzip

Decompresses a .gz file back to its original form.

Syntax: gunzip filename.gz

bzip2

Compresses files using the bzip2 algorithm (better compression than gzip, slower).

Syntax: bzip2 filename

bunzip2

Decompresses a .bz2 file back to its original form.

Syntax: bunzip2 filename.bz2

zip

Creates a compressed ZIP archive of files and directories.

Syntax: zip [options] archive.zip files

unzip

Extracts files from a ZIP archive.

Syntax: unzip archive.zip

xz

Compresses files using the xz (LZMA2) algorithm — very high compression ratio.

Syntax: xz filename

unxz

Decompresses a .xz file back to its original form.

Syntax: unxz filename.xz

7z

High-compression archiver supporting many formats (7z, zip, rar, tar, etc.).

Syntax: 7z a archive.7z files

Remote Access Commands

ssh

Connects securely to a remote machine via the SSH protocol.

Syntax: ssh [options] user@host

scp

Securely copies files between local and remote hosts over SSH.

Syntax: scp [options] source destination

rsync

Efficiently syncs files and directories between two locations (local or remote).

Syntax: rsync [options] source destination

ftp

Transfers files to and from a remote host using the File Transfer Protocol.

Syntax: ftp host

sftp

Securely transfers files over SSH (interactive FTP-like interface).

Syntax: sftp user@host

telnet

Connects to a remote host via the Telnet protocol (unencrypted — prefer SSH).

Syntax: telnet host port

ssh-keygen

Generates SSH public/private key pairs for passwordless authentication.

Syntax: ssh-keygen [options]

ssh-copy-id

Copies your SSH public key to a remote server for key-based authentication.

Syntax: ssh-copy-id user@host

Search Commands

find

Searches for files and directories in a directory hierarchy by name, type, size, etc.

Syntax: find [path] [expression]

grep

Searches for patterns (text or regex) inside files and prints matching lines.

Syntax: grep [options] pattern file

locate

Quickly finds files by name using a pre-built database (run updatedb to refresh).

Syntax: locate [options] pattern

which

Shows the full path of the executable that would run for a given command.

Syntax: which command

whereis

Locates the binary, source, and manual page files for a command.

Syntax: whereis command

type

Displays how a command name would be interpreted (alias, builtin, external, etc.).

Syntax: type command

awk

Powerful text processing language for pattern scanning and data extraction.

Syntax: awk 'pattern { action }' file

sed

Stream editor for filtering and transforming text (find/replace, insert, delete).

Syntax: sed [options] 'command' file

sort

Sorts lines of text files alphabetically or numerically.

Syntax: sort [options] file

uniq

Reports or filters out repeated lines in a sorted file.

Syntax: uniq [options] file

cut

Extracts specific columns/fields from each line of a file.

Syntax: cut [options] file

tr

Translates, deletes, or squeezes characters from standard input.

Syntax: tr [options] set1 set2

xargs

Builds and executes command lines from standard input (useful with pipes).

Syntax: xargs [options] command

Disk Commands

df

Reports disk space usage for all mounted filesystems (human-readable with -h).

Syntax: df [options]

du

Estimates file and directory space usage (disk usage).

Syntax: du [options] [path]

fdisk

Manipulates disk partition table (create, delete, resize partitions).

Syntax: fdisk [options] device

mount

Mounts a filesystem (attaches a device to the directory tree).

Syntax: mount [options] device mount_point

umount

Unmounts a filesystem (detaches a mounted device from the directory tree).

Syntax: umount [options] mount_point

mkfs

Creates a filesystem (formats) on a disk partition.

Syntax: mkfs -t type device

fsck

Checks and optionally repairs a filesystem for errors.

Syntax: fsck [options] device

dd

Copies and converts raw data at the block level (disk cloning, bootable USB creation).

Syntax: dd if=input of=output [options]

blkid

Displays block device attributes including UUID and filesystem type.

Syntax: blkid [device]

parted

Disk partitioning tool (supports GPT and MBR partition tables).

Syntax: parted [options] device

ncdu

Interactive disk usage analyzer with a terminal UI (ncurses-based).

Syntax: ncdu [path]

Service Commands

systemctl start

Starts a systemd service immediately.

Syntax: systemctl start service_name

systemctl stop

Stops a running systemd service immediately.

Syntax: systemctl stop service_name

systemctl restart

Stops and then starts a systemd service.

Syntax: systemctl restart service_name

systemctl enable

Enables a service to start automatically at boot time.

Syntax: systemctl enable service_name

systemctl disable

Disables a service from starting automatically at boot.

Syntax: systemctl disable service_name

systemctl status

Shows the current status, recent logs, and PID of a systemd service.

Syntax: systemctl status service_name

systemctl list-units

Lists all loaded and active systemd units (services, mounts, sockets, etc.).

Syntax: systemctl list-units [options]

service

Legacy command to run SysV init scripts (works on both SysV and systemd).

Syntax: service service_name action

journalctl

Queries and displays logs from the systemd journal.

Syntax: journalctl [options]