Last active
October 29, 2024 16:23
-
-
Save fiftin/2e49082df4bd916d3039fc2f4593921b to your computer and use it in GitHub Desktop.
Useful commands
This file contains 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
# Join array in Bash | |
mount_lines=( | |
"mount to test 123", | |
"mount to test 545", | |
) | |
mount_lines_str="" | |
for line in "${mount_lines[@]}" | |
do | |
mount_lines_str+="${line}\n" | |
done | |
# chmod for files only | |
chmod 644 $(find ./uploads -type f) | |
# NPM limit memory | |
NODE_OPTIONS=--max_old_space_size=512 npm install | |
# Parse JSON in Bash without jq | |
cat members.json | \ | |
python -c 'import json,sys;obj=json.load(sys.stdin);print obj["hits"]["hits"][0]["_source"]["xxx"]'; | |
cat members.json | \ | |
python -c ' | |
import json, sys | |
obj=json.load(sys.stdin) | |
for y in [x["_source"]["xxx"] for x in obj["hits"]["hits"]]: | |
print y | |
' | |
# multiline to file | |
cat << EOF > ./build/static/config.json | |
{ | |
"test": 235 | |
} | |
EOF | |
# SSH tunnel | |
ssh dev.antiland -N -f -L 9308:sphinx.antiland:9308 | |
# fast disk format | |
dd if=/dev/zero of=/dev/sdX bs=1M count=1 | |
https://www.digitalocean.com/community/tutorials/how-to-create-raid-arrays-with-mdadm-on-ubuntu-16-04 | |
# add user | |
useradd user1 -m -s /bin/bash | |
# default text editor | |
update-alternatives --config editor | |
# delete found files in (bash) | |
find . -name "FILE-TO-FIND" -exec rm -rf {} \; | |
# Copy directory to other server | |
tar -cf - /path/to/dir | ssh dest.server 'tar -xf - -C /path/to/parent/dir' | |
# compress file | |
tar -czvf archive.tar.gz stuff | |
# Copy file via netcat | |
nc -l -p 1234 > out.file | |
nc -w 3 [destination] 1234 < out.file | |
# Docker | |
docker run -p 127.0.0.1:3306:3306 --name my-mariadb -e MARIADB_ROOT_PASSWORD=pwd --restart unless-stopped -d mariadb | |
docker run -p 127.0.0.1:13306:3306 --name my-mysql -e MYSQL_ROOT_PASSWORD=pwd --restart unless-stopped -d mysql | |
docker run -p 127.0.0.1:5432:5432 --name my-postgres -e POSTGRES_PASSWORD=pwd --restart unless-stopped -d postgres # To connet use: ?sslmode=disable | |
docker run -p 127.0.0.1:27017:27017 --name my-mongo --restart unless-stopped -d mongo | |
docker run -p 127.0.0.1:6379:6379 --name my-redis --restart unless-stopped -d redis | |
# MacOS | |
# Restart VMWare | |
sudo /Applications/VMware\ Fusion.app/Contents/Library/services/services.sh --stop | |
sudo /Applications/VMware\ Fusion.app/Contents/Library/services/services.sh --start | |
# How to resize fs after disk size changed | |
https://unix.stackexchange.com/a/583544/342396 | |
# Yandex Cloud S3 CLI config | |
alias ycs3='aws s3 --endpoint-url=https://storage.yandexcloud.net --profile=yc' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment