pwd Print Working Directory Show the full path of the current directory.
Example
$ pwd
/home/jane/projects/api Essential terminal commands explained in plain English — with examples and the exact words to use when describing them in a standup or code review.
cat Concatenate and print Print the entire contents of a file to the terminal.
$ cat .env
DATABASE_URL=postgres://...
PORT=3000 less Less View a file page by page — press q to quit, / to search.
$ 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).
$ 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.
$ 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.
$ 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 chmod Change Mode Change the read/write/execute permissions of a file.
$ 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.
$ chown www-data:www-data html/
$ chown -R jane:staff src/ sudo SuperUser Do Run a command as the root (administrator) user.
$ sudo apt install nginx
$ sudo systemctl restart nginx
$ sudo nano /etc/hosts ps Process Status List running processes.
$ 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.
$ 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.
$ top
$ htop # if installed; q to quit, F2 to configure curl Client URL Make HTTP requests from the command line.
$ 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.
$ 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.
$ 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.
$ scp file.txt user@server:/home/user/
$ scp user@server:/var/log/app.log ./logs/
$ scp -r dist/ user@server:/var/www/html/ tar Tape Archive Create or extract .tar (and .tar.gz) archives.
$ 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.
$ zip -r archive.zip dist/
$ unzip archive.zip
$ unzip archive.zip -d output/ # extract to a directory echo Echo Print text or variable values to the terminal.
$ echo "Hello, world!"
$ echo $HOME
$ echo $NODE_ENV env Environment List all environment variables, or run a command with a specific environment.
$ 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.
$ 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.
$ source .env
$ source ~/.bashrc
$ . ~/.zshrc # dot is an alias for source which Which Show the full path of a command executable.
$ which node
/usr/local/bin/node
$ which python3 man Manual Show the manual page (documentation) for a command.
$ man grep
$ man ssh
# press q to quit
# use --help for a short summary: grep --help | (pipe) Pipe Send the output of one command as the input to the next.
$ 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.
$ 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 Phrases engineers actually use when talking about terminal work.