https://github.com/flameshine/cheatsheet
A kit of useful commands/scripts for UNIX-like systems and various concomitant tools.
https://github.com/flameshine/cheatsheet
Last synced: 8 months ago
JSON representation
A kit of useful commands/scripts for UNIX-like systems and various concomitant tools.
- Host: GitHub
- URL: https://github.com/flameshine/cheatsheet
- Owner: flameshine
- Created: 2022-08-10T16:31:18.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-04T15:50:53.000Z (8 months ago)
- Last Synced: 2025-03-04T16:41:15.676Z (8 months ago)
- Homepage:
- Size: 153 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Cheatsheet
Table of contents
* [Utilities](#Utilities)
* [Unix](#Unix)
* [Helm](#Helm)
* [Lerna](#Lerna)
* [Kubernetes](#Kubernetes)
* [Docker](#Docker)
* [AWS](#AWS)
* [CDK](#CDK)
* [ECR](#ECR)
* [EKS](#EKS)
* [S3](#S3)
* [Secrets](#Secrets)
* [Redis](#Redis)
* [argo-workflows](#argo-workflows)
* [Git](#Git)
* [SVN](#SVN)
* [git-crypt](#git-crypt)
* [Gradle](#Gradle)
* [Maven](#Maven)
* [Python](#Python)
* [pyenv](#pyenv)
* [pip](#pip)
Utilities
UML diagram builder: https://app.diagrams.net
AWS policy generator: https://awspolicygen.s3.amazonaws.com/policygen.html
AWS pricing calculator: https://calculator.aws
Unicode converter: https://www.branah.com/unicode-converter
JSON converter: https://jsontostring.com
Difference checker: https://www.diffchecker.com
Character remover: https://onlinecaseconvert.com/remove-characters-from-text-online.php
Case converter: https://convertcase.net
Epoch time converter: https://www.epochconverter.com
Random number generator: https://www.random.org
TypeScript playground: https://www.typescriptlang.org/play
RegEx shaper: https://regexr.com
Character counter: https://charactercalculator.com
Unix
Grant read/write/execute permissions to a file:
```
sudo chmod 775
```
Change group permission of a file:
```
sudo chown :contractors
```
Kill a process on particular port:
```
sudo kill -9 $(lsof -t -i:)
```
Check what is running on the port:
```
netstat -tulpn | grep
```
Get SSL certificate data:
```
openssl crl2pkcs7 -nocrl -certfile | openssl pkcs7 -print_certs -noout
```
Grep all '.gz' files in directory:
```
find . -name \*.gz -print0 | xargs -0 zgrep ""
```
Generate a random string:
```
LC_ALL=C < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c32; echo
```
Encode a string with Base64:
```
openssl base64 -e <<< ""
```
Decode a string with Base64:
```
openssl base64 -d <<< ""
```
Get your IP address:
```
ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}'
```
Inspect HTTP requests to a particular port:
```
nc -l
```
Grab nth line of console output:
```
sed -n 2p
```
Find file and replace all occurrences of a string inside:
```
find . -name "" -print0 | xargs -0 sed -i "" 's///g'
```
Check if the SSH connection is authorized:
```
ssh -p 7999 -v
```
Generate timestamp:
```
date +%s
```
Helm
Update dependencies:
```
helm dependency update
```
Build dependencies:
```
helm dependency build
```
Generate template:
```
helm template -f > ~/template.yaml
```
Lerna
Clean:
```
npx lerna clean
```
Build:
```
npx lerna run build
```
Kubernetes
Connect to the cluster:
```
kcon
```
Connect to a certain namespace of the cluster:
```
kcon
```
List contexts:
```
kc config get-contexts
```
List resource types:
```
kc get
```
Get a specific resource type:
```
kc get
```
List namespace events:
```
kc -n get events
```
Delete a resource type:
```
kc delete
```
Describe a resource type:
```
kc describe
```
Apply a manifest:
```
kc apply -f
```
Enter a specific pod:
```
kc exec --stdin --tty -- /bin/bash
```
Execute a command inside a pod:
```
kc -n exec
```
Create an ordinary job from a cronjob (server & client Kubernetes versions should be the same):
```
kc create job --from=cronjob/
```
Check pod's logs:
```
kc logs
```
Get resource YAML definition:
```
kc get -o yaml
```
Forward pod's requests to a local port:
```
kc -n port-forward 8080:80
```
View the exact yaml of some Kubernetes component:
```
kc get -o yaml | less
```
Apply the corresponding action to each listed pod:
```
kc -n get pods | awk '{print $1}' | grep "" | xargs kubectl -n pod
```
Scale the deployment:
```
kc -n scale deployment/ --replicas=
```
Docker
Remove all stopped containers, networks not used by at least one container, all images without at least one container and all build cache:
```
docker system prune -a
```
List all images:
```
docker images
```
Remove an image:
```
docker image rm
```
List all containers:
```
docker ps -a
```
Remove a container:
```
docker container rm
```
Build an image:
```
docker build (-t )
```
Push an image:
```
docker push
```
Remove the last container:
```
docker ps -a | awk '{print $1}' | sed -n 2p | xargs docker rm
```
AWS
CDK
Synthetize CDK changes:
```
cdk synth
```
Deploy CDK changes:
```
cdk deploy
```
Destroy CDK changes:
```
cdk destroy
```
List stacks:
```
cdk list
```
ECR
Login into ECR:
```
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin
```
EKS
Update EKS cluster config:
```
aws eks update-kubeconfig --profile --region --name
```
S3
Get total number of objects in a bucket:
```
aws s3 ls s3:// --recursive --summarize | grep "Total Objects:"
```
Secrets
Delete a secret immediately:
```
aws secretsmanager delete-secret --secret-id --force-delete-without-recovery
```
List secrets:
```
aws secretsmanager list-secrets
```
Redis
Connect to the cluster:
```
redis6-cli -c -h -p
```
Get N items matching a pattern:
```
scan 0 match count
```
Get random key:
```
randomkey
```
Flush all data:
```
flushall
```
argo-workflows
Submit a template:
```
argo -n template create
```
Submit a workflow:
```
argo -n submit
```
Delete a template:
```
argo -n template delete template
```
Delete a workflow:
```
argo -n delete workflow
```
Git
Remove all unpushed commits:
```
git reset --hard origin
```
Reword last commit message:
```
git commit --amend -m ""
```
Squash all commits on a branch:
```
git checkout
git reset $(git merge-base master $(git branch --show-current))
git add -A
git commit -m
git push --force
```
Move unpushed commit from one branch to another:
```
git reset HEAD~1
git stash
git checkout
git stash pop
```
Make a certain branch same as master:
```
git reset --hard master
```
Revert particular file:
```
git checkout HEAD^
```
Cherry-pick commit from another repository:
```
git remote add other
git fetch other
git cherry-pick
git remote remove other
```
Squash certain commit:
```
git rebase -i master
pick -> squash (for the commits you're interested in)
```
Split a certain commit:
```
git rebase -i
pick -> edit (for the commits you're interested in)
git reset HEAD~
git rebase --continue
```
SVN
Revert all changes:
```
svn revert -R .
```
Get latest revision before the new branch was created:
```
svn log --stop-on-copy --verbose --limit 1 -r0:HEAD
```
Define a format a file:
```
svn propset svn:mime-type
```
git-crypt
Instructions: https://github.com/AGWA/git-crypt/tree/master
Lock repository:
```
git-crypt lock
```
Unlock repository:
```
git-crypt unlock
```
Gradle
Clean:
```
./gradlew clean
```
Build:
```
./gradlew build
```
Build refreshing dependencies:
```
./gradlew build --refresh-dependencies
```
Maven
Clean:
```
mvn clean
```
Build the project:
```
mvn install
```
Build, but faster:
```
mvn clean install -DskipTests -T4
```
Compile:
```
mvn compile
```
Clean, build and refresh all dependencies:
```
mvn clean install -U
```
Display dependency tree:
```
mvn dependency:tree
```
Python
pyenv
List available for installation versions:
```
pyenv install --list
```
Install a version:
```
pyenv install
```
Create a virtual environment:
```
pyenv virtualenv
```
List virtual environments:
```
pyenv virtualenvs
```
Activate an environment:
```
pyenv activate
```
Deactivate an environment:
```
pyenv deactivate
```
Uninstall an environment:
```
pyenv uninstall
```
pip
Install a module:
```
pip install
```