Initial
This commit is contained in:
6
.editorconfig
Normal file
6
.editorconfig
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
[*]
|
||||||
|
end_of_line = lf
|
||||||
|
indent_style = tab
|
||||||
|
tab_width = 4
|
23
.gitignore
vendored
Normal file
23
.gitignore
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
**/*_
|
||||||
|
**/.#*
|
||||||
|
**/0*
|
||||||
|
**/1*
|
||||||
|
**/2*
|
||||||
|
**/3*
|
||||||
|
**/4*
|
||||||
|
**/5*
|
||||||
|
**/6*
|
||||||
|
**/7*
|
||||||
|
**/8*
|
||||||
|
**/9*
|
||||||
|
|
||||||
|
**/*.log*
|
||||||
|
**/*log
|
||||||
|
**/LOG*
|
||||||
|
|
||||||
|
cache/**
|
||||||
|
data/**
|
||||||
|
old/**
|
||||||
|
outer/**
|
||||||
|
secret/**
|
14
README.MD
Normal file
14
README.MD
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
|
||||||
|
| A | B |
|
||||||
|
|-----------------------------------------|-----------------------------------------|
|
||||||
|
| | [Linux](docs/linux/common.md) |
|
||||||
|
| | [MariaDB](docs/progs/mariadb.md) |
|
||||||
|
| | [MC](docs/progs/mc.md) |
|
||||||
|
| | [Socat](docs/progs/socat.md) |
|
||||||
|
| [Math](docs/math.md) | [Crontab](docs/progs/crontab.md) |
|
||||||
|
| | [Kubernetes](docs/progs/kubernetes.md) |
|
||||||
|
| | [NMCli](docs/progs/nmcli.md) |
|
||||||
|
| [Math](docs/math.md) | [SSH](docs/progs/ssh.md) |
|
||||||
|
| | [GIT](docs/progs/git.md) |
|
||||||
|
| | [PHP](docs/progs/php.md) |
|
54
docs/linux/common.md
Normal file
54
docs/linux/common.md
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
|
||||||
|
[File systems](filesystems.md)
|
||||||
|
|
||||||
|
[Fedora / CentOS](fedora.md)
|
||||||
|
|
||||||
|
[SELinux](selinux.md)
|
||||||
|
|
||||||
|
# Common
|
||||||
|
|
||||||
|
## find
|
||||||
|
```
|
||||||
|
find /var -maxdepth 2 -type d -printf "%TY-%Tm-%Td %TH:%TM:%TS %Tz %p\n"
|
||||||
|
```
|
||||||
|
|
||||||
|
## bash
|
||||||
|
```
|
||||||
|
# cat > /etc/profile.d/cmp.sh
|
||||||
|
|
||||||
|
export EDITOR=mcedit
|
||||||
|
export HISTFILESIZE=10485760
|
||||||
|
export HISTSIZE=500000
|
||||||
|
export HISTCONTROL=ignoreboth:erasedups
|
||||||
|
export HISTIGNORE="history:reboot:poweroff:cd:ls:pwd:mc:ps:m:e:l"
|
||||||
|
export SSH_ASKPASS=
|
||||||
|
|
||||||
|
alias ffi='ffmpeg -hide_banner -i'
|
||||||
|
|
||||||
|
alias m='cd /mnt'
|
||||||
|
alias e='cd /etc'
|
||||||
|
alias l='cd /var/log'
|
||||||
|
|
||||||
|
tabs -4
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## reboot
|
||||||
|
```bash
|
||||||
|
echo 1 > /proc/sys/kernel/sysrq
|
||||||
|
echo b > /proc/sysrq-trigger
|
||||||
|
```
|
||||||
|
|
||||||
|
## Motherboard name
|
||||||
|
```bash
|
||||||
|
cat /sys/devices/virtual/dmi/id/board_name
|
||||||
|
```
|
||||||
|
|
||||||
|
## grab video from screen
|
||||||
|
```bash
|
||||||
|
ffmpeg -s 1920x1080 -framerate 10 -f x11grab -i :0 -qscale 6 out.mkv
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ps --ppid 2 -p 2 --deselect
|
||||||
|
```
|
13
docs/linux/fedora.md
Normal file
13
docs/linux/fedora.md
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Fedora / CentOS / Etc
|
||||||
|
|
||||||
|
## Relabel
|
||||||
|
```bash
|
||||||
|
touch /.autorelabel
|
||||||
|
```
|
||||||
|
|
||||||
|
## Install PHP 8
|
||||||
|
```
|
||||||
|
dnf install https://rpms.remirepo.net/fedora/remi-release-38.rpm
|
||||||
|
dnf module reset php
|
||||||
|
dnf module install php:remi-8.2
|
||||||
|
```
|
41
docs/linux/filesystems.md
Normal file
41
docs/linux/filesystems.md
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
|
||||||
|
# LVM
|
||||||
|
#### Extend
|
||||||
|
```bash
|
||||||
|
lvextend -L+1G /dev/vg4/homevol
|
||||||
|
```
|
||||||
|
|
||||||
|
# Btrfs
|
||||||
|
#### Resize
|
||||||
|
```bash
|
||||||
|
btrfs filesystem resize max /mnt/dmp/
|
||||||
|
```
|
||||||
|
#### Defragment / compress
|
||||||
|
```bash
|
||||||
|
btrfs filesystem defragment -v -clzo /boot/*
|
||||||
|
```
|
||||||
|
#### Set RO / RW
|
||||||
|
```bash
|
||||||
|
btrfs property set -f . ro false
|
||||||
|
btrfs property set -f . ro true
|
||||||
|
```
|
||||||
|
#### Create shapshot
|
||||||
|
```bash
|
||||||
|
btrfs subvolume snapshot xyz xyz-snapshot-path-name
|
||||||
|
```
|
||||||
|
#### Delete shapshot
|
||||||
|
```bash
|
||||||
|
btrfs subvolume delete xyz-snapshot-path-name
|
||||||
|
```
|
||||||
|
|
||||||
|
# Ext4
|
||||||
|
#### Resize
|
||||||
|
```bash
|
||||||
|
resize2fs /dev/device [size]
|
||||||
|
```
|
||||||
|
|
||||||
|
#### if superblock fail
|
||||||
|
```bash
|
||||||
|
dumpe2fs /dev/sda5 | grep -i backup
|
||||||
|
fsck -b 32768 /dev/sda5
|
||||||
|
```
|
64
docs/linux/rsyslog.md
Normal file
64
docs/linux/rsyslog.md
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
```
|
||||||
|
$ModLoad imudp
|
||||||
|
$UDPServerRun 514
|
||||||
|
|
||||||
|
template(name="cmpDate" type="list") {
|
||||||
|
property(name="timereported" dateformat="year")
|
||||||
|
constant(value="-")
|
||||||
|
property(name="timereported" dateformat="month")
|
||||||
|
constant(value="-")
|
||||||
|
property(name="timereported" dateformat="day")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
set $.cmpDate = exec_template("cmpDate");
|
||||||
|
set $.cmpSuff = "default";
|
||||||
|
|
||||||
|
template(name="cmpOutFile" type="list") {
|
||||||
|
constant(value="/mnt/netlog/zzz/")
|
||||||
|
|
||||||
|
property(name="$.cmpDate")
|
||||||
|
|
||||||
|
constant(value="/")
|
||||||
|
# property(name="hostname")
|
||||||
|
property(name="fromhost-ip")
|
||||||
|
constant(value="-")
|
||||||
|
property(name="$.cmpSuff")
|
||||||
|
constant(value=".log")
|
||||||
|
}
|
||||||
|
|
||||||
|
template(name="cmpOutFmt" type="list") {
|
||||||
|
property(name="$.cmpDate")
|
||||||
|
|
||||||
|
constant(value=" ")
|
||||||
|
property(name="timereported" dateformat="hour")
|
||||||
|
constant(value=":")
|
||||||
|
property(name="timereported" dateformat="minute")
|
||||||
|
constant(value=":")
|
||||||
|
property(name="timereported" dateformat="second")
|
||||||
|
|
||||||
|
constant(value=" ")
|
||||||
|
property(name="hostname")
|
||||||
|
constant(value=" ")
|
||||||
|
|
||||||
|
property(name="syslogtag")
|
||||||
|
property(name="msg" spifno1stsp="on" )
|
||||||
|
property(name="msg" droplastlf="on" )
|
||||||
|
constant(value="\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if( $fromhost-ip == "127.0.0.1" ) then {
|
||||||
|
stop
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $fromhost-ip == "172.16.1.1" ) then {
|
||||||
|
if ( $syslogtag contains "teg3" ) then {
|
||||||
|
set $.cmpSuff = "teg3";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
action(type="omfile" dynafile="cmpOutFile" template="cmpOutFmt")
|
||||||
|
|
||||||
|
stop
|
||||||
|
```
|
9
docs/linux/selinux.md
Normal file
9
docs/linux/selinux.md
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
# Nginx
|
||||||
|
```
|
||||||
|
# Allow open local port
|
||||||
|
semanage port -a -t http_port_t -p tcp 28081
|
||||||
|
|
||||||
|
# Allow open remote port
|
||||||
|
setsebool -P httpd_can_network_connect 1
|
||||||
|
```
|
3
docs/other/math.md
Normal file
3
docs/other/math.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
# Аппроксимация функции одной переменной
|
||||||
|
[https://planetcalc.ru/5992/](https://planetcalc.ru/5992/)
|
28
docs/progs/crontab.md
Normal file
28
docs/progs/crontab.md
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
# Crontab
|
||||||
|
|
||||||
|
```
|
||||||
|
# PATH=$PATH:/usr/local/bin
|
||||||
|
# LANG=
|
||||||
|
# LC_ALL=
|
||||||
|
|
||||||
|
### on reboot
|
||||||
|
# @reboot command
|
||||||
|
|
||||||
|
### on time
|
||||||
|
# * * * * * command
|
||||||
|
### | | | | |
|
||||||
|
### | | | | |
|
||||||
|
### | | | | |
|
||||||
|
### | | | | |--| 0-7 день недели
|
||||||
|
### | | | | |
|
||||||
|
### | | | |----| 1-12 месяц
|
||||||
|
### | | | |
|
||||||
|
### | | |------| 1-31 день месяца
|
||||||
|
### | | |
|
||||||
|
### | |--------| 0-23 часы
|
||||||
|
### | |
|
||||||
|
### |----------| 0-59 минуты
|
||||||
|
|
||||||
|
```
|
||||||
|
|
22
docs/progs/kubernetes.md
Normal file
22
docs/progs/kubernetes.md
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir -p $HOME/.kube
|
||||||
|
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
|
||||||
|
sudo chown $(id -u):$(id -g) $HOME/.kube/config
|
||||||
|
```
|
||||||
|
|
||||||
|
Alternatively, if you are the root user, you can run:
|
||||||
|
```bash
|
||||||
|
export KUBECONFIG=/etc/kubernetes/admin.conf
|
||||||
|
```
|
||||||
|
|
||||||
|
You should now deploy a pod network to the cluster.
|
||||||
|
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
|
||||||
|
https://kubernetes.io/docs/concepts/cluster-administration/addons/
|
||||||
|
|
||||||
|
Then you can join any number of worker nodes by running the following on each as root:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubeadm join 10.0.0.1:6443 --token 000000.0000000000000000 \
|
||||||
|
--discovery-token-ca-cert-hash sha256:0000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
```
|
8
docs/progs/mariadb.md
Normal file
8
docs/progs/mariadb.md
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
# MariaDB
|
||||||
|
|
||||||
|
## Create database, user and grand permission
|
||||||
|
```sql
|
||||||
|
CREATE DATABASE dbn CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||||
|
CREATE USER 'usr'@'localhost' IDENTIFIED BY 'pwd'; GRANT ALL PRIVILEGES ON dbn.* TO usr@localhost;
|
||||||
|
```
|
53
docs/progs/mc.md
Normal file
53
docs/progs/mc.md
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# MC
|
||||||
|
|
||||||
|
## ~/.config/mc/ini
|
||||||
|
```ini
|
||||||
|
[Layout]
|
||||||
|
command_prompt=1
|
||||||
|
free_space=1
|
||||||
|
horizontal_equal=1
|
||||||
|
horizontal_split=0
|
||||||
|
keybar_visible=0
|
||||||
|
left_panel_size=104
|
||||||
|
menubar_visible=0
|
||||||
|
message_visible=0
|
||||||
|
output_lines=0
|
||||||
|
top_panel_size=1
|
||||||
|
vertical_equal=1
|
||||||
|
xterm_title=0
|
||||||
|
|
||||||
|
[Midnight-Commander]
|
||||||
|
use_internal_view=1
|
||||||
|
use_internal_edit=1
|
||||||
|
alternate_plus_minus=1
|
||||||
|
skin=darkfar
|
||||||
|
|
||||||
|
editor_ask_filename_before_edit=false
|
||||||
|
editor_backspace_through_tabs=false
|
||||||
|
editor_backup_extension=~
|
||||||
|
editor_check_new_line=false
|
||||||
|
editor_cursor_after_inserted_block=false
|
||||||
|
editor_cursor_beyond_eol=false
|
||||||
|
editor_drop_selection_on_copy=true
|
||||||
|
editor_edit_confirm_save=true
|
||||||
|
editor_fake_half_tabs=false
|
||||||
|
editor_filesize_threshold=64M
|
||||||
|
editor_fill_tabs_with_spaces=false
|
||||||
|
editor_group_undo=false
|
||||||
|
editor_line_state=false
|
||||||
|
editor_option_auto_para_formatting=false
|
||||||
|
editor_option_save_mode=0
|
||||||
|
editor_option_save_position=true
|
||||||
|
editor_option_typewriter_wrap=false
|
||||||
|
editor_persistent_selections=true
|
||||||
|
editor_return_does_auto_indent=true
|
||||||
|
editor_show_right_margin=false
|
||||||
|
editor_simple_statusbar=false
|
||||||
|
editor_state_full_filename=false
|
||||||
|
editor_stop_format_chars=-+*\\,.;:&>
|
||||||
|
editor_syntax_highlighting=true
|
||||||
|
editor_tab_spacing=4
|
||||||
|
editor_visible_spaces=true
|
||||||
|
editor_visible_tabs=false
|
||||||
|
editor_word_wrap_line_length=72
|
||||||
|
```
|
71
docs/progs/nmcli.md
Normal file
71
docs/progs/nmcli.md
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
|
||||||
|
# Connection start
|
||||||
|
```bash
|
||||||
|
nmcli con up ens18
|
||||||
|
```
|
||||||
|
|
||||||
|
# Connection modifity
|
||||||
|
```bash
|
||||||
|
ifc=eth0 \
|
||||||
|
nmcli con mod $ifc ipv4.addresses 172.16.23.56/24 && \
|
||||||
|
nmcli con mod $ifc ipv4.gateway 172.16.23.1 && \
|
||||||
|
nmcli con mod $ifc ipv4.dns 172.16.20.130 && \
|
||||||
|
nmcli con mod $ifc ipv4.method manual && \
|
||||||
|
nmcli con mod $ifc ipv6.method disable && \
|
||||||
|
nmcli con up $ifc restart && \
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
||||||
|
# Disable IPv6 for all
|
||||||
|
```
|
||||||
|
nmcli con show | awk '{if(NR > 1) { print $1; system("nmcli con mod " $1 " ipv6.method disable"); } }'
|
||||||
|
```
|
||||||
|
|
||||||
|
# Connection event
|
||||||
|
```bash
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This is /etc/NetworkManager/dispatcher.d/0167-cmp.sh
|
||||||
|
|
||||||
|
# IFACE="$1" # DEVICE_IFACE
|
||||||
|
# EVENT="$2" # NM_DISPATCHER_ACTION
|
||||||
|
# - connectivity-change
|
||||||
|
# - down
|
||||||
|
# - up
|
||||||
|
# - vpn-down
|
||||||
|
# - vpn-up
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ "${NM_DISPATCHER_ACTION}" = "connectivity-change" ]; then
|
||||||
|
if [ "${CONNECTIVITY_STATE}" = "FULL" ]; then
|
||||||
|
nmcli conn up ssh-37
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${CONNECTIVITY_STATE}" = "LIMITED" ]; then
|
||||||
|
nmcli conn up ssh-37
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${CONNECTIVITY_STATE}" = "NONE" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if true; then
|
||||||
|
logger -t 0167-cmp.sh @=$@ "ENV" \
|
||||||
|
NM_DISPATCHER_ACTION=$NM_DISPATCHER_ACTION \
|
||||||
|
CONNECTION_UUID=$CONNECTION_UUID \
|
||||||
|
CONNECTION_ID=$CONNECTION_ID \
|
||||||
|
CONNECTION_DBUS_PATH=$CONNECTION_DBUS_PATH \
|
||||||
|
CONNECTION_FILENAME=$CONNECTION_FILENAME \
|
||||||
|
CONNECTION_EXTERNAL=$CONNECTION_EXTERNAL \
|
||||||
|
DEVICE_IFACE=$DEVICE_IFACE \
|
||||||
|
DEVICE_IP_IFACE=$DEVICE_IP_IFACE \
|
||||||
|
CONNECTIVITY_STATE=$CONNECTIVITY_STATE
|
||||||
|
fi
|
||||||
|
|
||||||
|
```
|
5
docs/progs/php.md
Normal file
5
docs/progs/php.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
## Set default timezone
|
||||||
|
```
|
||||||
|
printf '[Date]\ndate.timezone = Asia/Katmandu\n' > /etc/php.d/17-cmp-timezone.ini
|
||||||
|
```
|
4
docs/progs/socat.md
Normal file
4
docs/progs/socat.md
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
```bash
|
||||||
|
socat PTY,link=/dev/vmodem0,echo=0,waitslave TCP:10.0.0.1:333
|
||||||
|
```
|
17
docs/progs/ssh.md
Normal file
17
docs/progs/ssh.md
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# SSH
|
||||||
|
|
||||||
|
## Generate public key from private
|
||||||
|
```
|
||||||
|
ssh-keygen -f id_rsa -y > id_rsa.pub
|
||||||
|
```
|
||||||
|
|
||||||
|
## Port forwarding
|
||||||
|
```bash
|
||||||
|
# forward : 172.16.0.1:80 -> 172.16.0.2 -> 127.0.0.1:4080
|
||||||
|
ssh -f -N -L 4080:172.16.0.1:80 172.16.0.2
|
||||||
|
```
|
||||||
|
|
||||||
|
## Allow old algorithm
|
||||||
|
```bash
|
||||||
|
ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 -oHostKeyAlgorithms=+ssh-dss 172.16.0.1
|
||||||
|
```
|
Reference in New Issue
Block a user