Linux

Adding a user

Just the user

User with homedir

SED

RegEx on stdout

L-o-rem ipsum d-o-l-o-r sit amet, c-o-nsetetur sadipscing elitr, sed diam

RegEx in file

cat file L-o-rem ipsum d-o-l-o-r sit amet, c-o-nsetetur sadipscing elitr, sed diam

AWK

Order data

Field2 Field1 Field4 Field3 Field6 Field5

Custom field seperator

Field2 Field1 Field4 Field3 Field6 Field5

Adding inject variables

vimdiesel.de column1: Field1

Add a Header and footer

Header Field1 Footer

Archive files

Create archive (tar gzip)

ls file file.tar.gz

Extract whole archive (tar gzip)

ls file file.tar.gz

Extract single file from archive (tar gzip)

ls file3 files.tar.gz

Show archive content (tar gzip)

file

Extend disk

Get disks

Extend partition

Resize filesystem

Extend disk LVM

Get newly added disk

Add make new pv from disk

Extend Volume Group

Extrend logical volume

Resize Filesystem

Disk space

Normal

Filesystem 1K-blocks Used Available Use% Mounted on overlay 1055762868 9754812 992304584 1% / tmpfs 65536 0 65536 0% /dev tmpfs 8166136 0 8166136 0% /sys/fs/cgroup shm 65536 0 65536 0% /dev/shm /dev/sde 1055762868 9754812 992304584 1% /etc/hosts tmpfs 8166136 0 8166136 0% /proc/acpi tmpfs 8166136 0 8166136 0% /sys/firmware

Human-readable flag

Kilo Mega and Gigabyte instead of bytes

Inode flag

Inodes instead of space

Show largest files/folders

135M . 111M ./usr 56M ./usr/share 39M ./usr/lib 36M ./usr/lib/x86_64-linux-gnu

VMs & Containers

Docker

Start a container

75470e66ae05235b1724f99d2eba4d453d0d94b59d3661dfb0f47e216da95a25 docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 75470e66ae05 mysql:latest "docker-entrypoint.s…" 3 seconds ago Up 2 seconds 3306/tcp, 33060/tcp beautiful_joliot9

Get shell into a container

bash-4.4#

Dockerfile

=> [internal] load build definition from Dockerfile => => transferring dockerfile: 127B => [internal] load .dockerignore => => transferring context: 2B => [internal] load metadata for docker.io/library/debian:latest => [1/4] FROM docker.io/library/debian:latest => [internal] load build context => => transferring context: 907B => [2/4] WORKDIR /work => [3/4] COPY . /work => [4/4] RUN /bin/bash => exporting to image => => exporting layers => => writing image sha256:02e19f5bec3cec137c85e7364e4cc1174b3020cd48e7ce5fa78a57e223269241 docker run -it --rm 02e19f5bec3c bash root@939c94556f02:/work# ls Dockerfile config_file output

Kubernetes

Start a pod

Podman

Start a pod

Vim

Closing

With saving in command mode

Safe and quit the file with either command

Without saving in command mode

Quit without saving the file with either command

Changing the color scheme

Command :colorscheme

Show line numbers

Relative line numbers

Absolut line numbers

Run commands

Run a command

Hi Press ENTER or type command to continue

Command output to file

Command output

Bash

Loops

Item in list

This is item1 This is item2 This is item3 This is item4

Conditional commands

AND

OR

IF

I am the dirty Dan

IF conditions

Variables

Declare

Options

General shell behavior

Glob behavior

Redirection

Standard out to file (overwrite)

cat file Hey I am content

Standard out to file (append)

cat file Hey I am content Hey I am new content

Advanced to file (overwrite)

cat config_file # My config ip=10.1.1.1/32

Advanced to file (append)

cat config_file # My config ip=10.1.1.1/32 # Appended config port=9001

Advanced to file and also escape variables (append)

cat config_file # My config ip=10.1.1.1/32 # Appended escaped config file="example" directory=$MY_VARIABLE

SQL

MySQL

Get tables from database

+---------------------+ | Tables_in_altislife | +---------------------+ | containers | | gangs | | houses | | players | | vehicles | | wanted | +---------------------+ 6 rows in set (0.000 sec)

Generate sha password

+------------------------------------------+ | sha("password") | +------------------------------------------+ | 5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8 | +------------------------------------------+

Create a User

Query OK, 0 rows affected (0.01 sec)

Create Database

Query OK, 1 row affected (0.00 sec)

Grant permission on database to user

Query OK, 0 row affected (0.00 sec) Query OK, 0 row affected (0.00 sec)

Python

Dictionary

With initialized values

Screen

Create new session

Just create a session

Create with name

Create an run command

tmux

tmux sessions

Just create session

Create session with name

List sessions

0: 1 windows (created Sun May 28 15:57:15 2023) session1: 1 windows (created Sun May 28 15:57:46 2023)

Attach to session

Detach from session

Delete session

Tools

Git

Clone a repository

Add changes/files

Commit changes

Pull changes

Push changes

Show branches

Create branches

Delete branches

Switch to branch/commit/label

Initialize repository

Git ignore file

Remove local untracked files

Reset to previous state