LittleGreenCat / Search all man pages by keyword
Last active
Поиск всех man страничек по ключевому слову
LittleGreenCat / Proxy only for apt, not for the whole system
Last active
Прокси только для apt, но не для системы в целом
cat <<EOF | sudo tee /etc/apt/apt.conf.d/90curtin-aptproxy
Acquire::http::Proxy "http://10.20.30.40:3128";
Acquire::https::Proxy "http://10.20.30.40:3128";
EOF
Альтернативный способ, чтобы не прописывать прокси в систему (мы же за безопасность) можно ее прям команде скормить, например:
http_proxy=http://10.20.30.40:3128 https_proxy=http://10.20.30.40:3128 HTTP_PROXY=http://10.20.30.40:3128 HTTPS_PROXY=http://10.20.30.40:3128 apt update
LittleGreenCat / Arithmetic operations in bash
Last active
Арифметические операции в bash
1 | # Returns true if the numbers are equal |
2 | [[ ${arg1} -eq ${arg2} ]] |
3 | |
4 | # Returns true if the numbers are not equal |
5 | [[ ${arg1} -ne ${arg2} ]] |
6 | |
7 | # Returns true if arg1 is less than arg2 |
8 | [[ ${arg1} -lt ${arg2} ]] |
9 | |
10 | # Returns true if arg1 is less than or equal arg2 |
LittleGreenCat / Conditional expressions for string variables in bash
Last active
Условные выражения для строковых переменных в bash
1 | # True if the shell variable varname is set (has been assigned a value). |
2 | [[ -v ${varname} ]] |
3 | |
4 | # True if the length of the string is zero. |
5 | [[ -z ${string} ]] |
6 | |
7 | # True if the length of the string is non-zero. |
8 | [[ -n ${string} ]] |
9 | |
10 | # True if the strings are equal. = should be used with the test command for POSIX conformance. When used with the [[ command, this performs pattern matching as described above (Compound Commands) |
LittleGreenCat / Conditional expressions for files in bash
Last active
Условные выражения для файлов в bash
1 | ## True if file exists. |
2 | [[ -a ${file} ]] |
3 | |
4 | ## True if file exists and is a block special file. |
5 | [[ -b ${file} ]] |
6 | |
7 | ## True if file exists and is a character special file. |
8 | [[ -c ${file} ]] |
9 | |
10 | ## True if file exists and is a directory. |
LittleGreenCat / Sound signal in console
Last active
Звуковой сигнал в консоли заданного тона и длительности. Например для оповещений об ошибках.
Звуковой сигнал в консоли заданного тона и длительности. Например для оповещений об ошибках.
TONE=3500 #от 500 до 3500
(speaker-test -t sine -f $TONE) & pid=$!;sleep 0.1s;kill -9 $pid
Вообще интересная утилитка, позволяющая проигрывать и WAV, и раздельно левый правый канал и много чего еще.
LittleGreenCat / Grep variations
Last active
Разные варианты команды grep и ключи для смены режимов в базовом grep
1 | grep = grep -G # базовое регулярное выражение (BRE) |
2 | fgrep = grep -F # фиксированный текст, игнорирующий мета-символы |
3 | egrep = grep -E # расширенное регулярное выражение (ERE) |
4 | rgrep = grep -r # рекурсивный |
5 | |
6 | # Опубликовано в https://t.me/gitgate |
LittleGreenCat / Correct increase disc VM
Last active
-
Добавить свободное место в блочное устройство в гипервизоре
-
Внутри VM перечитать размер диска
echo 1>/sys/class/block/sdb/device/rescan
- Установить пакет cloud-guest-utils в составе которого находится нужная нам утилита growpart
apt-get install cloud-guest-utils
LittleGreenCat / Cgroups - Memory Limits
Last active
Ограничение памяти с помощью cgroups
Control Groups (cgroups) позволяют ограничивать объем памяти, доступной для группы процессов.
Для начала необходимо создать группу для ограничения памяти:
sudo cgcreate -g memory:/mygroup
Далее настраиваются ограничение на использование памяти для группы mygroup. Например, ограничение на 512 MB:
LittleGreenCat / Using Jumphost
Last active
1 | ssh -J user1@hostname1:port1 user2@hostname2:port2 |
2 | # Где hostname1 - промежуточный jump узел с доступом извне, hostname2 узел изолированный от внешних каналов, но с сетевой связаностью с hostname1 |
3 | |
4 | # Для удобства можно прописать алиасом в файле ~/.bashrc |
5 | alias jump='ssh -J user1@hostname1:port1' |
6 | # И просто вызывать командой |
7 | jump user2@hostname2:port2 |
8 | |
9 | Опубликовано в https://t.me/gitgate |