Useful commands for Windows (CMD and PowerShell), Linux and macOS. Commands marked as needing Administrator or sudo will fail without it.
ipconfig /all | Full network configuration for every adapter. |
ipconfig /flushdns | Clear the DNS resolver cache. |
ipconfig /release then ipconfig /renew | Drop and request a new DHCP lease. |
ping -n 4 example.com | Send four echo requests to test connectivity. |
tracert example.com | Show each hop on the route to a host. |
nslookup example.com | Query DNS for a hostname. |
netstat -ano | List active connections and listening ports with owning PIDs. |
tasklist | List running processes. |
taskkill /PID 1234 /F | Force-stop a process by its PID. |
systeminfo | OS version, hardware, install date and uptime. |
whoami /all | Current user, groups and privileges. |
net user | List local user accounts. |
net localgroup administrators | List members of the local Administrators group. |
sfc /scannow | Scan and repair protected system files (run as Administrator). |
DISM /Online /Cleanup-Image /RestoreHealth | Repair the Windows component store (run as Administrator). |
chkdsk C: /f | Check the C: drive for errors and fix them (may require a reboot). |
gpupdate /force | Reapply Group Policy immediately. |
where notepad | Find the location of an executable on the PATH. |
dir /s /b *.log | Recursively list every .log file under the current folder. |
shutdown /r /t 0 | Restart the computer immediately. |
Get-ComputerInfo | Detailed system, OS and hardware information. |
Get-NetIPConfiguration | IP, gateway and DNS settings per adapter. |
Test-NetConnection example.com -Port 443 | Test TCP reachability to a host and port. |
Resolve-DnsName example.com | DNS lookup with record type support. |
Clear-DnsClientCache | Clear the DNS client cache. |
Get-Process | Sort-Object CPU -Descending | Select-Object -First 10 | Top 10 processes by CPU time. |
Get-Service | Where-Object Status -eq Stopped | List all stopped services. |
Restart-Service -Name Spooler | Restart a service by name (run as Administrator). |
Get-WinEvent -LogName System -MaxEvents 20 | Show the 20 most recent System event log entries. |
Get-LocalUser | List local user accounts and their status. |
Get-LocalGroupMember -Group Administrators | List members of the local Administrators group. |
Get-ChildItem -Recurse -Filter *.log | Search the current folder tree for .log files. |
Get-Content C:\path\app.log -Wait -Tail 20 | Follow the end of a log file in real time (like tail -f). |
Get-FileHash C:\file.iso -Algorithm SHA256 | Verify a file hash, for example after a download. |
Get-Disk | List physical disks and their health. |
Invoke-WebRequest https://example.com -Method Head | Fetch only the HTTP headers of a URL. |
Get-Date -Format o | Current date and time in ISO 8601 format. |
Get-ExecutionPolicy -List | Show the script execution policy at each scope. |
df -h | Disk space used and free on each filesystem. |
du -sh * | sort -h | Size of each item in the current folder, sorted. |
free -h | Memory and swap usage. |
uptime | System uptime and load averages. |
top / htop | Live view of processes and resource use. |
ps aux | grep nginx | Find running processes matching a name. |
ss -tulpn | Listening TCP and UDP ports with owning processes. |
ip a and ip r | Network interfaces with addresses, and the routing table. |
dig example.com +short | Concise DNS lookup. |
curl -I https://example.com | Fetch only the HTTP response headers. |
sudo systemctl status nginx | Check the status of a service. |
sudo systemctl restart nginx | Restart a service. |
journalctl -u nginx -f | Follow the logs for a specific service. |
sudo apt update && sudo apt upgrade | Update package lists and upgrade installed packages (Debian/Ubuntu). |
grep -R "error" /var/log | Recursively search files for a string. |
find / -name "*.conf" 2>/dev/null | Find files by name, hiding permission errors. |
lsof -i :80 | Show which process is using a port. |
tar -czf backup.tar.gz folder/ | Create a compressed archive. |
chmod 640 file / chown user:group file | Change file permissions or ownership. |
last -n 10 | Show the last 10 logins. |
sw_vers | macOS version and build number. |
system_profiler SPHardwareDataType | Hardware model, chip, memory and serial. |
df -h | Disk space used and free. |
diskutil list | List disks and partitions. |
ipconfig getifaddr en0 | IP address of the Wi-Fi interface (en0). |
networksetup -listallhardwareports | List network services and their device names. |
scutil --dns | Show the DNS resolver configuration. |
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder | Flush the DNS cache. |
lsof -iTCP -sTCP:LISTEN -n -P | List listening TCP ports and their processes. |
pmset -g batt | Battery status and charge level. |
caffeinate -d | Keep the display awake until stopped with Ctrl+C. |
softwareupdate -l | List available macOS updates. |
launchctl list | List loaded launchd services. |
log show --last 1h --info | Show unified log entries from the last hour. |
brew update && brew upgrade | Update Homebrew and upgrade installed packages. |
open -a "Activity Monitor" | Open an application from the terminal. |