🐧 Linux Basics

Navigation

pwd  # print working directory
cd   # change directory
ls -l # list files in long format
ls -la # list all files including hidden files
cd .. # go up one directory

Files & Directories

cp
mv
rm -rf
mkdir

Processes

ps aux
top
kill -9

Permissions (ls -l)

ls -la    # long list + hidden (.dot) files

# read the 10-char field:  d rwx r-x r-x
#   1st char = type: - file, d directory, l link
#   then 3 x rwx = owner / group / others
#   r=read  w=write  x=execute  (- = no permission)

-rw-r--r--   # file: owner read/write, others read-only
drwxr-xr-x   # directory
-rwxr-x---   # has x = runnable program
drwx------   # only the owner can access (e.g. .ssh)

πŸ“ Vim

Basic Commands

i          # insert mode
esc        # normal mode
:w         # save
:q         # quit
:wq        # save and quit

Navigation

h j k l    # move left, down, up, right
gg         # go to top
G          # go to bottom

πŸ’» Shell

Basic Commands

echo "Hello, World!"
cat file.txt
grep "pattern" file.txt

Text Processing

cut -d: -f1 /etc/passwd     # column 1 (: = delimiter, f = field)
grep -i "root" file        # -i ignore case, -v invert, -n line numbers
sort file                  # sort lines
sort file | uniq -c        # count duplicates (must sort first!)
sed 's/old/new/g' file     # replace text (g = every match per line)
tr 'a-z' 'A-Z' < file       # translate chars β€” reads stdin only, use <
tr -d '0-9' < file          # delete chars

Pipes & Redirection

cmd1 | cmd2         # pipe: cmd1 output becomes cmd2 input
cmd > file          # save stdout to file (overwrite)
cmd >> file         # append to file
cmd < file          # feed file in as stdin
cmd 2> err.txt      # save stderr (errors) to file
cmd 2> /dev/null    # throw errors away
cmd > out.txt 2>&1  # stdout AND stderr to same file

# stream numbers:  0 = stdin   1 = stdout   2 = stderr

Find & Count

find ~ -name "*.txt"               # search recursively by name
find ~ -maxdepth 1 -name "*.txt"   # top level only (don't go deep)
find ~ -size +1M                   # files bigger than 1 MB
find / -name "*.conf" 2> /dev/null # search all, hide permission errors
find ~ -name "*.txt" | wc -l       # count matches (find + pipe + wc)

wc -l file   # count lines   (-w words, -c bytes)

🐍 Python

Basic Commands

python3 script.py
pip install package
uv venv
source .venv/bin/activate
deactivate

πŸ—‚ SQL

Basic Commands

SELECT * FROM table;
INSERT INTO table (col1, col2) VALUES (val1, val2);
UPDATE table SET col1 = val1 WHERE condition;
DELETE FROM table WHERE condition;

🌱 Git & GitHub

Local Git Basics

git init
git status
git add .
git commit -m "message"
git log --oneline

Branching

git branch
git branch new-branch
git checkout new-branch
git switch -c new-branch
git merge main

Remote Repositories (GitHub)

git remote -v
git remote add origin git@github.com:user/repo.git
git push -u origin main
git pull origin main
git fetch

Undo / Fix

git restore file.txt
git reset HEAD file.txt
git reset --soft HEAD~1
git reset --hard HEAD~1

GitHub Workflow

# clone a repo
git clone git@github.com:user/repo.git

# typical workflow
git pull
git add .
git commit -m "update"
git push

🌐 Networking

Basic Commands

ping
curl
nslookup
traceroute

IP & Interface

ip addr
ifconfig
netstat -tuln

SSH

ssh user@host
scp file user@host:/path
ssh-keygen
ssh-copy-id

Nginx

nginx -t
systemctl restart nginx

🐳 Docker

Basic Commands

docker build -t image_name .
docker run -d -p host_port:container_port image_name
docker ps
docker stop container_id
docker rm container_id
docker rmi image_id

☸️ Kubernetes

Basic Commands

kubectl get pods
kubectl get services
kubectl apply -f deployment.yaml
kubectl delete -f deployment.yaml

☁️ AWS

Basic Commands

aws s3 ls
aws ec2 describe-instances
aws lambda invoke --function-name my-function output.txt
aws cloudformation deploy --template-file template.yaml --stack-name my-stack