dd if=/dev/zero of=src/file3 bs=1M count=3
- создание файла заданного размераsync; dd if=/dev/zero of=/tmp/tempfile bs=1M count=1024; sync
dd if=/tmp/tempfile of=/dev/null bs=1M count=1024
- тестирование скорости дискаnetstat -an|awk '/tcp/ {print $6}'|sort|uniq -c
(echo -e “HTTP/1.1 200 OK\nContent-Type: text/html\n\n Hello World”;) | nc -vv -l -p 8080
curl ipinfo.io / curl ifconfig.co / curl ifconfig.co/json
curl ipinfo.io/188.120.242.62
geoiplookup 188.120.242.62 (sudo apt install geoip-bin)
sudo cat /var/log/nginx/wiki/access.log | grep -o '^.* -' | grep -o '[0-9\.]*' | sort | uniq -c
sudo grep -o 'Ban [0-9\.]*' /var/log/fail2ban.log | grep -o '[0-9\.]*' | sort | uniq -c | sort
Tmux - это терминальный мультиплексор, позволяет на один экран выводить несколько окон, можно отключаться и подключаться к ним не теряя прогресс.
# Sessions tmux # Создать новую сессию 0 tmux new -s hello # Создать новую сессию hello tmux detach # (Ctr-b + d) Отключиться от сессии tmux attach (или a) # Подключиться к последней работающей сессии tmux attach -t hello # Подключиться к сессии по имени tmux ls # Список сессий (Ctr-b + s) # Выбрать сессию tmux kill-server # Завершить все сессии tmux kill-session -t hello # Завершить сессию hello # Wndows (Ctr-b + c) # Создать новое окно (Ctr-b + w) # Список окон (Ctr-b + n) # Следующее окно (Ctr-b + p) # Предыдущее окно (Ctr-b + 0) # Окно по номеру # Panes (Панели) (Ctr-b + \") # Поделить горизонтально (Ctr-b + -) # Поделить вертикально (Ctr-b + стрелки) # Переход между панелей (Ctr-b + Ctrl-стрелки) # Изменение размеров панелей (Ctr-b + q-<n>) # Подсветить все панели и перейти на панель n (Ctr-b + z) # Развернуть панель во все окно или сжать # Copy paste Shift + Mouse left button double-click # Copies the double-clicked word Shift + Select using mouse # Copies the selection Shift + Mouse middle button click # Pastes the copied text using above method in the tmux pane
# TPM Plugin (Ctr-b + I) # install new plugins and refresh Tmux environment (Ctr-b + U) # update plugins (Ctr-b + alt-u) # remove plugins not in plugin list # Resurrect Plugin (Ctr-b + ctrl-s) # Save environment (Ctr-b + ctrl-r) # Restore environment # Continuum Plugin # Continuous saving tmux environment, automatic start tmux, automatic restore
ll | awk 'BEGIN {print "Hello!"} {print} END {print "Bye!"}' ll | awk -f command.awk awk -v name=Diego 'BEGIN {printf "Name - %s\n", name}' # Шаблоны ll | awk '/git/' # одно ll | awk '/git/ {print}' # и ll | awk '/git/ {print $0}' # тоже (авнозначные комманды)
#!/usr/bin/awk -f BEGIN { print "type a number"; } { print "The square of ", $1, " is ", $1*$1; print "type another number"; } END { print "Done" }
sed OPTIONS... [SCRIPT] [INPUTFILE...] Options: -e -i -f # read script form file -n # produces output when explicitly told to via the p command # A sed script is a sequence of commands: [ADDR]X[OPTIONS] where, [ADDR] is an optional address specification X is a single-letter command [OPTIONS] are optional options (or flags) accepted by the command.
a TEXT # Append text after a line c TEXT # Replace (change) lines with text d # Delete the pattern space; immediately start next cycle i TEXT # Insert text before a line p # Print the pattern space s/REGEXP/REPLACEMENT/[FLAGS] # Match the regular expression REGEXP, if found, replace with REPLACEMENT. y/SRC/DST/ # Transliterate characters which match any of the SRC # with the corresponding character in DST.
s/REGEXP/REPLACEMENT/[FLAGS] g # Apply the replacement to all matches to the regexp, not just the first NUMBER #Only replace the NUMBERth match of the regexp
sed -i s/alexander/alex/g /etc/passwd where, [ADDR] = '' X = 's///' [OPTIONS] = 'g'
sed -i 1,1000d /var/log/messages where, [ADDR] = '1,1000' X = 'd' [OPTIONS] = ''
sed -n '/roo/{p;p;q;}' /etc/passwd where, [ADDR] = '/roo/' X = '{p;p;q}' - block [OPTIONS] = ''
grep [options] pattern [files] Options Description -B : Lines before -A : Lines after -c : This prints only a count of the lines that match a pattern -h : Display the matched lines, but do not display the filenames. -i : Ignores, case for matching -l : Displays list of a filenames only. -n : Display the matched lines and their line numbers. -v : This prints out all the lines that do not matches the pattern -e exp : Specifies expression with this option. Can use multiple times. -f file : Takes patterns from file, one per line. -E : Treats pattern as an extended regular expression (ERE) -w : Match whole word -o : Print only the matched parts of a matching line, with each such part on a separate output line.
find [папка] [параметры] критерий шаблон [действие] параметры: -type {f,d, b,c,p,l,f} -maxdepth N критерий: -name "file_name" -perm # поиск по правам доступа, например 755 -o # or -and # and (expr1 expr2 / expr1 -a expr2 / expr1 -and expr2) -prune # остановить поиск на текущей директории действие: -exec <command> {} \; Example: find . \( -name "\.git" -o -name "\.mypy_cache" -o -name ".tox" \) -prune -o -print
Code examples:
jq '.[0:2] | .[] | {requested_at: .requested_at, respond_at: .respond_at}' test.json jq 'map(select(has("respond_at"))) | length' test.json jq 'map(select(.respond_at == "2022-03-16")) | length' test.json jq 'map(select(.requested_at > "2022-03-15")) | length' test.json jq 'map(select(.requested_at > "2022-03-16")) | map(select(has("respond_at"))) | length' test.json jq 'map(select(.requested_at > "2022-03-15")) | map(select(has("respond_at")|not)) | .[0]' test.json jq '.[] | {start_time: (.start_time/1000 | todate), duration: (.end_time - .start_time)}' test.json jq 'map({start_time: (.start_time/1000 | todate), duration: (.end_time - .start_time)})' test.json jq 'map(select(.email|test("^m.*i.*h.*a.*i.*l.*v@gmail\\.com"; "gixp"))) | length' test.json jq 'map(select(has("src_lang"))) | .[] | .src_lang' localization-prod-project_20230504105646.json | sort | uniq -c | sort -k1 -n -r jq '.[0:10] | map(select(has("dst_lang"))) |map(select(has("src_lang"))) | .[] | "\(.src_lang) - \(.dst_lang)"' localization-prod-project_20230504105646.json | sort | uniq -c | sort -k1 -n -r | head -n 20 jq '.[0:10] | map(select(has("dst_lang"))) |map(select(has("src_lang"))) | .[] | "\(.src_lang) - \(.dst_lang | split('-'))"' localization-prod-project_20230504105646.json