CLI Commands Reference

Essential terminal commands explained in plain English — with examples and the exact words to use when describing them in a standup or code review.

Viewing File Contents

cat Concatenate and print

Print the entire contents of a file to the terminal.

Say it "cat"
Example
$ cat .env
DATABASE_URL=postgres://...
PORT=3000
less Less

View a file page by page — press q to quit, / to search.

Say it "less"
Example
$ less server.log
# press / then type a word to search
# press q to quit
head Head

Show the first N lines of a file (default 10).

Say it "head"
Example
$ head server.log
$ head -n 50 server.log   # first 50 lines
tail Tail

Show the last N lines of a file. -f follows new output in real time.

Say it "tail"
Example
$ tail server.log
$ tail -n 100 server.log
$ tail -f server.log    # "follow" — watch live log output
grep Global Regular Expression Print

Search for a pattern inside files or command output.

Say it "grep"
Example
$ grep "error" server.log
$ grep -r "TODO" src/               # recursive search
$ grep -i "Error" server.log        # case-insensitive
$ grep -n "port" config.yml         # show line numbers
$ cat server.log | grep "500"       # pipe: filter output

Permissions & Users

chmod Change Mode

Change the read/write/execute permissions of a file.

Say it "chmod"
Example
$ chmod +x deploy.sh            # make a script executable
$ chmod 600 .env                 # owner read/write only
$ chmod 644 README.md            # owner rw, others read-only
$ chmod -R 755 public/           # recursive
chown Change Owner

Change the owner (user and group) of a file or directory.

Say it "chown"
Example
$ chown www-data:www-data html/
$ chown -R jane:staff src/
sudo SuperUser Do

Run a command as the root (administrator) user.

Say it "sudo"
Example
$ sudo apt install nginx
$ sudo systemctl restart nginx
$ sudo nano /etc/hosts

Processes

ps Process Status

List running processes.

Say it "p-s"
Example
$ ps aux                          # all processes, detailed
$ ps aux | grep node              # find Node.js processes
kill Kill

Send a signal to a process, usually to terminate it.

Say it "kill"
Example
$ kill 12345          # send SIGTERM (graceful stop)
$ kill -9 12345       # send SIGKILL (force stop)
$ killall node        # kill all processes named "node"
top / htop Table of Processes / Interactive Process Viewer

Live view of CPU and memory usage by process. htop is the friendly version.

Say it "top / h-top"
Example
$ top
$ htop   # if installed; q to quit, F2 to configure

Networking & Remote

curl Client URL

Make HTTP requests from the command line.

Say it "curl"
Example
$ curl https://api.example.com/health
$ curl -X POST https://api.example.com/users \
  -H "Content-Type: application/json" \
  -d '{"name":"Jane"}'
$ curl -I https://example.com       # headers only
wget Web Get

Download files from a URL.

Say it "wget"
Example
$ wget https://example.com/archive.zip
$ wget -O output.zip https://example.com/archive.zip
ssh Secure Shell

Log in to a remote server securely over the network.

Say it "S-S-H"
Example
$ ssh user@192.168.1.10
$ ssh -i ~/.ssh/my-key.pem ubuntu@ec2-1-2-3-4.compute.amazonaws.com
$ ssh -p 2222 user@example.com        # non-default port
scp Secure Copy Protocol

Copy files between local machine and a remote server over SSH.

Say it "s-c-p"
Example
$ scp file.txt user@server:/home/user/
$ scp user@server:/var/log/app.log ./logs/
$ scp -r dist/ user@server:/var/www/html/

Archives & Compression

tar Tape Archive

Create or extract .tar (and .tar.gz) archives.

Say it "tar"
Example
$ tar -czf archive.tar.gz dist/    # compress folder
$ tar -xzf archive.tar.gz           # extract
$ tar -tzf archive.tar.gz           # list contents without extracting
# Flags: c=create, x=extract, z=gzip, f=filename, t=list
zip / unzip Zip / Unzip

Create or extract .zip archives.

Say it "zip / unzip"
Example
$ zip -r archive.zip dist/
$ unzip archive.zip
$ unzip archive.zip -d output/     # extract to a directory

Environment & Shell

echo Echo

Print text or variable values to the terminal.

Say it "echo"
Example
$ echo "Hello, world!"
$ echo $HOME
$ echo $NODE_ENV
env Environment

List all environment variables, or run a command with a specific environment.

Say it "env"
Example
$ env                        # list all env vars
$ env | grep NODE            # filter env vars
$ env NODE_ENV=production node app.js
export Export

Set an environment variable so child processes inherit it.

Say it "export"
Example
$ export NODE_ENV=production
$ export PORT=3000
$ export DATABASE_URL="postgres://localhost/mydb"
source Source

Run a script in the current shell — useful for loading .env files or updating PATH.

Say it "source"
Example
$ source .env
$ source ~/.bashrc
$ . ~/.zshrc    # dot is an alias for source
which Which

Show the full path of a command executable.

Say it "which"
Example
$ which node
/usr/local/bin/node
$ which python3
man Manual

Show the manual page (documentation) for a command.

Say it "man"
Example
$ man grep
$ man ssh
# press q to quit
# use --help for a short summary: grep --help

Piping & Redirection

| (pipe) Pipe

Send the output of one command as the input to the next.

Say it "pipe"
Example
$ cat server.log | grep "ERROR" | tail -n 20
$ ps aux | grep node
$ ls -la | less
> and >> Redirect output

> overwrites a file with output. >> appends to a file.

Say it "redirect to / append to"
Example
$ echo "build failed" > error.txt    # overwrite
$ cat server.log >> all-logs.txt     # append
$ npm run build 2>&1 | tee build.log  # tee: write to file AND show in terminal

How to Say Commands Aloud

When talking with teammates, you'll describe commands in words. Here's how to translate common command strings into natural spoken English.

You type You say
grep -r "error" ./logs "grep dash r for error in the logs directory"
chmod +x deploy.sh "chmod plus x deploy dot s-h"
tail -f app.log "tail dash f app dot log"
ls -la "l-s dash l-a"
ssh -i key.pem user@host "S-S-H dash i key dot pem user at host"
curl -X POST "curl dash X POST"
rm -rf dist/ "r-m dash r-f dist slash"
ps aux | grep node "p-s aux pipe grep node"
tar -czf archive.tar.gz src/ "tar dash c-z-f archive dot tar dot g-z s-r-c slash"
kill -9 1234 "kill dash nine twelve-thirty-four"

General rules

  • Flags: Say "dash" for - and "double-dash" for --. "-v" = "dash v", "--verbose" = "double-dash verbose".
  • Path separators: Say "slash" for / and "backslash" for \. Say "dot" for . when it's part of a filename.
  • Pipe: Say "pipe" for |.
  • Tilde: Say "tilde" for ~ (home directory).
  • Asterisk: Say "star" or "wildcard" for *.
  • Redirects: Say "redirect to" for > and "append to" for >>.
  • Extensions: Spell or read them: .sh = "dot s-h" or "shell script", .tar.gz = "dot tar dot g-z".

CLI Phrasebook

Phrases engineers actually use when talking about terminal work.

"I'm SSHing into the server."
I'm connecting to the remote server via SSH.
"Let me grep the logs for the error."
I'll search the log file for the error message.
"I'll tail the log file to watch it live."
I'll run tail -f to watch new log entries in real time.
"I need to chmod the script to make it executable."
I'll run chmod +x on the script file.
"Let me curl the endpoint."
I'll send an HTTP request to the API endpoint using curl.
"I'll SCP the file over."
I'll copy the file to the remote server using scp.
"Check if port 3000 is in use."
Run: lsof -i :3000 or ss -ltnp | grep 3000.
"Kill the process on port 8080."
Find the PID (lsof -i :8080) then kill that PID.
"I'll tar up the build folder."
I'll compress the build directory into a .tar.gz archive.
"Export the env var first."
Run export VARIABLE_NAME=value before running the command.
"Pipe the output to grep."
Add | grep "pattern" to the end of the command.
"The script isn't executable — chmod it."
Run chmod +x script.sh to give it execute permission.