CommandDescription
git initInitialize a new Git repository
git clone <url>Clone a remote repository
git statusShow working tree status
git add .Stage all changes
git add <file>Stage a specific file
git commit -m "msg"Commit staged changes with message
git pushPush commits to remote
git push -u origin <branch>Push and set upstream for a new branch
git pullFetch and merge from remote
git fetchDownload objects from remote without merging
git branchList local branches
git branch <name>Create a new branch
git checkout <branch>Switch to a branch
git checkout -b <branch>Create and switch to a new branch
git merge <branch>Merge a branch into current branch
git rebase <branch>Rebase current branch onto another
git stashStash uncommitted changes
git stash popApply and remove last stash
git log --onelineShow compact commit history
git log --graphShow commit history as a graph
git diffShow unstaged changes
git diff --stagedShow staged changes
git reset HEAD <file>Unstage a file
git reset --soft HEAD~1Undo last commit, keep changes staged
git reset --hard HEAD~1Undo last commit and discard changes
git revert <commit>Create a new commit that undoes a previous commit
git cherry-pick <commit>Apply a specific commit to current branch
git tag <name>Create a lightweight tag
git remote -vList remote repositories
git config --global user.name "Name"Set global Git username
git clean -fdRemove untracked files and directories
git bisect startStart binary search for a bad commit
git blame <file>Show who changed each line
git show <commit>Show details of a specific commit
git reflogShow history of HEAD movements
CommandDescription
ls -laList all files with details
cd <dir>Change directory
pwdPrint current working directory
cp -r <src> <dst>Copy files/directories recursively
mv <src> <dst>Move or rename files
rm -rf <path>Remove files/dirs recursively (use with caution)
mkdir -p <dir>Create directory and parent directories
touch <file>Create empty file or update timestamp
cat <file>Print file contents
head -n 20 <file>Show first 20 lines of a file
tail -f <file>Follow file output in real time
grep -r "pattern" .Search recursively for a pattern
find . -name "*.txt"Find files by name pattern
chmod 755 <file>Change file permissions
chown user:group <file>Change file owner and group
ps auxList all running processes
kill -9 <pid>Force kill a process by PID
topReal-time process monitor
df -hShow disk usage in human-readable format
du -sh <dir>Show directory size
tar -czf archive.tar.gz <dir>Create compressed tar archive
tar -xzf archive.tar.gzExtract tar.gz archive
ssh user@hostConnect to remote server via SSH
scp file user@host:/pathCopy file to remote server
curl -X GET <url>Make HTTP request
wget <url>Download file from URL
echo $PATHPrint environment variable
export VAR=valueSet environment variable
which <cmd>Show full path of a command
wc -l <file>Count lines in a file
sort <file> | uniqSort and remove duplicates
awk '{print $1}' <file>Print first column of each line
sed 's/old/new/g' <file>Find and replace text in file
history | grep <cmd>Search command history
xargsBuild and execute commands from stdin
CommandDescription
docker build -t name .Build image from Dockerfile in current dir
docker run -d -p 80:80 nameRun container in detached mode with port mapping
docker run -it name /bin/bashRun container interactively with shell
docker psList running containers
docker ps -aList all containers including stopped
docker stop <id>Stop a running container
docker start <id>Start a stopped container
docker rm <id>Remove a stopped container
docker rmi <image>Remove an image
docker imagesList all local images
docker pull <image>Pull image from registry
docker push <image>Push image to registry
docker exec -it <id> bashExecute shell in running container
docker logs -f <id>Follow container logs
docker inspect <id>Show detailed container/image info
docker cp <id>:/path ./localCopy files from container to host
docker volume lsList volumes
docker volume create <name>Create a named volume
docker network lsList networks
docker network create <name>Create a custom network
docker compose up -dStart services in detached mode
docker compose downStop and remove services
docker compose buildBuild or rebuild services
docker compose logs -fFollow logs for all services
docker system prune -aRemove all unused images, containers, networks
docker tag <img> <repo:tag>Tag an image for a registry
docker loginLog in to a Docker registry
SyntaxDescription
SELECT col FROM tableSelect specific columns from a table
SELECT DISTINCT col FROM tableSelect unique values only
WHERE col = 'value'Filter rows by condition
WHERE col LIKE '%pattern%'Pattern matching with wildcards
WHERE col IN (1, 2, 3)Match against a set of values
WHERE col BETWEEN 10 AND 20Filter within a range (inclusive)
WHERE col IS NULLCheck for NULL values
INNER JOIN t2 ON t1.id = t2.idReturn matching rows from both tables
LEFT JOIN t2 ON t1.id = t2.idAll rows from left + matching from right
RIGHT JOIN t2 ON t1.id = t2.idAll rows from right + matching from left
FULL OUTER JOIN t2 ON t1.id = t2.idAll rows from both tables
GROUP BY colGroup rows by column value
HAVING COUNT(*) > 1Filter groups (used after GROUP BY)
ORDER BY col ASC/DESCSort results ascending or descending
LIMIT 10 OFFSET 20Limit rows returned, skip first 20
COUNT(*), SUM(col), AVG(col)Aggregate functions
MIN(col), MAX(col)Get minimum/maximum value
INSERT INTO t (c1,c2) VALUES (v1,v2)Insert a new row
UPDATE t SET col='val' WHERE id=1Update existing rows
DELETE FROM t WHERE id=1Delete specific rows
CREATE TABLE t (id INT PRIMARY KEY, ...)Create a new table
ALTER TABLE t ADD col TYPEAdd a column to existing table
DROP TABLE tDelete a table permanently
CREATE INDEX idx ON t(col)Create index for faster queries
SELECT * FROM (SELECT ...) AS subSubquery as derived table
UNION / UNION ALLCombine results from multiple queries
CASE WHEN cond THEN x ELSE y ENDConditional logic in queries
BEGIN; ... COMMIT;Transaction block
2xx — Success
200
OK
Request succeeded
201
Created
Resource created successfully
204
No Content
Success with no response body
3xx — Redirection
301
Moved Permanently
Resource has a new permanent URL
302
Found
Temporary redirect to another URL
304
Not Modified
Cached version is still valid
4xx — Client Errors
400
Bad Request
Server couldn't understand the request
401
Unauthorized
Authentication required
403
Forbidden
Server refuses to authorize the request
404
Not Found
Requested resource doesn't exist
405
Method Not Allowed
HTTP method not supported for this URL
409
Conflict
Request conflicts with current state
410
Gone
Resource permanently removed
422
Unprocessable Entity
Valid request but semantic errors
429
Too Many Requests
Rate limit exceeded
5xx — Server Errors
500
Internal Server Error
Unexpected server error
502
Bad Gateway
Invalid response from upstream server
503
Service Unavailable
Server temporarily overloaded or down
504
Gateway Timeout
Upstream server didn't respond in time
Special Characters & Quantifiers
PatternMeaning
.Any character except newline
^Start of string / line
$End of string / line
*0 or more of preceding element
+1 or more of preceding element
?0 or 1 of preceding element (optional)
{n}Exactly n occurrences
{n,m}Between n and m occurrences
[abc]Any one of a, b, or c
[^abc]Any character NOT a, b, or c
[a-z]Any lowercase letter
(abc)Capturing group
(?:abc)Non-capturing group
a|bMatch a or b
\dDigit [0-9]
\DNon-digit
\wWord character [a-zA-Z0-9_]
\WNon-word character
\sWhitespace (space, tab, newline)
\SNon-whitespace
\bWord boundary
(?=...)Positive lookahead
(?!...)Negative lookahead
Common Patterns
PatternMatches
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$Email address
https?:\/\/(www\.)?[\w-]+\.[\w./-]+URL (http/https)
^\+?[\d\s()-]{7,15}$Phone number (international)
^\d{4}-\d{2}-\d{2}$Date (YYYY-MM-DD)
^(\d{1,3}\.){3}\d{1,3}$IPv4 address (basic)
^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$Hex color code
^[a-zA-Z0-9]+$Alphanumeric string only
^(?=.*[A-Z])(?=.*[a-z])(?=.*\d).{8,}$Strong password (8+ chars, upper, lower, digit)
^\d+(\.\d{1,2})?$Decimal number (up to 2 places)
^[a-z0-9-]+$URL slug (lowercase, digits, hyphens)