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] -hGet help about a commandman [command]Show the help manual of the command
cdHome directorycd [folder]Change directory, e.g. cd Documentscd ~Home directorycd/Root of the drivecd -Previous directory or folder you last browsedpwdShow your working directorycd..Move up to the parent directorycd../..Move up two levels
lsDisplay the name of files and subdirectories in the directoryls -CForce multi-column output of the listingls -aList all entries including those with .(period) and ..(double period)ls -1Output the list of files in one entry per line formatls -FDisplay a / (slash) immediately after each path that is a directory, * (asterisk) after executable programs or scripts, and @ after a symbolic linkls -SSort files or entries by sizels -lList in a long format. Includes file mode, owner and group name, date and time file was modified, pathname, and morels -ltList the files sorted by time modified (most recent first)ls -lhLong listing with human readable file sizes in KB, MB, or GBls -loList the file names with size, owner, and flagsls -laList detailed directory contents, including hidden files
duList usage for each subdirectory and its contentsdu -sh [folder]Human readable output of all files in a directorydu -sDisplay an entry for each specified filedu -sk* | sort -nrList files and folders, totaling the size including the subfolders. Replace sk* with sm* to list directories in MBdf -hCalculate your system's free disk spacedf -HCalculate free disk space in powers of 1,000 (as opposed to 1,024)lscpuShow cpu statslshwShow hardware statshwinfoShow hardware infosinixi -FxShow hardware info, beautifully wrappeddfShow 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
mdfindSpotlight search fileopenOpen a file with desktop app
Ctrl + RSearch through previously used commandshistory nShows 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 -ldDisplay 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 -axOutput currently running processes. Here, a shows processes from all users and x shows processes that are not connected with the Terminalps -auxShows all the processes with %cpu, %mem, page in, PID, and commandtopDisplay live information about currently running processeshtopSee processes and memory statstop -ocpu -s 5Display processes sorted by CPU usage, updating every 5 secondstop -o rsizeSort top by memory usagefreeShow memory usagevmstatReport virtual memory statisticsdstat, atopHelps correlate all existing resource data for processes, memory, paging, block I/O, traps, and CPU activity.iftopInteractive network traffic viewer per interfacenethogsInteractive network traffic viewer per processiotopInteractive I/O vieweriostatFor storage I/O statisticssarmpstatFor CPU statisticstloadLoad average graph for terminalxloadLoad average graph for X/proc/loadavgText file containing load averagekill PIDQuit process with ID PID. You'll see PID as a column in the Activity Monitorps -ax | grep [appname]Find a process by name or PIDfactorFactor integers
ifconfigFind 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 hostnettopDisplay network activitytraceroute [host]Display the packets route to the hostdig [host]Simulate the domain name servernetstatShow listening ports (deprecated)ssShow listening ports (successor tonetstat)networkQualitymacOS Monterey specific network quality testtcpdumpTool for analyzing internet traffic
brew doctorCheck brew for potential problemsbrew install [formula]Install a formulabrew uninstall [formula]Uninstall a formulabrew listList all the installed formulasbrew searchDisplay available formulas for brewingbrew upgradeUpgrade all outdated and unpinned brewsbrew updateFetch latest version of homebrew and formulabrew cleanupRemove older version of installed formulabrew tap homebrew/caskTap the cask repository from GitHubbrew cask listList 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]" dirSearch 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 updateUpdate Package Listssudo apt upgradeDownload and Install Updated Packagessudo apt cleanClean Old Package Filessudo raspi-configThe Raspberry Pi Configuration Tooltree -dShow a Tree of DirectoriesclearClear the Terminal Windowsudo haltShut Down a Raspberry Pisudo rebootRestart a Raspberry PistartxStart the Desktop Environment (LXDE)
security find-generic-password -wa wifinameShow Wi-Fi passwordsudo powermetrics --samplers cpupower,gpupower,thermal,battery -i 1000 -o powermetricslog.txtPowermetrics logs into a filesudo powermetrics -s smcmacOS specific get fan speedyes > /dev/null &Stress CPUfind / -type f -name something.txtSearches for a file from root directorylocate [filename]Locate a file by namecat /dev/urandomFreeze the console with endless random stream outputsudo tcpdump -nnSX port 433Prints all the HTTPS traffic
callCalls a batch file from another onecdChange directoryclsClear screencmdStart command promptcolorChange console colordateShow/set datedirList directory contentechoText outputexitExits the command prompt or a batch filefindFind fileshostnameDisplay host namepausePauses the execution of a batch file and * shows a messagerunasStart a program as another usershutdownShutdown the computersortSort the screen outputstartStart an own window to execute a program or commandtaskkillTerminate a process or a applicationtasklistDisplay applications and related taskstimeDisplay/edit the system timetimeoutWait any timetitleSet title for promptverDisplay operating system versionw32tmSetting time synchronisation/time server/time zone
ftpTransfer files to a FTP serverftypeDisplay file type and mappinggetmacSisplay MAC addressipconfigSisplay IP network settingsnetshConfigure/control/display network componentsnetstatDisplay TCP/IP connections and statusnslookupQuery the DNSpathpingTest the connection to a specific IP addressping [domainname]Pings the networkrouteDisplay network routing table, add static routessysteminfoDisplays computer-specific properties and configurationstelnetEstablish Telnet connectiontftpTransfer files to a TFTP servertracert [domainname]Trace routes similar to patchpingarp -aDisplay network addressesnslookup [domainname]Simulate the domain name server
attribDisplay file attributescompCompare file contentscompactDisplay/change file compressioncopy / xcopyCopy filesdiskcompCompare content of two floppy disksdiskcopyCopy floppy disc to another oneerase / delDelete one or more filesexpandExtract filesfcCompare files and display the differencesmkdirCreate a new directorymoveMove/rename filesrenameRename filesreplaceReplace filesrmdir / rdDelete directorytreeDisplay folder structure graphicallytypeDisplay content of text files
chkdskCheck volumeschkntfsDisplay/change volume check at startupsfcSystem file scandefragDefragment mediadiskpartVolume managementdriverqueryDisplay installed devices and their propertiesformatFormat volumeslabelChange volume namemodeConfigure interfaces/devicesmountvolAssign/delete drive mountpointsverifyMonitoring whether volumes are written correctlyvolShow volume description and serial numbers of the HDDspowercfgEnergy and battery reports and options
forfor loopgpresultDisplay group policiesgpupdateUpdate group policiesperfmonStart performance monitorpromptChange command promptregAdd/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 60while (1) { ps | sort -desc cpu | select -first 30; sleep-seconds 2; cls }top command equivalent in Windows