Last active
December 4, 2024 04:02
-
-
Save rsyuzyov/05054c8df5ebe68cac45943104c24493 to your computer and use it in GitHub Desktop.
linux commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Сразу после установки: | |
| apt install fail2ban sysstat atop htop iotop iftop net-tools mc ncdu zfs-auto-snapshot | |
| apt install dosfstools rsync ntfs-3g ntfs-config perf-tools-unstable | |
| ========================================= | |
| Настройка fail2ban: | |
| /etc/fail2ban/jail.local | |
| [proxmox] | |
| enabled = true | |
| port = https,http,8006 | |
| filter = proxmox | |
| logpath = /var/log/daemon.log | |
| maxretry = 5 | |
| bantime = 14400 | |
| [sshd] | |
| enabled = true | |
| port = ssh | |
| logpath = %(sshd_log)s | |
| maxretry = 5 | |
| bantime = 14400 | |
| ========================================= | |
| О системе: | |
| uname -a | |
| lsb_release -a | |
| Просмотр логов: | |
| dmesg | egrep -i 'err|warn|critical' | |
| tail -f /var/log/syslog | |
| О системе: | |
| hwinfo - cli | |
| hardinfo - gui | |
| Что в какой порт подключено, например подключен usb-диск в usb2 или usb3: | |
| lshw -numeric | less | |
| Посмотртеть железо, например планки памяти: | |
| dmidecode -t memory | |
| или | |
| lshw -class memory | |
| Диски: | |
| lsblk -do name,size,model | |
| cfdisk, cgdisk | |
| fdisk, gdisk | |
| partprobe | |
| Отображение прогресса для cp, rsync, dd: | |
| progress | |
| https://losst.ru/kak-posmotret-progress-komandy-v-linux | |
| для dd: | |
| dd if=... | pv | dd of=... | |
| Замер скорости: | |
| fio --randrepeat=1 --ioengine=libaio --direct=1 --gtod_reduce=1 --name=/dev/sdc --filename=/dev/sdc --bs=4k --iodepth=64 --size=4G --readwrite=randwrite | |
| fio --time_based --name=benchmark --size=8G --runtime=30 --filename=/dev/disk/by-id/google-local-ssd-0 --ioengine=libaio --randrepeat=0 --iodepth=128 --direct=1 --invalidate=1 --verify=0 --verify_fatal=0 --numjobs=4 --rw=randwrite --blocksize=4k --group_reporting | |
| Cache & swap | |
| echo 10 > /proc/sys/vm/swappiness или sysctl -w vm.swappiness=10 | |
| echo 1 > /proc/sys/vm/drop_caches | |
| echo 100 > /proc/sys/vm/vfs_cache_pressure | |
| swapoff -a && swapon -a | |
| grub: | |
| dpkg-reconfigure grub-pc или dpkg-reconfigure grub-uefi-amd64 | |
| grub-install /dev/sda | |
| update-grub | |
| grub-mkconfig -o /boot/grub/grub.conf | |
| Клонирование системы: | |
| rsync -auHxv -e "ssh -p $port" --numeric-ids --exclude={/etc/fstab,/etc/network/*,/proc/*,/tmp/*,/sys/*,/dev/*,/mnt/*,/boot/*,/root/*} root@SRCIP:/* / | |
| rsync -auAHXv /* /mnt/root --exclude={/mnt/*,lost+found/,/proc/*,/sys/*,/dev/*,/tmp/*,/boot/*} | |
| Что сколько весит в текущем каталоге: | |
| sudo du -sm * | sort -gr | |
| либо ncdu / | |
| lvm: | |
| sudo pvcreate /dev/sdb | |
| sudo vgcreate pgpool /dev/sdb | |
| sudo lvcreate -n pgdata -L300G pgpool | |
| sudo nano /etc/fstab | |
| /dev/mapper/pgpool-pgdata /pgdata ext4 errors=remount-ro 0 1 | |
| Свободное место: | |
| df -H | |
| Проброс X11 в windows: | |
| http://www.geo.mtu.edu/geoschem/docs/putty_install.html | |
| choco install xming putty | |
| xlaunch | |
| В putty: ssh -> X11: localhost:0.0 | |
| Проброс X11 для sudo: | |
| https://askubuntu.com/questions/414785/cant-open-gedit-as-root | |
| в /etc/sudoers добавить: | |
| Defaults env_keep="XAUTHORIZATION XAUTHORITY TZ PS2 PS1 PATH LS_COLORS KRB5CCNAME HOSTNAME HOME DISPLAY COLORS" | |
| //Монтирование | |
| //smb: | |
| sudo mount -t cifs <//server/share> </target/folder> -o user=<usr>,password=<pwd>,domain=<domain>,file_mode=0777,dir_mode=0777 | |
| //если permission denied, добавляем параметр sec=none|krb5|ntlm | |
| //nfs: | |
| /etc/exports: /sharedfolder *(rw,async,no_subtree_check,no_root_squash) | |
| Посмотреть шары: showmount -e <NFS server name> | |
| fstab: servername:/sharedfolder /mountpoint nfs | |
| // Desktop environment | |
| //Смена DE: | |
| sudo update-alternatives –config x-session-manager | |
| //Смена DM (lightdm, gdm3, sddm): | |
| sudo dpkg-reconfigure lightdm | |
| //Работа с DNS | |
| sudo systemd-resolve --flush-caches | |
| nsupdate | |
| update add www1.example.com 86400 a 172.16.1.1 | |
| update add www.example.com 600 cname www1.example.com. | |
| send | |
| update add 1.1.16.172.in-addr.arpa 86400 ptr www1.example.com. | |
| send | |
| update delete www.example.com cname | |
| update delete www1.example.com a | |
| update delete www2.example.com a | |
| update delete www3.example.com a | |
| send | |
| ////////////////////// | |
| #!/bin/sh | |
| #original from http://community.spiceworks.com/topic/262635-linux-does-not-register-on-the-windows-ad-dns | |
| # reply of Phil6196 Oct 1, 2012 at 12:41 AM (EDT) | |
| ADDR=`/sbin/ifconfig eth0 | grep 'inet addr' | awk '{print $2}' | sed -e s/.*://` | |
| HOST=`hostname` | |
| echo "update delete $HOST A" > /var/nsupdate.txt | |
| echo "update add $HOST 86400 A $ADDR" >> /var/nsupdate.txt | |
| echo "update delete $HOST PTR" > /var/nsupdate.txt | |
| echo "update add $HOST 86400 PTR $ADDR" >> /var/nsupdate.txt | |
| nsupdate /var/nsupdate.txt | |
| /////////// | |
| //Разрешение входа по ssh для root | |
| nano /etc/ssh/sshd_config | |
| PermitRootLogin yes | |
| //Имя ПК | |
| echo "hostname" > /etc/hostname | |
| hostname -F /etc/hotname | |
| //смотрим и настраиваем ip | |
| ip addr //смотрим | |
| ifconfig x.x.x.x netmask x.x.x.x gateway x.x.x.x nameserver x.x.x.x | |
| //dhcp | |
| vi /etc/network/inerfaces | |
| auto eth0 | |
| iface eth0 inet dhcp | |
| hostname rsyuzyov-dh1 | |
| //Автозагрузка | |
| https://losst.ru/avtozagruzka-linux | |
| https://losst.ru/kak-dobavit-skript-v-avtozagruzku-ubuntu | |
| //Просмотр лога NetworkManager | |
| journalctl -u NetworkManager | |
| //Открыть порт | |
| iptables -A INPUT -p tcp --dport 21 -j ACCEPT | |
| Остановить iptables | |
| systemctl stop iptables | |
| Отключение защиты от spectre и meltdown для grub: | |
| /etc/default/grub | |
| GRUB_CMDLINE_LINUX_DEFAULT="noibrs noibpb nopti nospectre_v2 nospectre_v1 l1tf=off nospec_store_bypass_disable no_stf_barrier mds=off tsx=on tsx_async_abort=off mitigations=off" | |
| #GRUB_CMDLINE_LINUX="noibrs noibpb nopti nospectre_v2 nospectre_v1 l1tf=off nospec_store_bypass_disable no_stf_barrier mds=off tsx=on tsx_async_abort=off mitigations=off" | |
| update-grub | |
| reboot | |
| Отключение защиты от spectre и meltdown для PVE: | |
| https://forum.proxmox.com/threads/disable-spectre-meltdown-mitigations.112553/ | |
| /etc/kernel/cmdline: | |
| root=ZFS=rpool/ROOT/pve-1 boot=zfs mitigations=off | |
| Свободные sata-порты: | |
| dmesg | grep 'SATA link down' | |
| Слоты памяти: | |
| dmidecode -t memory |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment