From 1ffd517d8840f6806429568b0374a7904254f699 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 | 10 +++++++ navi/docker.cheat | 60 +++++++++++++++++++++++++++++++++++++++ navi/git.cheat | 60 +++++++++++++++++++++++++++++++++++++++ navi/misc.cheat | 34 ++++++++++++++++++++++ navi/mysql.cheat | 10 +++++++ 5 files changed, 174 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..5289e5d --- /dev/null +++ b/navi/docker-compose.cheat @@ -0,0 +1,10 @@ +% docker-compose + +# Builds, (re)creates, starts, and attaches to containers for all services +sudo docker-compose up + +# Builds, (re)creates, starts, and dettaches to containers for all services +sudo docker-compose up -d + +# Stops containers and removes containers, networks created by up +sudo docker-compose down diff --git a/navi/docker.cheat b/navi/docker.cheat new file mode 100644 index 0000000..fb63be9 --- /dev/null +++ b/navi/docker.cheat @@ -0,0 +1,60 @@ +% docker + +# Remove an image +docker image rm + +# Remove an image from the local image store +docker rmi + +# Remove all images from the local image store +docker rmi $(docker images -q) --force + +# Remove all containers +docker rm $(docker ps -aq) + +# Stop all containers +docker stop $(docker ps -aq) + +# List all images that are locally stored with the Docker engine +docker images + +# Build an image from the Dockerfile in the current directory and tag the image +docker build -t : . + +# Pull an image from a registry +docker pull : + +# Stop a running container through SIGTERM +docker stop + +# Stop a running container through SIGKILL +docker kill + +# List the networks +docker network ls + +# List the running containers +docker ps + +# Delete all running and stopped containers +docker rm -f "$(docker ps -aq)" + +# Create a new bash process inside the container and connect it to the terminal +docker exec -it bash + +# 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 + +# Create new network +docker network create + +$ image_id: docker images --- --headers 1 --column 3 --delimiter '\s\s+' +$ container_id: docker ps --- --headers 1 --column 1 --delimiter '\s\s+' + +% docker, boot + +# Prevent all containers from autostarting on boot +docker update --restart=no $(docker ps -a -q) 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..0cffe75 --- /dev/null +++ b/navi/misc.cheat @@ -0,0 +1,34 @@ +% misc + +# 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..db9ea51 --- /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 > + +# Import database +mysql -u -p