CLI Cheatsheet

Quick reference for common Linux & Windows command-line commands

Linux Files & Directories

ls -laList all files with details
cd /pathChange directory
pwdPrint working directory
mkdir dirCreate a directory
rm -r dirRemove file/directory recursively
cp -r a bCopy files/directories
mv a bMove or rename
touch fileCreate empty file / update timestamp
find . -name "*.log"Search for files by name

Linux Viewing & Text

cat fileShow file contents
less fileScroll through a file
head -n 20 fileFirst 20 lines
tail -f fileFollow file as it grows
grep "text" fileSearch text in files
wc -l fileCount lines
nano fileEdit in a simple editor
diff a bCompare two files

Linux System & Processes

top / htopLive process monitor
ps auxList running processes
kill -9 PIDForce-kill a process
df -hDisk space usage
du -sh dirSize of a directory
free -hMemory usage
uname -aKernel / system info
uptimeHow long system has run

Linux Permissions & Users

chmod 755 fileChange permissions
chown user fileChange owner
sudo cmdRun as superuser
whoamiCurrent user
passwdChange your password
whoWho is logged in

Linux Networking

ping hostTest connectivity
ip aShow IP addresses
curl urlFetch a URL
wget urlDownload a file
ss -tulpnList open ports/sockets
ssh user@hostConnect to remote host
scp file user@host:/pathCopy files over SSH

Linux Packages & Services

apt install pkgInstall package (Debian/Ubuntu)
apt updateRefresh package list
dnf install pkgInstall package (Fedora/RHEL)
systemctl status svcCheck a service
systemctl restart svcRestart a service
journalctl -u svcView service logs

Windows Files & Directories

dirList directory contents
cd \pathChange directory
cdShow current directory
mkdir dirCreate a directory
rmdir /s dirRemove directory + contents
del fileDelete a file
copy a bCopy a file
xcopy /s a bCopy folders recursively
move a bMove or rename
ren a bRename a file

Windows Viewing & Text

type fileShow file contents
more fileView file page by page
find "text" fileSearch text in a file
findstr "regex" fileSearch with patterns
fc a bCompare two files
notepad fileOpen in Notepad

Windows System & Processes

tasklistList running processes
taskkill /PID 123 /FForce-kill a process
systeminfoDetailed system info
verWindows version
hostnameComputer name
shutdown /r /t 0Restart now
sfc /scannowRepair system files

Windows Networking

ipconfig /allShow network config
ipconfig /flushdnsClear DNS cache
ping hostTest connectivity
tracert hostTrace network route
nslookup domainDNS lookup
netstat -anoConnections + owning PID
net useMap/list network drives

Windows Users & Admin

whoamiCurrent user
net userList / manage user accounts
net localgroup administratorsList admins
gpupdate /forceRefresh group policy
runas /user:admin cmdRun as another user

Windows PowerShell Basics

Get-ChildItemList items (like ls)
Get-Content fileShow file contents
Get-ProcessList processes
Stop-Process -Id 123Kill a process
Get-ServiceList services
Test-Connection hostPing equivalent
Get-Help cmdHelp for a command
No commands match your search.