Curated and comprehensive list of Linux-Mac (Unix) and Windows console commands.
Disclaimer: Don't insert the square brackets when typing the command in the console, they are used here just for the sake of clarity.
Disclaimer: In Win32, all the commands are compatible with PowerShell, only a subset is compatible with CMD.
Hide/Show
/
(Forward Slash) Top level directory.
(Single Period) Current directory..
(Double Period) Parent directory~
(Tilde) Home directorysudo [command]
Run command with the security privileges of the super usernano [file]
Opens the Terminal editoropen [file]
Opens a file[command] -h
Get help about a commandman [command]
Show the help manual of the command
cd
Home directorycd [folder]
Change directory, e.g. cd Documentscd ~
Home directorycd/
Root of the drivecd -
Previous directory or folder you last browsedpwd
Show your working directorycd..
Move up to the parent directorycd../..
Move up two levels
ls
Display the name of files and subdirectories in the directoryls -C
Force multi-column output of the listingls -a
List all entries including those with .(period) and ..(double period)ls -1
Output the list of files in one entry per line formatls -F
Display a / (slash) immediately after each path that is a directory, * (asterisk) after executable programs or scripts, and @ after a symbolic linkls -S
Sort files or entries by sizels -l
List in a long format. Includes file mode, owner and group name, date and time file was modified, pathname, and morels -lt
List the files sorted by time modified (most recent first)ls -lh
Long listing with human readable file sizes in KB, MB, or GBls -lo
List the file names with size, owner, and flagsls -la
List detailed directory contents, including hidden files
du
List usage for each subdirectory and its contentsdu -sh [folder]
Human readable output of all files in a directorydu -s
Display an entry for each specified filedu -sk* | sort -nr
List files and folders, totaling the size including the subfolders. Replace sk* with sm* to list directories in MBdf -h
Calculate your system's free disk spacedf -H
Calculate free disk space in powers of 1,000 (as opposed to 1,024)lscpu
Show cpu statslshw
Show hardware statshwinfo
Show hardware infosinixi -Fx
Show hardware info, beautifully wrappeddf
Show file system usage
mkdir [dir]
Create new folder named dirmkdir -p [dir/dir]
Create nested foldersmkdir [dir1] [dir2] [dir3]
Create several folders at oncemkdir ["dir"]
Create a folder with a space in the filenamermdir [dir]
Delete a folder (only works on empty folders)rm -R [dir]
Delete a folder and its contentscp [file] [dir]
Copy a file to the foldercp [file] [newfile]
Copy a file to the current foldercp [file] [~/dir/newfile]
Copy a file to the folder and rename the copied filecp -R [dir] ["new dir"]
Copy a folder to a new folder with spaces in the filenamecp -i [filedir]
Prompts you before copying a file with a warning overwrite messagecp [file1] [file2] [file3/dir]
Copy multiple files to a folderrm [file]
Delete a file (This deletes the file permanently; use with caution.)rm -i [file]
Delete a file only when you give confirmationrm -f [file]
Force removal without confirmationrm [file1] [file2] [file3]
Delete multiple files without any confirmationmv [file] [newfilename]
Move/renamemv [file] [dir]
Move a file to the folder, possibly by overwriting an existing filemv -i [file] [dir]
Optional -i flag to warn you before overwriting the file- mv *.png [~/dir] Move all PNG files from current folder to a different folder
mdfind
Spotlight search fileopen
Open a file with desktop app
Ctrl + R
Search through previously used commandshistory n
Shows the previous commands you've typed Add a number to limit to the last n items![value]
Execute the last command typed that starts with a value!!
Execute the last command typed
ls -ld
Display the default permission for a home directoryls -ld/[dir]
Display the read, write, and access permission of a particular folderchmod 755 [file]
Change the permission of a file to 755chmod -R 600 [dir]
Change the permission of a folder (and its contents) to 600chown user:group [file]
Change the ownership of a file to user and group. Add -R to include folder contents
ps -ax
Output currently running processes. Here, a shows processes from all users and x shows processes that are not connected with the Terminalps -aux
Shows all the processes with %cpu, %mem, page in, PID, and commandtop
Display live information about currently running processeshtop
See processes and memory statstop -ocpu -s 5
Display processes sorted by CPU usage, updating every 5 secondstop -o rsize
Sort top by memory usagefree
Show memory usagevmstat
Report virtual memory statisticsdstat, atop
Helps correlate all existing resource data for processes, memory, paging, block I/O, traps, and CPU activity.iftop
Interactive network traffic viewer per interfacenethogs
Interactive network traffic viewer per processiotop
Interactive I/O vieweriostat
For storage I/O statisticssar
mpstat
For CPU statisticstload
Load average graph for terminalxload
Load average graph for X/proc/loadavg
Text file containing load averagekill PID
Quit process with ID PID. You'll see PID as a column in the Activity Monitorps -ax | grep [appname]
Find a process by name or PIDfactor
Factor integers
ifconfig
Find your IP addressping [host]
Ping host and display statuswhois [domain]
Output whois info for a domaincurl -O [url/to/file]
Download file via HTTP, HTTPS, or FTPssh [username]@[host]
Establish SSH connection to host with user usernamescp file[user]@[host]:[/remote/path]
Copy file to a remote hostnettop
Display network activitytraceroute [host]
Display the packets route to the hostdig [host]
Simulate the domain name servernetstat
Show listening ports (deprecated)ss
Show listening ports (successor tonetstat
)networkQuality
macOS Monterey specific network quality testtcpdump
Tool for analyzing internet traffic
brew doctor
Check brew for potential problemsbrew install [formula]
Install a formulabrew uninstall [formula]
Uninstall a formulabrew list
List all the installed formulasbrew search
Display available formulas for brewingbrew upgrade
Upgrade all outdated and unpinned brewsbrew update
Fetch latest version of homebrew and formulabrew cleanup
Remove older version of installed formulabrew tap homebrew/cask
Tap the cask repository from GitHubbrew cask list
List all installed casksbrew cask install [cask]
Install the given caskbrew cask uninstall [cask]
Uninstall the given cask
find dir -name ["file"]
Find all files named file inside dir. Use wildcards (*) to search for parts of filenamesgrep "[text]" [file]
Output all occurrences of TEXT inside file (add -i for case insensitivity)grep -rl "[text]" dir
Search for all files containing TEXT inside dirls | grep "^abc"
Find all the files with name starting with abc in the current directory
cat [file]
Output the content of fileless [file]
Output the contents of file using the less command that supports pagination and morehead [file]
Output the first 10 lines of file
sudo apt update
Update Package Listssudo apt upgrade
Download and Install Updated Packagessudo apt clean
Clean Old Package Filessudo raspi-config
The Raspberry Pi Configuration Tooltree -d
Show a Tree of Directoriesclear
Clear the Terminal Windowsudo halt
Shut Down a Raspberry Pisudo reboot
Restart a Raspberry Pistartx
Start the Desktop Environment (LXDE)
security find-generic-password -wa wifiname
Show Wi-Fi passwordsudo powermetrics --samplers cpupower,gpupower,thermal,battery -i 1000 -o powermetricslog.txt
Powermetrics logs into a filesudo powermetrics -s smc
macOS specific get fan speedyes > /dev/null &
Stress CPUfind / -type f -name something.txt
Searches for a file from root directorylocate [filename]
Locate a file by namecat /dev/urandom
Freeze the console with endless random stream outputsudo tcpdump -nnSX port 433
Prints all the HTTPS traffic
call
Calls a batch file from another onecd
Change directorycls
Clear screencmd
Start command promptcolor
Change console colordate
Show/set datedir
List directory contentecho
Text outputexit
Exits the command prompt or a batch filefind
Find fileshostname
Display host namepause
Pauses the execution of a batch file and * shows a messagerunas
Start a program as another usershutdown
Shutdown the computersort
Sort the screen outputstart
Start an own window to execute a program or commandtaskkill
Terminate a process or a applicationtasklist
Display applications and related taskstime
Display/edit the system timetimeout
Wait any timetitle
Set title for promptver
Display operating system versionw32tm
Setting time synchronisation/time server/time zone
ftp
Transfer files to a FTP serverftype
Display file type and mappinggetmac
Sisplay MAC addressipconfig
Sisplay IP network settingsnetsh
Configure/control/display network componentsnetstat
Display TCP/IP connections and statusnslookup
Query the DNSpathping
Test the connection to a specific IP addressping [domainname]
Pings the networkroute
Display network routing table, add static routessysteminfo
Displays computer-specific properties and configurationstelnet
Establish Telnet connectiontftp
Transfer files to a TFTP servertracert [domainname]
Trace routes similar to patchpingarp -a
Display network addressesnslookup [domainname]
Simulate the domain name server
attrib
Display file attributescomp
Compare file contentscompact
Display/change file compressioncopy / xcopy
Copy filesdiskcomp
Compare content of two floppy disksdiskcopy
Copy floppy disc to another oneerase / del
Delete one or more filesexpand
Extract filesfc
Compare files and display the differencesmkdir
Create a new directorymove
Move/rename filesrename
Rename filesreplace
Replace filesrmdir / rd
Delete directorytree
Display folder structure graphicallytype
Display content of text files
chkdsk
Check volumeschkntfs
Display/change volume check at startupsfc
System file scandefrag
Defragment mediadiskpart
Volume managementdriverquery
Display installed devices and their propertiesformat
Format volumeslabel
Change volume namemode
Configure interfaces/devicesmountvol
Assign/delete drive mountpointsverify
Monitoring whether volumes are written correctlyvol
Show volume description and serial numbers of the HDDspowercfg
Energy and battery reports and options
for
for loopgpresult
Display group policiesgpupdate
Update group policiesperfmon
Start performance monitorprompt
Change command promptreg
Add/read/import/export registry entries
- In a batch file (.bat) ->
:main start goto main
(Possible one line console execution of script above)
:main & start & goto main
shutdown -s -t 60
while (1) { ps | sort -desc cpu | select -first 30; sleep-seconds 2; cls }
top command equivalent in Windows