Получение открытого ключа на основе закрытого
# ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDMawKdoRMlgI/UlJujNQTb7X0IUFOJtiksT83tWHAPtSpA9i89w6725LsZaEJBLxThmYDvd 5pjo3OBW4OqV0itnf0O4e5WwwYEZ+TQx5ootmwvBINGP3oEly0kcd/3Ye+gwuRUIR9+XevaPx9pgb3CITo93qUtHxXZJLh6ZJoP+caoz1b4 /JvQoY7IfzRJQbY11hgxLojqewQHZoffthCvceKumvrTYxNdEwsD+RgxFqX3ucCCRnoxkjBNH0shSf50s0zImVRn1g34It3xjBN0BRq55eLAr
Копирование одного файла сразу в несколько
# tee < source.txt dst1.txt dst2.txt dst3.txt > /dev/null
Конвертация файла в utf-8 используя все доступные кодировки.
for charset in $(iconv -l) do echo ${charset} iconv -f ${charset} -t UTF-8 file.txt done &>/tmp/converted
# echo -e "1\n2\n3\n4" | xargs -t -n 2 echo echo 1 2 1 2 echo 3 4 3 4 # echo -e "1\n2\n3\n4" | xargs -n 2 echo 1 2 3 4 # echo -e "1\n2\n3\n4" | xargs -t -n 1 echo echo 1 1 echo 2 2 echo 3 3 echo 4 4
Отправка multipart/form-data
# curl -i -H "Content-Type: multipart/form-data" -F limit=100000 -F count=10 -F [email protected] http://requestb.in/abc123zyx
Получение ip адреса
# curl -s http://checkip.dyndns.org | grep -P -o '([0-9]{1,3}\.?){4}' 52.40.xxx.xxx # curl 'https://api.ipify.org?format=json' {"ip":"52.40.xxx.xxx"} # curl https://api.ipify.org 52.40.xxx.xxx
Генерация mac адреса
# tr -dc A-F0-9 < /dev/urandom | head -c 10 | sed -r 's/(..)/\1:/g;s/:$//;s/^/02:/' 02:B3:75:39:15:25
Для локальных mac адресов рекомендуется использовать следующие диапазоны
x2:xx:xx:xx:xx:xx x6:xx:xx:xx:xx:xx xA:xx:xx:xx:xx:xx xE:xx:xx:xx:xx:xx
Вывод заданных строк в файле
# sed -n 1,3p /etc/sysconfig/iptables-config # Load additional iptables modules (nat helpers) # Default: -none- # Space separated list of nat helpers (e.g. 'ip_nat_ftp ip_nat_irc'), which
Генерация динамического png файла с текущей датой и временем
# while true; do convert -size 512x512 canvas:black -gravity center -extent 256x64 -fill white -pointsize 24 -font /usr/share/fonts/truetype/google/Noto_Serif/NotoSerif-Regular.ttf -annotate 0 "$(date +'%d.%m.%Y %H:%M:%S')" tmp.png; mv -f tmp.png 12345_face1.png; sleep 3; done
# mkdir -p /mnt/ramfs # mount -t ramfs none /mnt/ramfs # dd if=/dev/zero of=/mnt/ramfs.img bs=1M count=1024 # mke2fs -vFL RAMDisk /mnt/ramfs.img # mkdir -p /mnt/ramdisk # mount -o loop /mnt/ramfs.img /mnt/ramdisk
mount -t tmpfs -o size=2048M tmpfs /mnt/tmpfs/
# find project1/ -type f -name '*.psd' -exec ls -l {} \; | awk '{ print $5}' | awk '{s+=S0} END {print s/1073741824" Gb"}' 16.9759 Gb
# mysqldump --routines --no-create-info --no-data --no-create-db --skip-opt database_name > database_name.sql
# echo b > /proc/sysrq-trigger
# tr -dc A-Za-z0-9_@$% < /dev/urandom | head -c 10
# tar cjf - /var/www/html/ | ssh [email protected] "cat > /backup/sys-adm.org.ua.tar.bz2"
или
# tar --rsh-command=/usr/bin/ssh -jcvf backup.sys-adm.org.ua:/backup/sys-adm.org.ua.tar.bz2 /var/www/html/
# mount -t cifs //192.168.127.100/Soft -o username=alex,password=1234567 --verbose /mnt/ mount.cifs kernel mount options: unc=//192.168.127.100\Soft,ip=192.168.127.100,ver=1,rw,username=alex,pass=******** # mount | grep Soft //192.168.127.100/Soft on /mnt type cifs (rw,mand)
# mount.cifs //192.168.127.100/share /mnt -o username=alex,password=1234567,workgroup=SYSADM,rw --verbose mount.cifs kernel mount options: unc=//192.168.127.100\share,ver=1,username=alex,workgroup=SYSADM,rw,ip=192.168.127.100,pass=******** # mount | grep share //192.168.127.100/share on /mnt type cifs (rw,mand)
# find . -type d -iname '*get'
# yum provides "*/uuencode" sharutils-4.6.1-2.i386 : The GNU shar utilities for packaging and unpackaging shell archives. Repo : base Matched from: Filename : /usr/bin/uuencode
# yum install yum-utils # package-cleanup --orphan # package-cleanup --orphan Setting up yum samba-client-3.4.5-1.i386 samba-doc-3.4.5-1.i386 samba-common-3.4.5-1.i386 openfire-3.6.4-1.i386 samba-3.4.5-1.i386
# package-cleanup --leaves Setting up yum libnl-1.0-0.10.pre5.5.i386 libacl-devel-2.2.39-3.el5.i386 libhugetlbfs-1.3-3.el5.i386 libaio-0.3.106-3.2.i386
# package-cleanup --problems Setting up yum Reading local RPM database Processing all local requires Missing dependencies: Package redhat-lsb requires /usr/bin/lp Package redhat-lsb requires /usr/bin/lpr Package hal-cups-utils requires cups Package desktop-printing requires cups Package libgnomecups requires cups
# lsof -n | grep TCP | grep LISTEN named 2349 named 20u IPv4 6799 TCP 127.0.0.1:domain (LISTEN) named 2349 named 21u IPv4 6801 TCP 10.0.0.104:domain (LISTEN) named 2349 named 22u IPv4 6803 TCP 127.0.0.1:rndc (LISTEN) named 2349 named 23u IPv6 6812 TCP [::1]:rndc (LISTEN) portmap 2407 rpc 4u IPv4 6906 TCP *:sunrpc (LISTEN) rpc.statd 2444 rpcuser 7u IPv4 7008 TCP *:930 (LISTEN) slapd 2667 ldap 7u IPv6 7614 TCP *:ldap (LISTEN) slapd 2667 ldap 8u IPv4 7615 TCP *:ldap (LISTEN) slapd 2667 ldap 9u IPv6 7619 TCP *:ldaps (LISTEN) slapd 2667 ldap 10u IPv4 7620 TCP *:ldaps (LISTEN) hpiod 2718 root 0u IPv4 7756 TCP 127.0.0.1:2208 (LISTEN) python 2723 root 4u IPv4 7774 TCP 127.0.0.1:2207 (LISTEN) sshd 2741 root 3u IPv6 7820 TCP *:ssh (LISTEN) mysqld 2850 mysql 11u IPv4 8017 TCP *:mysql (LISTEN) httpd 2921 root 3u IPv6 8191 TCP *:http (LISTEN) java 3126 daemon 32u IPv6 10288 TCP 10.0.0.104:cbt (LISTEN) java 3126 daemon 34u IPv6 10290 TCP 10.0.0.104:5229 (LISTEN) java 3126 daemon 36u IPv6 10292 TCP 10.0.0.104:xmpp-server (LISTEN) java 3126 daemon 46u IPv6 10304 TCP 10.0.0.104:websm (LISTEN) java 3126 daemon 51u IPv6 10310 TCP 10.0.0.104:xmltec-xmlmail (LISTEN) java 3126 daemon 73u IPv6 10320 TCP 10.0.0.104:xmpp-client (LISTEN) java 3126 daemon 77u IPv6 10323 TCP 10.0.0.104:5223 (LISTEN) java 3126 daemon 81u IPv6 10326 TCP 10.0.0.104:arcp (LISTEN) java 3126 daemon 85u IPv6 10329 TCP 10.0.0.104:7443 (LISTEN) httpd 3694 apache 3u IPv6 8191 TCP *:http (LISTEN) httpd 3695 apache 3u IPv6 8191 TCP *:http (LISTEN) httpd 3696 apache 3u IPv6 8191 TCP *:http (LISTEN) httpd 3697 apache 3u IPv6 8191 TCP *:http (LISTEN) httpd 3698 apache 3u IPv6 8191 TCP *:http (LISTEN) httpd 3699 apache 3u IPv6 8191 TCP *:http (LISTEN) httpd 3700 apache 3u IPv6 8191 TCP *:http (LISTEN) httpd 3701 apache 3u IPv6 8191 TCP *:http (LISTEN) smbd 17348 root 25u IPv4 35979 TCP 10.0.0.104:microsoft-ds (LISTEN) smbd 17348 root 26u IPv4 35981 TCP 10.0.0.104:netbios-ssn (LISTEN)