Command reference

Every entry has a one-line summary and an example you can copy.

52 commands shown

AI & Dev Tools

git

Download a project and track changes to it. Also the easiest way to deploy a site to a server.

Syntax git clone url

git clone https://github.com/user/siteDB.git

jq

Read and filter JSON in the terminal. AI services return JSON, so this comes up a lot.

Syntax jq 'filter' file

curl -s https://api.github.com/repos/torvalds/linux | jq '.stargazers_count'

man

Open the manual page for a command. Read it before you run something an AI suggested.

Syntax man command

man tar

nvidia-smi

Show the status of NVIDIA GPUs: load, memory, and running processes. Useful for AI training jobs.

Syntax nvidia-smi

watch -n 2 nvidia-smi

ollama

Download and run an open-weight language model on your own machine, after Ollama is installed.

Syntax ollama run model

ollama run llama3.2

pip

Install Python libraries, including the ones used for machine learning.

Syntax pip install package

pip install requests

python3 -m venv

Create an isolated Python environment so project packages do not collide. Activate it with source .venv/bin/activate.

Syntax python3 -m venv .venv

python3 -m venv .venv && source .venv/bin/activate

tmux

Keep a terminal session alive after you disconnect. Good for long training or download jobs.

Syntax tmux new -s name

tmux new -s training

Files & Directories

cd

Change the current directory. cd with no argument takes you home; cd - jumps back to the last directory.

Syntax cd [directory]

cd ~/projects

cp

Copy files. Use -r to copy a whole directory.

Syntax cp [-r] source destination

cp -r site/ site-backup/

df

Show free and used disk space for each mounted filesystem.

Syntax df -h

df -h

du

Show how much disk space a file or directory uses.

Syntax du -sh path

du -sh /var/log/*

find

Search for files by name, type, size, or age.

Syntax find path -name pattern

find /var/www -name '*.php'

ln

Create a symbolic link (a shortcut). Nginx uses these to enable a site.

Syntax ln -s target linkname

sudo ln -s /etc/nginx/sites-available/mysite /etc/nginx/sites-enabled/

ls

List the files in a directory. -l shows details, -a shows hidden files, -h makes sizes readable.

Syntax ls [options] [path]

ls -lah /var/log

mkdir

Create a directory. -p also creates any missing parent directories.

Syntax mkdir [-p] directory

mkdir -p site/assets/css

mv

Move or rename a file or directory.

Syntax mv source destination

mv draft.txt final.txt

pwd

Print the full path of the directory you are in.

Syntax pwd

pwd

rm

Delete files. There is no trash can, so check the path before you press Enter. -r deletes directories.

Syntax rm [-r] file

rm -ri old-project/

tar

Bundle and compress files into one archive. Use -xzf to unpack it.

Syntax tar -czf archive.tar.gz directory

tar -czf backup.tar.gz /var/www/siteDB

Networking

curl

Make a web request from the terminal. -I shows only the headers; -s hides the progress bar.

Syntax curl [options] url

curl -I https://example.com

dig

Look up DNS records. Handy for checking that a domain points at your server.

Syntax dig domain

dig +short example.com

ping

Check that another machine answers. Press Ctrl+C to stop.

Syntax ping host

ping -c 4 example.com

rsync

Copy only what changed between two folders, locally or over SSH.

Syntax rsync -av source/ destination/

rsync -av public/ user@203.0.113.10:/var/www/siteDB/public/

scp

Copy files to or from another machine over SSH.

Syntax scp source user@host:path

scp index.html user@203.0.113.10:/tmp/

ss

List the ports your machine is listening on and which programs own them.

Syntax ss -tulpn

sudo ss -tulpn

ssh

Log in to another machine securely over the network.

Syntax ssh user@host

ssh liam@203.0.113.10

ufw

Simple firewall front end. Allow OpenSSH before you enable it, or you can lock yourself out.

Syntax sudo ufw command

sudo ufw allow OpenSSH && sudo ufw enable

Packages & Services

apt

Install, update, and remove software on Ubuntu and Debian.

Syntax sudo apt command

sudo apt update && sudo apt install nginx

journalctl

Read the logs that systemd collects. -f follows new entries.

Syntax journalctl -u service

journalctl -u nginx --since '1 hour ago'

systemctl

Start, stop, restart, or check a service. Use status to see if it is running.

Syntax systemctl action service

sudo systemctl status nginx

Permissions & Users

adduser

Create a new user account with a home directory.

Syntax sudo adduser username

sudo adduser deploy

chmod

Change who can read, write, or run a file. 644 is typical for web files and 755 for scripts and directories.

Syntax chmod mode file

chmod 755 deploy.sh

chown

Change the owner and group of a file. Needed so the web server can read your site.

Syntax chown [-R] user:group path

sudo chown -R deploy:www-data /var/www/siteDB

id

Show a user's ID numbers and the groups they belong to.

Syntax id [user]

id

sudo

Run one command with administrator (root) privileges.

Syntax sudo command

sudo apt update

whoami

Print the name of the user you are logged in as.

Syntax whoami

whoami

Processes & System

free

Show how much memory and swap is used and free.

Syntax free -h

free -h

kill

Send a signal to a process. The default asks it to stop; -9 forces it to stop.

Syntax kill [-signal] PID

kill -9 1234

ps

List running processes. Pipe it to grep to find one.

Syntax ps aux

ps aux | grep nginx

top

Live view of CPU and memory use by process. Press q to quit.

Syntax top

top

uptime

Show how long the machine has been running and its recent load.

Syntax uptime

uptime

Text Processing

awk

Pick out columns from text. $1 is the first column.

Syntax awk '{print $N}' file

awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -nr | head

cat

Print the contents of a file. Also joins several files together.

Syntax cat file

cat /etc/os-release

grep

Search inside files for lines that match a pattern. -r searches folders, -n shows line numbers, -i ignores case.

Syntax grep [options] pattern file

grep -rn 'error' /var/log/nginx/

head

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

Syntax head [-n lines] file

head -n 5 notes.txt

less

Read a long file one screen at a time. Press q to quit and / to search.

Syntax less file

less /var/log/syslog

sed

Find and replace text in a stream or file without opening an editor.

Syntax sed 's/old/new/g' file

sed 's/http:/https:/g' links.txt

sort

Sort lines of text. -n sorts numbers, -r reverses the order.

Syntax sort [-n] [-r] file

sort -nr counts.txt

tail

Show the last lines of a file. -f keeps watching and prints new lines as they arrive.

Syntax tail [-f] [-n lines] file

tail -f /var/log/nginx/access.log

uniq

Remove repeated neighboring lines. -c counts them. Usually used after sort.

Syntax uniq [-c]

sort names.txt | uniq -c

wc

Count lines, words, and bytes. wc -l counts lines.

Syntax wc [-l] file

wc -l /etc/passwd