Etc Linux

old nic names in CentOS 7
# add net.ifnames=0 biosdevname=0 to grub
vi /etc/default/grub
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet net.ifnames=0 biosdevname=0"

# check config
grub2-mkconfig

# save config
grub2-mkconfig -o /boot/grub2/grub.cfg

# then rename your configs in /etc/sysconfig/network-scripts
# and fix DEVICE="eth0"
swap in file
sudo su

fallocate -l 1G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo "/swapfile swap swap  sw 0 0" >> /etc/fstab

# less swapiness
sysctl vm.swappiness=10
echo "vm.swappiness = 10" >> /etc/sysctl.conf

# more inode cache
sysctl vm.vfs_cache_pressure=50
echo "vm.vfs_cache_pressure = 50" >> /etc/sysctl.conf
instant reboot and shutdown
# fast reboot
echo 1 > /proc/sys/kernel/sysrq 
echo b > /proc/sysrq-trigger

# fast shutdown
echo 1 > /proc/sys/kernel/sysrq 
echo o > /proc/sysrq-trigger
search routers in net
tcpdump -vvnn -i eth1 'src net 172.16.0.0/16 and ip[7:2] != 128 and ip[7:2] != 64'
gateway troubleshooting
netstat-nat -Nn

conntrack -L |awk '{if ($5 ~ /src/) print $5; else if ($4 ~ /src/) print $4}' | sed "s/src=/ /g" | sort | uniq -c | sort -n | tail -n15

sysctl tweaks
# network
net.core.rmem_max=67108864
net.core.wmem_max=67108864
net.ipv4.tcp_rmem=4096 87380 33554432
net.ipv4.tcp_wmem=4096 65536 33554432
net.core.netdev_max_backlog=30000
net.ipv4.tcp_congestion_control=htcp
net.ipv4.ip_local_port_range=1024 65000
net.core.somaxconn=256

# netfilter
net.netfilter.nf_conntrack_tcp_timeout_established=86400
net.netfilter.nf_conntrack_max=1548576
net.nf_conntrack_max=1548576

# Controls IP packet forwarding
net.ipv4.ip_forward = 1

# Controls source route verification
net.ipv4.conf.default.rp_filter = 1

# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0

# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0

# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1

# Controls the use of TCP syncookies
net.ipv4.tcp_syncookies = 1

# Controls the default maxmimum size of a mesage queue
kernel.msgmnb = 65536

# Controls the maximum size of a message, in bytes
kernel.msgmax = 65536

# Controls the maximum shared segment size, in bytes
kernel.shmmax = 68719476736

# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 4294967296
Filesystem ACLs
# allow user apetrov read all files and X all dirs
setfacl -R -m d:u:apetrov:rwX,u:apetrov:rwX folder

# addе +x for user http
setfacl -m "u:http:--x" /data/dir

# copy acls
getfacl basefile | setfacl -b -M - targetfile

# delete all acls
setfacl -Rb /home/dir
# golang support for mcedit
# ~/.local/share/mc/go.syntax
# or /usr/share/mc/syntax/go.syntax
#
# requires ~/.config/mc/mcedit/Syntax with lines:
#      or /usr/share/mc/syntax/Syntax
#
#   file ..\*\\.(go)$ Go\sSource
#   include go.syntax

context default
# keywords
        keyword whole break brightmagenta
        keyword whole case brightmagenta
        keyword whole chan brightmagenta
        keyword whole const brightmagenta
        keyword whole continue brightmagenta
        keyword whole default brightmagenta
        keyword whole defer brightmagenta
        keyword whole else brightmagenta
        keyword whole fallthrough brightmagenta
        keyword whole for brightmagenta
        keyword whole func brightmagenta
        keyword whole go brightmagenta
        keyword whole goto brightmagenta
        keyword whole if brightmagenta
        keyword whole import brightmagenta
        keyword whole interface brightmagenta
        keyword whole map brightmagenta
        keyword whole package brightmagenta
        keyword whole range brightmagenta
        keyword whole return brightmagenta
        keyword whole select brightmagenta
        keyword whole struct brightmagenta
        keyword whole switch brightmagenta
        keyword whole type brightmagenta
        keyword whole var brightmagenta
# builtin types
        keyword whole uint8 yellow
        keyword whole uint16 yellow
        keyword whole uint32 yellow
        keyword whole uint64 yellow
        keyword whole int8 yellow
        keyword whole int16 yellow
        keyword whole int32 yellow
        keyword whole int64 yellow
        keyword whole float32 yellow
        keyword whole float64 yellow
        keyword whole byte yellow
        keyword whole uint yellow
        keyword whole int yellow
        keyword whole float yellow
        keyword whole uintptr yellow
        keyword whole string yellow
        keyword whole bool yellow
# builtin functions
        keyword whole nil white
        keyword whole true white
        keyword whole false white
        keyword whole iota white
        keyword whole cap white
        keyword whole close white
        keyword whole closed white
        keyword whole len white
        keyword whole make white
        keyword whole new white
        keyword whole panic white
        keyword whole panicln white
        keyword whole print white
        keyword whole println white
# special functions
        keyword whole init white
        keyword whole main white
# comment chars
        keyword /\* brown
        keyword \*/ brown
        keyword // brown
# punctuation, operator chars
        keyword <- brightmagenta
        keyword \+ brightcyan
        keyword & brightcyan
        keyword ( brightcyan
        keyword ) brightcyan
        keyword - brightcyan
        keyword | brightcyan
        keyword < brightcyan
        keyword [ brightcyan
        keyword ] brightcyan
        keyword \* brightcyan
        keyword ^ brightcyan
        keyword > brightcyan
        keyword { brightcyan
        keyword } brightcyan
        keyword / brightcyan
        keyword = brightcyan
        keyword , brightcyan
        keyword ; brightcyan
        keyword % brightcyan
        keyword ! brightcyan
        keyword . brightcyan
        keyword : brightcyan
# comment
context exclusive /\* \*/ brown
context exclusive // \n brown

# char, raw string, string
context ' ' brightgreen
        keyword \\\{abfnrtv\\'"\} green
        keyword \\\{0123\}\{01234567\}\{01234567\} green
        keyword \\x\{0123456789abcdefABCDEF\}\{0123456789abcdefABCDEF\} green
        keyword \\u\{0123456789abcdefABCDEF\}\{0123456789abcdefABCDEF\}\{0123456789abcdefABCDEF\}\{0123456789abcdefABCDEF\} green
        keyword \\U\{0123456789abcdefABCDEF\}\{0123456789abcdefABCDEF\}\{0123456789abcdefABCDEF\}\{0123456789abcdefABCDEF\}\{0123456789abcdefABCDEF\}\{0123456789abcdefABCDEF\}\{0123456789abcdefABCDEF\}\{0123456789abcdefABCDEF\} green
context ` ` brightgreen
context " " brightgreen
        keyword \\\{abfnrtv\\'"\} green
        keyword \\\{0123\}\{01234567\}\{01234567\} green
        keyword \\x\{0123456789abcdefABCDEF\}\{0123456789abcdefABCDEF\} green
        keyword \\u\{0123456789abcdefABCDEF\}\{0123456789abcdefABCDEF\}\{0123456789abcdefABCDEF\}\{0123456789abcdefABCDEF\} green
        keyword \\U\{0123456789abcdefABCDEF\}\{0123456789abcdefABCDEF\}\{0123456789abcdefABCDEF\}\{0123456789abcdefABCDEF\}\{0123456789abcdefABCDEF\}\{0123456789abcdefABCDEF\}\{0123456789abcdefABCDEF\}\{0123456789abcdefABCDEF\} green