Command reference
What a command does, what it is made of and where it can bite. With examples from the tracks and one-click practice.
Bash
- pwd — Show which folder you are in
- ls — List files and folders
- cd — Go to another folder
- mkdir — Create a folder
- touch — Create an empty file or update its modification date
- cp — Copy a file or a folder
- mv — Move or rename a file
- rm — Delete files and folders
- cat — Print a file to the terminal
- head — Show the first lines of a file
- tail — Show the last lines of a file, or follow it
- less — Read a big file page by page
- wc — Count lines, words and bytes
- grep — Find the lines with some text in files
- find — Find files and folders by name, type and more
- which — Find out where a program lives
- > >> 2> — Output redirection. Write a command's output to a file instead of the screen
- | — The pipe. Pass the output of one command to the input of another
- sort — Sort lines and drop duplicates
- echo — Print text or the value of a variable
- export — Set an environment variable for the programs you run
- env — List environment variables
- source — Run the commands from a file in the current shell
Git
- git config — Set up git: the author name and email, the editor and other settings
- git init — Create a new repository in the current folder
- git clone — Download a repository from a server with its whole history
- git status — See what changed in the folder and what is already staged
- git add — Stage changes so they go into the next commit
- git commit — Save the staged changes to history as a new commit
- git diff — See exactly what changed in your files, line by line
- git branch — List, create, rename or delete branches
- git switch — Switch to another branch, or create a new one and switch to it
- git merge — Bring the changes from another branch into the current one
- git log — Show the commit history
- git show — Show one commit: its message, author and every change in it
- git blame — Find out who last changed each line of a file, and in which commit
- git restore — Discard edits in a file or unstage it
- git reset — Move the branch to another commit, for example to undo the last commits
- git revert — Undo a commit with a new commit, without rewriting history
- git remote — List and add remote repositories
- git fetch — Download new commits from the server without touching your branches
- git pull — Download changes from the server and merge them into the current branch
- git push — Send your commits to the server
- git stash — Put uncommitted edits aside for a while and bring them back later
- git rebase — Move a branch's commits onto a new base, or rewrite the last commits