Terminal Commands

Linux, macOS and PowerShell — every command with a real-world example and the mistake everyone makes.

39 commands

OS

Category

39 results

ls -la
linuxmac

List all files and directories, including hidden ones, with detailed info

Get-ChildItem -Force
windows

List all files including hidden ones in PowerShell (alias: ls or dir)

cd <directory>
linuxmacwindows

Change into a directory. Use ~ for home, .. for parent, - to go back

pwd
linuxmac

Print the full path of your current working directory

find <path> -name "<pattern>"
linuxmac

Recursively search for files matching a pattern

grep -rn "<pattern>" <path>
linuxmac

Search for a text pattern inside files recursively, showing line numbers

Select-String -Path "<pattern>" -Recurse "<text>"
windows

PowerShell equivalent of grep — searches for text within files

mkdir -p <path>
linuxmacwindows

Create a directory and all its parents in one command

touch <filename>
linuxmac

Create an empty file or update its last-modified timestamp

cp -r <source> <destination>
linuxmac

Copy a file or directory (-r for recursive)

mv <source> <destination>
linuxmac

Move or rename a file or directory

rm -rf <path>
linuxmac

Delete a file or directory permanently. No trash bin — gone forever

cat <file>
linuxmac

Print a file's contents to the terminal

less <file>
linuxmac

View a file with scrolling. Press q to quit, / to search inside

tail -f <file>
linuxmac

Watch a file's new content in real time. Essential for logs

chmod <permissions> <file>
linuxmac

Change file permissions. 755 for executables, 644 for files, 600 for secrets

sudo <command>
linuxmac

Run a command as the superuser (root). Required for system-level tasks

curl -X <METHOD> <url>
linuxmac

Make HTTP requests from the terminal. Perfect for testing APIs

ssh <user>@<host>
linuxmacwindows

Connect to a remote server securely over SSH

scp <file> <user>@<host>:<path>
linuxmac

Securely copy files to or from a remote server

ps aux | grep <name>
linuxmac

List all running processes and filter by name

kill -9 <PID>
linuxmac

Force-kill a process by its PID. Get the PID from ps or lsof

lsof -i :<port>
linuxmac

Find what process is using a specific network port

htop
linuxmac

Interactive process viewer — better than top. Shows CPU, memory, per-process

sed -i 's/<old>/<new>/g' <file>
linuxmac

Find and replace text in a file in-place

awk '{print $<N>}' <file>
linuxmac

Extract specific columns from structured text output

sort <file> | uniq -c | sort -rn
linuxmac

Count occurrences of each unique line, sorted by most common

wc -l <file>
linuxmac

Count lines (-l), words (-w), or characters (-c) in a file

tar -czf <output.tar.gz> <folder>
linuxmac

Create a compressed tar archive. -c create, -z gzip, -f filename

<command1> | <command2>
linuxmac

Pipe output of one command as input to another. The | is one of the most powerful shell features

alias <name>='<command>'
linuxmac

Create a shortcut for a long command. Add to ~/.bashrc or ~/.zshrc to persist

printenv | grep <name>
linuxmacwindows

Print environment variables, optionally filtered by name

history | grep <keyword>
linuxmac

Search your command history. Press Ctrl+R to interactively search

which <command>
linuxmac

Find where a command's binary lives on your system

df -h
linuxmac

Show disk usage of all mounted filesystems in human-readable format

du -sh <folder>
linuxmac

Show total size of a directory in human-readable format

<command> | xargs <command>
linuxmac

Pass output of one command as arguments to another

crontab -e
linuxmac

Edit your cron jobs to schedule commands at specific times

nohup <command> &
linuxmac

Run a command that keeps going after you close the terminal