Skip to content

terminal

Frequently used shell commands for file navigation, permissions, networking and more.

System Information

Getting information about the system.

Display system details

Output host configuration and kernel version.

macOSLinux
Terminal window
uname -a
Windows
Terminal window
systeminfo

Monitor running processes

Open interactive resource usage dashboard.

macOSLinux
Terminal window
top
Windows
Terminal window
taskmgr

List active processes

List running processes with their IDs and resource usage.

macOSLinux
Terminal window
ps aux
Windows
Terminal window
tasklist

Search processes by name

Find process IDs and names matching a search term.

macOSLinux
Terminal window
pgrep -ifl <search-term>
Example
pgrep -ifl chrome
Case-insensitive; output format varies between macOS and Linux.
Windows
Terminal window
Get-Process | Where-Object { $_.ProcessName -like "*<search-term>*" }
Example
Get-Process | Where-Object { $_.ProcessName -like "*chrome*" }

Terminate processes by name

Send a termination signal to matching processes.

macOSLinux
Terminal window
pkill <process-name>
Example
pkill chrome
Matches process names, not app display names. Add -i for case-insensitive matching.
Windows
Terminal window
Stop-Process -Name <process-name>
Example
Stop-Process -Name chrome

Terminate processes by command line

Terminate processes whose command lines match a pattern.

macOSLinux
Terminal window
pkill -f <search-term>
Example
pkill -if chrome
Add -i for case-insensitive matching. May match multiple processes.
Windows
Terminal window
Get-CimInstance Win32_Process | Where-Object { $_.CommandLine -like "*<search-term>*" } | ForEach-Object { Stop-Process -Id $_.ProcessId }
Example
Get-CimInstance Win32_Process | Where-Object { $_.CommandLine -like "*chrome*" } | ForEach-Object { Stop-Process -Id $_.ProcessId }
May match multiple processes; access to command lines can be restricted.

Force terminate processes

Force-stop processes that do not terminate normally.

macOSLinux
Terminal window
pkill -9 <process-name>
Example
pkill -9 chrome
SIGKILL; cannot be caught or handled. Add -i for case-insensitive matching.
Windows
Terminal window
Stop-Process -Name <process-name> -Force
Example
Stop-Process -Name chrome -Force

Terminate process by PID

Terminate a specific process using its ID.

macOSLinux
Terminal window
kill <PID>
Example
kill 1234
Add -9 after kill to force termination.
Windows
Terminal window
Stop-Process -Id <PID>
Example
Stop-Process -Id 1234
Add -Force to force termination.

Check disk space usage

Display storage volume capacity and availability.

macOSLinux
Terminal window
df -h
Windows
Terminal window
Get-PSDrive

Measure folder size

Calculate total disk space consumed by a directory.

macOSLinux
Terminal window
du -sh Documents
Windows
Terminal window
Get-ChildItem Documents -Recurse | Measure-Object Length -Sum

Check service status

Query the current operational state of a service.

Linux
Terminal window
systemctl status nginx
macOS
Terminal window
launchctl print system/nginx
Windows
Terminal window
Get-Service nginx

Restart system service

Stop and start a system service daemon.

Linux
Terminal window
systemctl restart nginx
macOS
Terminal window
launchctl kickstart -k system/nginx
Windows
Terminal window
Restart-Service nginx

File Permissions and Ownership

Managing file access rights and ownership.

Terminal window
# chmod numeric permissions overview:
# Each digit represents permissions for: [Owner][Group][Others]
# Add values for read(4), write(2), execute(1)
#
# Examples:
# 7 = 4+2+1 = read, write, execute
# 6 = 4+2 = read, write
# 5 = 4+1 = read, execute
# 4 = 4 = read
# 3 = 2+1 = write, execute
# 2 = 2 = write
# 1 = 1 = execute
# 0 = none
#
# Common chmod values:
# 755 = rwx for owner, rx for group, rx for others
# 644 = rw for owner, r for group, r for others
# 700 = rwx for owner, none for group/others

Modify file permissions

Update numerical or symbolic access mode bits.

macOSLinux
Terminal window
chmod 644 myfile.txt
Windows
Terminal window
icacls myfile.txt /setintegritylevel medium

Make file executable

Grant execution rights to a script file.

macOSLinux
Terminal window
chmod +x script.sh
Windows
Terminal window
Unblock-File -Path script.ps1

Change owner and group

Reassign file ownership to a user and group.

macOSLinux
Terminal window
chown user:staff myfile.txt
Windows
Terminal window
icacls myfile.txt /setowner "Domain\User"

View detailed file status

Inspect low-level file metadata and status properties.

macOSLinux
Terminal window
stat myfile.txt
Windows
Terminal window
Get-ItemProperty myfile.txt

Archiving and Compression

Creating and extracting tarballs and zip files.

Terminal window
# tar common flags overview:
# c = create new archive
# x = extract archive
# v = verbose (show files being processed)
# f = specify filename of archive
# z = compress with gzip (.tar.gz)
# j = compress with bzip2 (.tar.bz2)
# J = compress with xz (.tar.xz)
#
# Examples:
# tar -cvf archive.tar files/ -> create tar
# tar -xvf archive.tar -> extract tar
# tar -czvf archive.tar.gz dir/ -> create gzipped tar
# tar -xzvf archive.tar.gz -> extract gzipped tar

Create tar archive

Package files into an uncompressed archive container.

macOSLinuxWindows
Terminal window
tar -cvf archive.tar myfolder

Extract tar archive

Unpack files from a tar container.

macOSLinuxWindows
Terminal window
tar -xvf archive.tar

Create compressed tarball

Package and gzip compress a directory structure.

macOSLinuxWindows
Terminal window
tar -czvf archive.tar.gz myfolder

Extract compressed tarball

Unpack and decompress a gzipped archive file.

macOSLinuxWindows
Terminal window
tar -xzvf archive.tar.gz

Create zip archive

Compress files into a standard zip format.

macOSLinux
Terminal window
zip archive.zip myfile.txt myfolder/*
Windows
Terminal window
Compress-Archive -Path myfile.txt, myfolder -DestinationPath archive.zip

Extract zip archive

Decompress files from a zip archive container.

macOSLinux
Terminal window
unzip archive.zip
Windows
Terminal window
Expand-Archive -Path archive.zip -DestinationPath .