Catalog / Command-Line Tools & Utilities Cheatsheet

Command-Line Tools & Utilities Cheatsheet

A quick reference guide to essential command-line tools and utilities, covering file manipulation, process management, networking, and system information.

File Management

Basic Operations

ls

List directory contents.

pwd

Print working directory.

cd <directory>

Change directory.

mkdir <directory>

Create a new directory.

rm <file>

Remove a file.

rmdir <directory>

Remove an empty directory.

cp <source> <destination>

Copy a file or directory.

mv <source> <destination>

Move or rename a file or directory.

touch <file>

Create an empty file or update timestamp.

Advanced File Operations

find <directory> -name <pattern>

Find files matching a pattern.

grep <pattern> <file>

Search for a pattern in a file.

head <file>

Display the first few lines of a file.

tail <file>

Display the last few lines of a file.

wc <file>

Count words, lines, and bytes in a file.

chmod <permissions> <file>

Change file permissions.

chown <user>:<group> <file>

Change file owner and group.

tar -czvf <archive_name>.tar.gz <directory>

Compress a directory into a tar.gz archive.

tar -xzvf <archive_name>.tar.gz

Extract a tar.gz archive.

Process Management

Process Information

ps

Display a snapshot of current processes.

top

Display dynamic real-time view of running processes.

htop

Interactive process viewer.

pidof <process_name>

Find the process ID of a running process.

pgrep <pattern>

Find processes by name or other attributes.

pstree

Display a tree of processes.

Process Control

kill <PID>

Terminate a process.

kill -9 <PID>

Forcefully terminate a process (SIGKILL).

pkill <pattern>

Kill processes by name or other attributes.

nohup <command> &

Run a command immune to hangups, with output to nohup.out.

bg

Move a process to the background.

fg

Move a process to the foreground.

jobs

List active jobs.

Networking

Network Information

ifconfig

Display network interface configuration.

ip addr

Display IP addresses.

netstat -tulnp

Display listening ports and associated processes.

ss -tulnp

Another utility to display socket statistics.

ping <host>

Test network connectivity.

traceroute <host>

Trace the route packets take to a host.

dig <domain>

DNS lookup utility.

nslookup <domain>

Query DNS servers to obtain domain name or IP address mapping.

Network Tools

curl <URL>

Transfer data from or to a server.

wget <URL>

Download files from the web.

ssh <user>@<host>

Secure Shell client for remote login.

scp <source> <destination>

Securely copy files between hosts.

nc -l -p <port>

Netcat listener on a port.

nc <host> <port>

Netcat client connecting to a host and port.

System Information

Hardware Information

lscpu

Display CPU architecture information.

lsblk

List block devices.

lspci

List PCI devices.

lsusb

List USB devices.

free -m

Display memory usage.

System Status

uname -a

Display system information.

uptime

Show how long the system has been running.

df -h

Display disk space usage.

du -sh <directory>

Display the disk usage of a directory.

w

Show who is logged on and what they are doing.

last

Show listing of last logged in users.

date

Display the current date and time.