From d94f4a2ecd290e61cb356ec09bba96a84a606dc3 Mon Sep 17 00:00:00 2001 From: Robin-Charles GUIHENEUF Date: Sat, 21 Nov 2020 10:07:54 +0100 Subject: [PATCH] navi: Add some cheat sheets --- navi/docker-compose.cheat | 12 ++++++++ navi/docker.cheat | 39 +++++++++++++++++++++++++ navi/git.cheat | 60 +++++++++++++++++++++++++++++++++++++++ navi/misc.cheat | 40 ++++++++++++++++++++++++++ navi/mysql.cheat | 10 +++++++ 5 files changed, 161 insertions(+) create mode 100644 navi/docker-compose.cheat create mode 100644 navi/docker.cheat create mode 100644 navi/git.cheat create mode 100644 navi/misc.cheat create mode 100644 navi/mysql.cheat diff --git a/navi/docker-compose.cheat b/navi/docker-compose.cheat new file mode 100644 index 0000000..7839560 --- /dev/null +++ b/navi/docker-compose.cheat @@ -0,0 +1,12 @@ +% docker-compose + +# Builds, (re)creates, starts, and attaches to containers for all services +sudo docker-compose -f up + +# Builds, (re)creates, starts, and dettaches to containers for all services +sudo docker-compose -f up -d + +# Stops containers and removes containers, networks created by up +sudo docker-compose -f down + +$ file: ls *.yaml | awk '{print $1}' diff --git a/navi/docker.cheat b/navi/docker.cheat new file mode 100644 index 0000000..1c16d32 --- /dev/null +++ b/navi/docker.cheat @@ -0,0 +1,39 @@ +% docker-volumes + +# Create a volume +sudo docker volume create + +# List all volumes +sudo docker volume ls + +# Remove volume +sudo docker volume rm + +$ volume: sudo docker volume ls --format "{{.Name}}" | awk '{print $1}' + +% docker-network + +# Create new network +docker network create + +# List the networks +sudo docker network ls + +% docker + +# List the running containers +sudo docker ps + +# Stop a running container through SIGTERM +sudo docker stop + +# Stop a running container through SIGKILL +sudo docker kill + +# Print the last lines of a container's logs +docker logs --tail 100 | less + +# Print the last lines of a container's logs and following its logs +docker logs --tail 100 -f + +$ container_id: sudo docker ps --format "{{.ID}}" | awk '{print $1}' diff --git a/navi/git.cheat b/navi/git.cheat new file mode 100644 index 0000000..c36185c --- /dev/null +++ b/navi/git.cheat @@ -0,0 +1,60 @@ +% git + +# Initializes a git repository +git init + +# Clone a git repository +git clone + +# Rebase upstream master into local/origin master +git fetch +git checkout master +git rebase /master +git fetch origin +git push -f origin master + +# Merge upstream master into local/origin master +git fetch +git checkout master +git merge /master +git fetch origin +git push -f origin master + +# Adds a remote for a git repository +git remote add + +# Renames a remote for a git repository +git remote rename + +# Remove a remote for a git repository +git remote remove + +# Saves the changes to a file in a commit +git commit -m + +# Pushes committed changes to remote repository +git push --set-upstream + +# Displays formatted log of commits for a repo +git log --all --decorate --oneline --graph + +# Clear everything +git clean -dxf + +# Add a new module +git submodule add + +# Update module +git submodule update --init + +# Update module without init +git submodule update + +# Pull all submodules +git submodule foreach git pull origin master + +# Skip git hooks +git commit --no-verify + +# Create new branch from current HEAD +git checkout -b diff --git a/navi/misc.cheat b/navi/misc.cheat new file mode 100644 index 0000000..2fa8d8a --- /dev/null +++ b/navi/misc.cheat @@ -0,0 +1,40 @@ +% misc + +# Update system +sudo apt update && sudo apt upgrade + +# Clean APT +sudo apt autoclean && sudo apt autoremove + +# List users +cat /etc/passwd | awk -F: '{ print $1}' + +# User information +sudo id + +# Change user password +sudo passwd + +# Create user with home +sudo useradd -m + +# Create user without home +sudo useradd + +# Delete an user +sudo deluser + +# List all groups +cat /etc/group + +# Add user to group +sudo usermod -a -G + +# Remove user from a group +sudo deluser + +# Port binding +sudo lsof -i: + +$ user: cat /etc/passwd | awk -F: '{ print $1}' +$ group: cat /etc/group | awk -F: '{ print $1}' diff --git a/navi/mysql.cheat b/navi/mysql.cheat new file mode 100644 index 0000000..bde755d --- /dev/null +++ b/navi/mysql.cheat @@ -0,0 +1,10 @@ +% mysql + +# Create database +mysql -u -p -e "create database character set UTF8mb4 collate utf8mb4_bin" + +# Export databse +mysqldump -u -p -x -A > + +# Import database +mysql -u -p