Create a .tar.gz or .zip file
tar -czvf file.tar.gz directory-to-compress/
zip -r file.zip directory-to-compress/Extract contents of a .tar.gz or .zip file
tar -zxvf file.tar.gz
unzip file.zipCreate SSH key pair and connect SSH with this key
ssh-keygen -f file_name -C "Comment" # prompts for passphrase
ssh-copy-id -i file_name.pub user@host
ssh -i file_name user@hostImport public key of someone
gpg --import some-one.keySee all imported public keys
gpg --list-keysEncrypt a file
gpg --encrypt --armor -r some-one@server.com file.txt # or
gpg -e -u "Sender Name" -r "Receiver Name" file.txtDecrypt a file
gpg -d file.txt.gpg # to show content directly in bash or
gpg -d file.txt.gpg > file.txt # to create decrypted fileAdd existing private SSH key to bash
chmod 600 private.key # set permissions to be only read-writable by me
eval $(ssh-agent -s) # start ssh agent in background
ssh-add private.key # add SSH private key to bashTrigger the GPG agent and reauthenticate
echo "test" | gpg --clearsignRemount a device in read-write mode:
sudo mount -o remount,rw tiptoi /media/user/tiptoiCount the words of a PDF file:
pdftotext myfile.pdf - | wc -wQuickly create a random string to use for passwords:
date +%s | sha256sum | base64 | head -c 32 ; echosudo apt install curl # on debian/ubuntu if not already available
curl ipinfo.io/ipConvert all PHP files in the current directory to Unix line endings
find "./" -type f -name '*.php' -execdir dos2unix {} +Check which process uses a given port and (optionally) kill it
sudo lsof -i :1234
# COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
# docker-pr 43185 root 7u IPv4 123123 0t0 TCP *:1234 (LISTEN)
# docker-pr 43198 root 7u IPv6 123123 0t0 TCP *:1234 (LISTEN)
sudo kill 43185Run database import file on server (corresponding to the phpMyAdmin importer)
mysql -u database_user -p database_name < file.sql
mysql -u database_user -p -h database_host database_name < file.sql # if it's not localhostCreate database export file
mysqldump -u database_user -p database_name > file.sqlStart PHP's built in webserver for the current directory
php -S 127.0.0.1:8000Now you can access this directory as root under http://localhost:8000
Update all outdated packages at once
pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U