Linux Commands
Executive Summary
This cheatsheet is a quick reference for Linux navigation, file handling, users, permissions, processes, networking, services, logs, and package management.
Use it during labs, enumeration, troubleshooting, and system administration.
System Information
Show kernel and system information:
Show distribution:
Show hostname:
Show current user:
Show uptime:
Show environment variables:
Filesystem Navigation
Print current directory:
List files:
Change directory:
Show directory tree:
Find file by name:
Find writable directories:
File Viewing
View file:
Page through file:
Show first lines:
Show last lines:
Follow log output:
File Searching
Search text in files:
Case-insensitive search:
Search command history:
Find files modified in the last day:
Find large files:
Permissions
Show permissions:
Change permissions:
Add execute permission:
Change owner:
Find SUID files:
Find SGID files:
Users and Groups
Show current user ID and groups:
List logged-in users:
Show last logins:
List users:
List groups:
Show sudo privileges:
Processes
List processes:
Process tree:
Search processes:
Kill process by PID:
Force kill:
Interactive process viewer:
Networking
Show interfaces:
Show routes:
Show listening ports:
Show active connections:
Show ARP/neighbor table:
Test connection:
Check TCP port:
DNS
Resolve hostname:
Reverse lookup:
Query specific record:
Use specific DNS server:
Services
List running services:
Check service status:
Start service:
Stop service:
Enable service on boot:
Disable service on boot:
Logs
Common log locations:
/var/log/syslog
/var/log/auth.log
/var/log/kern.log
/var/log/apache2/
/var/log/nginx/
/var/log/audit/
View authentication logs:
Search failed logins:
View systemd logs:
View logs for service:
Packages
Debian/Ubuntu update package list:
Install package:
Remove package:
List installed packages:
Red Hat package install:
List RPM packages:
Compression
Create tar archive:
Extract tar archive:
Create gzip tar archive:
Extract gzip tar archive:
Zip directory:
Unzip:
File Transfer
Start HTTP server:
Download with wget:
Download with curl:
SCP upload:
SCP download:
Useful One-Liners
Show top directories by size:
Show current shell:
Show PATH:
Find world-writable files:
Find files containing possible secrets:
Notes
- Redirect errors with
2>/dev/nullto reduce noise. - Use
sudoonly when needed. - Check logs before assuming a service is broken.
- Confirm the distribution before using package commands.
- Prefer
ssover oldernetstaton modern Linux systems.