Essential CLI Commands

Master the command line with this comprehensive cheat sheet for web developers

Showing 87 commands
gitsetup

git init

Initialize a new Git repository

$ git init
gitsetup

git clone

Clone a repository

$ git clone https://github.com/user/repo.git
gitbasic

git status

Check the status of your repository

$ git status
gitbasic

git add

Stage changes for commit

$ git add . (all files) or git add filename.js
gitbasic

git commit

Commit staged changes

$ git commit -m "Your commit message"
gitbasic

git push

Push commits to remote repository

$ git push origin main
gitbasic

git pull

Pull latest changes from remote

$ git pull origin main
gitbranching

git branch

List, create, or delete branches

$ git branch (list) | git branch feature-name (create) | git branch -d branch-name (delete)
gitbranching

git checkout

Switch branches or restore files

$ git checkout branch-name or git checkout -b new-branch
gitbranching

git merge

Merge branches

$ git merge feature-branch
gitadvanced

git rebase

Reapply commits on top of another base

$ git rebase main
gitinspection

git log

View commit history

$ git log --oneline --graph --all
gitinspection

git diff

Show changes between commits, branches, etc.

$ git diff or git diff branch1..branch2
gitworkflow

git stash

Temporarily save changes

$ git stash (save) | git stash pop (restore)
gitadvanced

git reset

Undo commits or unstage files

$ git reset HEAD~1 (soft) | git reset --hard HEAD~1 (hard)
gitremote

git remote

Manage remote repositories

$ git remote -v (list) | git remote add origin url
npmsetup

npm init

Initialize a new Node.js project

$ npm init or npm init -y (skip prompts)
npmpackages

npm install

Install dependencies

$ npm install (all) | npm install package-name | npm install -D package-name (dev)
npmpackages

npm uninstall

Remove a package

$ npm uninstall package-name
npmpackages

npm update

Update packages

$ npm update or npm update package-name
npmscripts

npm run

Run a script defined in package.json

$ npm run dev | npm run build | npm run test
npminspection

npm list

List installed packages

$ npm list or npm list --depth=0
npmmaintenance

npm outdated

Check for outdated packages

$ npm outdated
npmsecurity

npm audit

Check for security vulnerabilities

$ npm audit | npm audit fix
npmexecution

npx

Execute packages without installing globally

$ npx create-next-app@latest | npx tsc --init
pnpmpackages

pnpm install

Install dependencies (faster than npm)

$ pnpm install or pnpm i
pnpmpackages

pnpm add

Add a package

$ pnpm add package-name | pnpm add -D package-name
pnpmpackages

pnpm remove

Remove a package

$ pnpm remove package-name
pnpmpackages

pnpm update

Update packages

$ pnpm update or pnpm up
pnpmscripts

pnpm run

Run package scripts

$ pnpm dev | pnpm build
yarnsetup

yarn init

Initialize a new project

$ yarn init or yarn init -y
yarnpackages

yarn install

Install dependencies

$ yarn install or yarn
yarnpackages

yarn add

Add a package

$ yarn add package-name | yarn add -D package-name
yarnpackages

yarn remove

Remove a package

$ yarn remove package-name
yarnpackages

yarn upgrade

Upgrade packages

$ yarn upgrade or yarn upgrade package-name
dockerimages

docker build

Build an image from a Dockerfile

$ docker build -t image-name .
dockercontainers

docker run

Run a container from an image

$ docker run -d -p 3000:3000 image-name
dockercontainers

docker ps

List running containers

$ docker ps or docker ps -a (all)
dockercontainers

docker stop

Stop a running container

$ docker stop container-id
dockercontainers

docker rm

Remove a container

$ docker rm container-id
dockerimages

docker images

List Docker images

$ docker images
dockerimages

docker rmi

Remove an image

$ docker rmi image-id
dockercompose

docker-compose up

Start services defined in docker-compose.yml

$ docker-compose up -d
dockercompose

docker-compose down

Stop and remove containers

$ docker-compose down
dockerdebugging

docker logs

View container logs

$ docker logs container-id or docker logs -f container-id
dockerdebugging

docker exec

Execute a command in a running container

$ docker exec -it container-id bash
verceldeployment

vercel

Deploy to Vercel

$ vercel or vercel --prod
verceldevelopment

vercel dev

Run development server with Vercel environment

$ vercel dev
vercelconfiguration

vercel env

Manage environment variables

$ vercel env ls | vercel env add
verceldebugging

vercel logs

View deployment logs

$ vercel logs
terminalnavigation

ls

List directory contents

$ ls or ls -la (detailed)
terminalnavigation

cd

Change directory

$ cd folder-name | cd .. (up one level) | cd ~ (home)
terminalnavigation

pwd

Print working directory

$ pwd
terminalfiles

mkdir

Create a new directory

$ mkdir folder-name
terminalfiles

touch

Create a new file

$ touch filename.js
terminalfiles

rm

Remove files or directories

$ rm file.js | rm -rf folder (recursive)
terminalfiles

cp

Copy files or directories

$ cp source.js dest.js | cp -r folder1 folder2
terminalfiles

mv

Move or rename files

$ mv old.js new.js
terminalviewing

cat

Display file contents

$ cat file.js
terminalsearch

grep

Search for patterns in files

$ grep "search term" file.js | grep -r "term" .
terminalsearch

find

Find files and directories

$ find . -name "*.js"
terminalpermissions

chmod

Change file permissions

$ chmod +x script.sh | chmod 755 file
terminalnetwork

curl

Transfer data from or to a server

$ curl https://api.example.com
nextjssetup

npx create-next-app@latest

Create a new Next.js application

$ npx create-next-app@latest my-app
nextjsdevelopment

npm run dev

Start development server

$ npm run dev
nextjsproduction

npm run build

Build for production

$ npm run build
nextjsproduction

npm run start

Start production server

$ npm run start
vitesetup

npm create vite@latest

Create a new Vite project

$ npm create vite@latest my-app
vitedevelopment

npm run dev

Start development server

$ npm run dev
viteproduction

npm run build

Build for production

$ npm run build
viteproduction

npm run preview

Preview production build

$ npm run preview
typescriptsetup

tsc --init

Initialize TypeScript configuration

$ npx tsc --init
typescriptcompilation

tsc

Compile TypeScript files

$ npx tsc or npx tsc --watch
typescripttype-checking

tsc --noEmit

Type-check without emitting files

$ npx tsc --noEmit
prismasetup

npx prisma init

Initialize Prisma in your project

$ npx prisma init
prismamigrations

npx prisma migrate dev

Create and apply migrations

$ npx prisma migrate dev --name init
prismaclient

npx prisma generate

Generate Prisma Client

$ npx prisma generate
prismatools

npx prisma studio

Open Prisma Studio (database GUI)

$ npx prisma studio
prismadatabase

npx prisma db push

Push schema changes to database

$ npx prisma db push
prismadatabase

npx prisma db seed

Seed your database

$ npx prisma db seed
eslintsetup

npx eslint --init

Initialize ESLint configuration

$ npx eslint --init
eslintlinting

npx eslint .

Lint all files

$ npx eslint . or npx eslint src/
eslintlinting

npx eslint --fix

Fix auto-fixable issues

$ npx eslint . --fix
playwrighttesting

npx playwright test

Run Playwright tests

$ npx playwright test
playwrighttesting

npx playwright test --ui

Run tests in UI mode

$ npx playwright test --ui
playwrightgeneration

npx playwright codegen

Generate test code by recording

$ npx playwright codegen https://example.com
playwrightreporting

npx playwright show-report

Show test report

$ npx playwright show-report