navi: Add some cheat sheets

This commit is contained in:
Robin-Charles Guihéneuf 2020-11-21 10:07:54 +01:00 committed by Robin-Charles GUIHENEUF
parent f9ceefc1dd
commit cd7dcf47fd
5 changed files with 161 additions and 0 deletions

12
navi/docker-compose.cheat Normal file
View File

@ -0,0 +1,12 @@
% docker-compose
# Builds, (re)creates, starts, and attaches to containers for all services
sudo docker-compose -f <file> up
# Builds, (re)creates, starts, and dettaches to containers for all services
sudo docker-compose -f <file> up -d
# Stops containers and removes containers, networks created by up
sudo docker-compose -f <file> down
$ file: ls *.yaml | awk '{print $1}'

39
navi/docker.cheat Normal file
View File

@ -0,0 +1,39 @@
% docker-volumes
# Create a volume
sudo docker volume create <name>
# List all volumes
sudo docker volume ls
# Remove volume
sudo docker volume rm <volume>
$ volume: sudo docker volume ls --format "{{.Name}}" | awk '{print $1}'
% docker-network
# Create new network
docker network create <name>
# List the networks
sudo docker network ls
% docker
# List the running containers
sudo docker ps
# Stop a running container through SIGTERM
sudo docker stop <container_id>
# Stop a running container through SIGKILL
sudo docker kill <container_id>
# Print the last lines of a container's logs
docker logs --tail 100 <container_id> | less
# Print the last lines of a container's logs and following its logs
docker logs --tail 100 <container_id> -f
$ container_id: sudo docker ps --format "{{.ID}}" | awk '{print $1}'

60
navi/git.cheat Normal file
View File

@ -0,0 +1,60 @@
% git
# Initializes a git repository
git init
# Clone a git repository
git clone <repository> <clone_directory>
# Rebase upstream master into local/origin master
git fetch <remote_name>
git checkout master
git rebase <remote_name>/master
git fetch origin
git push -f origin master
# Merge upstream master into local/origin master
git fetch <remote_name>
git checkout master
git merge <remote_name>/master
git fetch origin
git push -f origin master
# Adds a remote for a git repository
git remote add <remote_name> <remote_url>
# Renames a remote for a git repository
git remote rename <old_remote_name> <new_remote_name>
# Remove a remote for a git repository
git remote remove <remote_name>
# Saves the changes to a file in a commit
git commit -m <message>
# Pushes committed changes to remote repository
git push --set-upstream <remote_name> <branch_name>
# 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 <repository> <path>
# 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 <new_branch_name>

40
navi/misc.cheat Normal file
View File

@ -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 <user>
# Change user password
sudo passwd <user>
# Create user with home
sudo useradd -m <username>
# Create user without home
sudo useradd <username>
# Delete an user
sudo deluser <user>
# List all groups
cat /etc/group
# Add user to group
sudo usermod -a -G <group> <user>
# Remove user from a group
sudo deluser <user> <group>
# Port binding
sudo lsof -i:<port>
$ user: cat /etc/passwd | awk -F: '{ print $1}'
$ group: cat /etc/group | awk -F: '{ print $1}'

10
navi/mysql.cheat Normal file
View File

@ -0,0 +1,10 @@
% mysql
# Create database
mysql -u <user> -p -e "create database <database> character set UTF8mb4 collate utf8mb4_bin"
# Export databse
mysqldump -u <user> -p -x -A <database> > <file>
# Import database
mysql -u <user> -p <database> <path>